@its-not-rocket-science/ananke 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/LICENSE +21 -0
  3. package/README.md +2199 -0
  4. package/STABLE_API.md +266 -0
  5. package/dist/src/anatomy/anatomy-compiler.d.ts +14 -0
  6. package/dist/src/anatomy/anatomy-compiler.js +277 -0
  7. package/dist/src/anatomy/anatomy-contracts.d.ts +94 -0
  8. package/dist/src/anatomy/anatomy-contracts.js +1 -0
  9. package/dist/src/anatomy/anatomy-helpers.d.ts +82 -0
  10. package/dist/src/anatomy/anatomy-helpers.js +233 -0
  11. package/dist/src/anatomy/anatomy-schema.d.ts +28 -0
  12. package/dist/src/anatomy/anatomy-schema.js +388 -0
  13. package/dist/src/anatomy/index.d.ts +4 -0
  14. package/dist/src/anatomy/index.js +4 -0
  15. package/dist/src/archetypes.d.ts +87 -0
  16. package/dist/src/archetypes.js +285 -0
  17. package/dist/src/arena.d.ts +173 -0
  18. package/dist/src/arena.js +695 -0
  19. package/dist/src/bridge/bridge-engine.d.ts +46 -0
  20. package/dist/src/bridge/bridge-engine.js +252 -0
  21. package/dist/src/bridge/index.d.ts +4 -0
  22. package/dist/src/bridge/index.js +5 -0
  23. package/dist/src/bridge/interpolation.d.ts +64 -0
  24. package/dist/src/bridge/interpolation.js +130 -0
  25. package/dist/src/bridge/mapping.d.ts +33 -0
  26. package/dist/src/bridge/mapping.js +54 -0
  27. package/dist/src/bridge/types.d.ts +94 -0
  28. package/dist/src/bridge/types.js +2 -0
  29. package/dist/src/campaign.d.ts +141 -0
  30. package/dist/src/campaign.js +235 -0
  31. package/dist/src/channels.d.ts +15 -0
  32. package/dist/src/channels.js +20 -0
  33. package/dist/src/chronicle.d.ts +124 -0
  34. package/dist/src/chronicle.js +232 -0
  35. package/dist/src/collective-activities.d.ts +154 -0
  36. package/dist/src/collective-activities.js +247 -0
  37. package/dist/src/competence/acoustic.d.ts +101 -0
  38. package/dist/src/competence/acoustic.js +242 -0
  39. package/dist/src/competence/catalogue.d.ts +30 -0
  40. package/dist/src/competence/catalogue.js +241 -0
  41. package/dist/src/competence/crafting.d.ts +35 -0
  42. package/dist/src/competence/crafting.js +88 -0
  43. package/dist/src/competence/engineering.d.ts +53 -0
  44. package/dist/src/competence/engineering.js +108 -0
  45. package/dist/src/competence/framework.d.ts +68 -0
  46. package/dist/src/competence/framework.js +694 -0
  47. package/dist/src/competence/index.d.ts +12 -0
  48. package/dist/src/competence/index.js +13 -0
  49. package/dist/src/competence/interspecies.d.ts +81 -0
  50. package/dist/src/competence/interspecies.js +108 -0
  51. package/dist/src/competence/language.d.ts +79 -0
  52. package/dist/src/competence/language.js +115 -0
  53. package/dist/src/competence/naturalist.d.ts +97 -0
  54. package/dist/src/competence/naturalist.js +187 -0
  55. package/dist/src/competence/navigation.d.ts +24 -0
  56. package/dist/src/competence/navigation.js +48 -0
  57. package/dist/src/competence/performance.d.ts +125 -0
  58. package/dist/src/competence/performance.js +210 -0
  59. package/dist/src/competence/teaching.d.ts +64 -0
  60. package/dist/src/competence/teaching.js +121 -0
  61. package/dist/src/competence/willpower.d.ts +74 -0
  62. package/dist/src/competence/willpower.js +114 -0
  63. package/dist/src/crafting/index.d.ts +55 -0
  64. package/dist/src/crafting/index.js +229 -0
  65. package/dist/src/crafting/manufacturing.d.ts +83 -0
  66. package/dist/src/crafting/manufacturing.js +165 -0
  67. package/dist/src/crafting/materials.d.ts +53 -0
  68. package/dist/src/crafting/materials.js +120 -0
  69. package/dist/src/crafting/recipes.d.ts +75 -0
  70. package/dist/src/crafting/recipes.js +233 -0
  71. package/dist/src/crafting/workshops.d.ts +61 -0
  72. package/dist/src/crafting/workshops.js +170 -0
  73. package/dist/src/debug.d.ts +86 -0
  74. package/dist/src/debug.js +76 -0
  75. package/dist/src/derive.d.ts +21 -0
  76. package/dist/src/derive.js +88 -0
  77. package/dist/src/describe.d.ts +29 -0
  78. package/dist/src/describe.js +276 -0
  79. package/dist/src/dialogue.d.ts +122 -0
  80. package/dist/src/dialogue.js +266 -0
  81. package/dist/src/dist.d.ts +20 -0
  82. package/dist/src/dist.js +39 -0
  83. package/dist/src/downtime.d.ts +89 -0
  84. package/dist/src/downtime.js +391 -0
  85. package/dist/src/economy.d.ts +116 -0
  86. package/dist/src/economy.js +182 -0
  87. package/dist/src/emotional-contagion.d.ts +142 -0
  88. package/dist/src/emotional-contagion.js +274 -0
  89. package/dist/src/equipment.d.ts +206 -0
  90. package/dist/src/equipment.js +598 -0
  91. package/dist/src/faction.d.ts +102 -0
  92. package/dist/src/faction.js +237 -0
  93. package/dist/src/generate.d.ts +35 -0
  94. package/dist/src/generate.js +166 -0
  95. package/dist/src/index.d.ts +42 -0
  96. package/dist/src/index.js +54 -0
  97. package/dist/src/inheritance.d.ts +69 -0
  98. package/dist/src/inheritance.js +136 -0
  99. package/dist/src/inventory.d.ts +194 -0
  100. package/dist/src/inventory.js +637 -0
  101. package/dist/src/item-durability.d.ts +69 -0
  102. package/dist/src/item-durability.js +308 -0
  103. package/dist/src/legend.d.ts +97 -0
  104. package/dist/src/legend.js +269 -0
  105. package/dist/src/lod.d.ts +9 -0
  106. package/dist/src/lod.js +84 -0
  107. package/dist/src/metrics.d.ts +51 -0
  108. package/dist/src/metrics.js +91 -0
  109. package/dist/src/model3d.d.ts +138 -0
  110. package/dist/src/model3d.js +214 -0
  111. package/dist/src/mythology.d.ts +101 -0
  112. package/dist/src/mythology.js +308 -0
  113. package/dist/src/narrative-render.d.ts +42 -0
  114. package/dist/src/narrative-render.js +194 -0
  115. package/dist/src/narrative-stress.d.ts +123 -0
  116. package/dist/src/narrative-stress.js +183 -0
  117. package/dist/src/narrative.d.ts +44 -0
  118. package/dist/src/narrative.js +257 -0
  119. package/dist/src/party.d.ts +70 -0
  120. package/dist/src/party.js +226 -0
  121. package/dist/src/polity.d.ts +262 -0
  122. package/dist/src/polity.js +398 -0
  123. package/dist/src/presets.d.ts +42 -0
  124. package/dist/src/presets.js +170 -0
  125. package/dist/src/progression.d.ts +170 -0
  126. package/dist/src/progression.js +256 -0
  127. package/dist/src/quest-generators.d.ts +76 -0
  128. package/dist/src/quest-generators.js +534 -0
  129. package/dist/src/quest.d.ts +239 -0
  130. package/dist/src/quest.js +520 -0
  131. package/dist/src/relationships-effects.d.ts +75 -0
  132. package/dist/src/relationships-effects.js +219 -0
  133. package/dist/src/relationships.d.ts +104 -0
  134. package/dist/src/relationships.js +347 -0
  135. package/dist/src/replay.d.ts +47 -0
  136. package/dist/src/replay.js +82 -0
  137. package/dist/src/rng.d.ts +9 -0
  138. package/dist/src/rng.js +37 -0
  139. package/dist/src/settlement-services.d.ts +67 -0
  140. package/dist/src/settlement-services.js +267 -0
  141. package/dist/src/settlement.d.ts +143 -0
  142. package/dist/src/settlement.js +419 -0
  143. package/dist/src/sim/action.d.ts +28 -0
  144. package/dist/src/sim/action.js +12 -0
  145. package/dist/src/sim/aging.d.ts +95 -0
  146. package/dist/src/sim/aging.js +243 -0
  147. package/dist/src/sim/ai/decide.d.ts +10 -0
  148. package/dist/src/sim/ai/decide.js +267 -0
  149. package/dist/src/sim/ai/perception.d.ts +12 -0
  150. package/dist/src/sim/ai/perception.js +54 -0
  151. package/dist/src/sim/ai/personality.d.ts +54 -0
  152. package/dist/src/sim/ai/personality.js +202 -0
  153. package/dist/src/sim/ai/presets.d.ts +2 -0
  154. package/dist/src/sim/ai/presets.js +28 -0
  155. package/dist/src/sim/ai/system.d.ts +6 -0
  156. package/dist/src/sim/ai/system.js +13 -0
  157. package/dist/src/sim/ai/targeting.d.ts +8 -0
  158. package/dist/src/sim/ai/targeting.js +42 -0
  159. package/dist/src/sim/ai/types.d.ts +14 -0
  160. package/dist/src/sim/ai/types.js +1 -0
  161. package/dist/src/sim/body.d.ts +9 -0
  162. package/dist/src/sim/body.js +32 -0
  163. package/dist/src/sim/bodyplan.d.ts +161 -0
  164. package/dist/src/sim/bodyplan.js +677 -0
  165. package/dist/src/sim/capability.d.ts +135 -0
  166. package/dist/src/sim/capability.js +8 -0
  167. package/dist/src/sim/combat.d.ts +21 -0
  168. package/dist/src/sim/combat.js +77 -0
  169. package/dist/src/sim/commandBuilders.d.ts +11 -0
  170. package/dist/src/sim/commandBuilders.js +39 -0
  171. package/dist/src/sim/commands.d.ts +71 -0
  172. package/dist/src/sim/commands.js +8 -0
  173. package/dist/src/sim/condition.d.ts +35 -0
  174. package/dist/src/sim/condition.js +21 -0
  175. package/dist/src/sim/cone.d.ts +40 -0
  176. package/dist/src/sim/cone.js +44 -0
  177. package/dist/src/sim/context.d.ts +68 -0
  178. package/dist/src/sim/context.js +1 -0
  179. package/dist/src/sim/density.d.ts +14 -0
  180. package/dist/src/sim/density.js +33 -0
  181. package/dist/src/sim/disease.d.ts +141 -0
  182. package/dist/src/sim/disease.js +353 -0
  183. package/dist/src/sim/entity.d.ts +251 -0
  184. package/dist/src/sim/entity.js +19 -0
  185. package/dist/src/sim/events.d.ts +25 -0
  186. package/dist/src/sim/events.js +5 -0
  187. package/dist/src/sim/explosion.d.ts +40 -0
  188. package/dist/src/sim/explosion.js +40 -0
  189. package/dist/src/sim/formation-unit.d.ts +138 -0
  190. package/dist/src/sim/formation-unit.js +197 -0
  191. package/dist/src/sim/formation.d.ts +12 -0
  192. package/dist/src/sim/formation.js +54 -0
  193. package/dist/src/sim/frontage.d.ts +30 -0
  194. package/dist/src/sim/frontage.js +84 -0
  195. package/dist/src/sim/grapple.d.ts +100 -0
  196. package/dist/src/sim/grapple.js +480 -0
  197. package/dist/src/sim/hazard.d.ts +104 -0
  198. package/dist/src/sim/hazard.js +201 -0
  199. package/dist/src/sim/hydrostatic.d.ts +58 -0
  200. package/dist/src/sim/hydrostatic.js +117 -0
  201. package/dist/src/sim/impairment.d.ts +20 -0
  202. package/dist/src/sim/impairment.js +162 -0
  203. package/dist/src/sim/indexing.d.ts +7 -0
  204. package/dist/src/sim/indexing.js +7 -0
  205. package/dist/src/sim/injury.d.ts +54 -0
  206. package/dist/src/sim/injury.js +66 -0
  207. package/dist/src/sim/intent.d.ts +26 -0
  208. package/dist/src/sim/intent.js +7 -0
  209. package/dist/src/sim/kernel.d.ts +45 -0
  210. package/dist/src/sim/kernel.js +1992 -0
  211. package/dist/src/sim/kinds.d.ts +64 -0
  212. package/dist/src/sim/kinds.js +56 -0
  213. package/dist/src/sim/knockback.d.ts +50 -0
  214. package/dist/src/sim/knockback.js +82 -0
  215. package/dist/src/sim/limb.d.ts +48 -0
  216. package/dist/src/sim/limb.js +78 -0
  217. package/dist/src/sim/medical.d.ts +32 -0
  218. package/dist/src/sim/medical.js +33 -0
  219. package/dist/src/sim/morale.d.ts +69 -0
  220. package/dist/src/sim/morale.js +92 -0
  221. package/dist/src/sim/mount.d.ts +150 -0
  222. package/dist/src/sim/mount.js +225 -0
  223. package/dist/src/sim/nutrition.d.ts +74 -0
  224. package/dist/src/sim/nutrition.js +168 -0
  225. package/dist/src/sim/occlusion.d.ts +8 -0
  226. package/dist/src/sim/occlusion.js +71 -0
  227. package/dist/src/sim/push.d.ts +11 -0
  228. package/dist/src/sim/push.js +79 -0
  229. package/dist/src/sim/ranged.d.ts +44 -0
  230. package/dist/src/sim/ranged.js +69 -0
  231. package/dist/src/sim/seeds.d.ts +3 -0
  232. package/dist/src/sim/seeds.js +16 -0
  233. package/dist/src/sim/sensory-extended.d.ts +103 -0
  234. package/dist/src/sim/sensory-extended.js +181 -0
  235. package/dist/src/sim/sensory.d.ts +38 -0
  236. package/dist/src/sim/sensory.js +109 -0
  237. package/dist/src/sim/skills.d.ts +70 -0
  238. package/dist/src/sim/skills.js +69 -0
  239. package/dist/src/sim/sleep.d.ts +107 -0
  240. package/dist/src/sim/sleep.js +215 -0
  241. package/dist/src/sim/spatial.d.ts +8 -0
  242. package/dist/src/sim/spatial.js +59 -0
  243. package/dist/src/sim/step/capability.d.ts +8 -0
  244. package/dist/src/sim/step/capability.js +77 -0
  245. package/dist/src/sim/step/concentration.d.ts +9 -0
  246. package/dist/src/sim/step/concentration.js +25 -0
  247. package/dist/src/sim/step/effects.d.ts +17 -0
  248. package/dist/src/sim/step/effects.js +96 -0
  249. package/dist/src/sim/step/energy.d.ts +3 -0
  250. package/dist/src/sim/step/energy.js +31 -0
  251. package/dist/src/sim/step/hazards.d.ts +4 -0
  252. package/dist/src/sim/step/hazards.js +19 -0
  253. package/dist/src/sim/step/injury.d.ts +10 -0
  254. package/dist/src/sim/step/injury.js +353 -0
  255. package/dist/src/sim/step/morale.d.ts +11 -0
  256. package/dist/src/sim/step/morale.js +130 -0
  257. package/dist/src/sim/step/movement.d.ts +5 -0
  258. package/dist/src/sim/step/movement.js +172 -0
  259. package/dist/src/sim/step/push.d.ts +11 -0
  260. package/dist/src/sim/step/push.js +79 -0
  261. package/dist/src/sim/step/substances.d.ts +3 -0
  262. package/dist/src/sim/step/substances.js +75 -0
  263. package/dist/src/sim/substance.d.ts +38 -0
  264. package/dist/src/sim/substance.js +57 -0
  265. package/dist/src/sim/systemic-toxicology.d.ts +109 -0
  266. package/dist/src/sim/systemic-toxicology.js +263 -0
  267. package/dist/src/sim/team.d.ts +9 -0
  268. package/dist/src/sim/team.js +37 -0
  269. package/dist/src/sim/tech.d.ts +36 -0
  270. package/dist/src/sim/tech.js +46 -0
  271. package/dist/src/sim/terrain.d.ts +121 -0
  272. package/dist/src/sim/terrain.js +141 -0
  273. package/dist/src/sim/testing.d.ts +13 -0
  274. package/dist/src/sim/testing.js +100 -0
  275. package/dist/src/sim/thermoregulation.d.ts +77 -0
  276. package/dist/src/sim/thermoregulation.js +161 -0
  277. package/dist/src/sim/tick.d.ts +3 -0
  278. package/dist/src/sim/tick.js +3 -0
  279. package/dist/src/sim/toxicology.d.ts +52 -0
  280. package/dist/src/sim/toxicology.js +104 -0
  281. package/dist/src/sim/trace.d.ts +141 -0
  282. package/dist/src/sim/trace.js +1 -0
  283. package/dist/src/sim/tuning.d.ts +16 -0
  284. package/dist/src/sim/tuning.js +42 -0
  285. package/dist/src/sim/vec3.d.ts +14 -0
  286. package/dist/src/sim/vec3.js +31 -0
  287. package/dist/src/sim/weapon_dynamics.d.ts +102 -0
  288. package/dist/src/sim/weapon_dynamics.js +142 -0
  289. package/dist/src/sim/weather.d.ts +95 -0
  290. package/dist/src/sim/weather.js +105 -0
  291. package/dist/src/sim/world.d.ts +52 -0
  292. package/dist/src/sim/world.js +1 -0
  293. package/dist/src/sim/wound-aging.d.ts +120 -0
  294. package/dist/src/sim/wound-aging.js +223 -0
  295. package/dist/src/species.d.ts +106 -0
  296. package/dist/src/species.js +664 -0
  297. package/dist/src/story-arcs.d.ts +17 -0
  298. package/dist/src/story-arcs.js +276 -0
  299. package/dist/src/tech-diffusion.d.ts +80 -0
  300. package/dist/src/tech-diffusion.js +185 -0
  301. package/dist/src/traits.d.ts +25 -0
  302. package/dist/src/traits.js +178 -0
  303. package/dist/src/types.d.ts +117 -0
  304. package/dist/src/types.js +1 -0
  305. package/dist/src/units.d.ts +41 -0
  306. package/dist/src/units.js +64 -0
  307. package/dist/src/weapons.d.ts +20 -0
  308. package/dist/src/weapons.js +824 -0
  309. package/dist/src/world-generation.d.ts +52 -0
  310. package/dist/src/world-generation.js +301 -0
  311. package/package.json +74 -0
@@ -0,0 +1,178 @@
1
+ import { DamageChannel, channelMask } from "./channels.js";
2
+ import { SCALE, clampQ, q, qMul } from "./units.js";
3
+ export const TRAITS = {
4
+ sealed: {
5
+ id: "sealed",
6
+ name: "Sealed",
7
+ description: "Resistant to chemical exposure and suffocation-like hazards (sealed system).",
8
+ resistantTo: channelMask(DamageChannel.Chemical, DamageChannel.Suffocation),
9
+ mult: { shockTolerance: q(1.10) },
10
+ },
11
+ nonConductive: {
12
+ id: "nonConductive",
13
+ name: "Non-conductive",
14
+ description: "Highly resistant to electrical hazards.",
15
+ immuneTo: channelMask(DamageChannel.Electrical),
16
+ },
17
+ distributedControl: {
18
+ id: "distributedControl",
19
+ name: "Distributed control",
20
+ description: "No single control core; more tolerant of local disruption.",
21
+ resistantTo: channelMask(DamageChannel.ControlDisruption),
22
+ mult: { concussionTolerance: q(1.20), shockTolerance: q(1.10) },
23
+ },
24
+ noSurfaceLayer: {
25
+ id: "noSurfaceLayer",
26
+ name: "No surface layer",
27
+ description: "Surface injuries are largely irrelevant.",
28
+ mult: { surfaceIntegrity: q(9.99) },
29
+ },
30
+ noBulkMedium: {
31
+ id: "noBulkMedium",
32
+ name: "No bulk medium",
33
+ description: "Bulk trauma effects are reduced.",
34
+ mult: { bulkIntegrity: q(2.00), shockTolerance: q(1.25) },
35
+ },
36
+ highThermalMass: {
37
+ id: "highThermalMass",
38
+ name: "High thermal mass",
39
+ description: "Temperature changes slowly; tolerant of thermal exposure.",
40
+ mult: { heatTolerance: q(1.30), coldTolerance: q(1.30) },
41
+ },
42
+ fragileStructure: {
43
+ id: "fragileStructure",
44
+ name: "Fragile structure",
45
+ description: "More susceptible to structural failure.",
46
+ mult: { structureIntegrity: q(0.75), structureScale: q(0.90) },
47
+ },
48
+ reinforcedStructure: {
49
+ id: "reinforcedStructure",
50
+ name: "Reinforced structure",
51
+ description: "Upgraded load-bearing structure.",
52
+ mult: { structureIntegrity: q(1.25), structureScale: q(1.10) },
53
+ },
54
+ chemicalImmune: {
55
+ id: "chemicalImmune",
56
+ name: "Chemical immune",
57
+ description: "Unaffected by chemical/toxin hazards.",
58
+ immuneTo: channelMask(DamageChannel.Chemical),
59
+ },
60
+ radiationHardened: {
61
+ id: "radiationHardened",
62
+ name: "Radiation hardened",
63
+ description: "Resistant to radiation damage and radiation-induced control glitches.",
64
+ resistantTo: channelMask(DamageChannel.Radiation, DamageChannel.ControlDisruption),
65
+ mult: { controlQuality: q(1.05) },
66
+ },
67
+ leader: {
68
+ id: "leader",
69
+ name: "Leader",
70
+ description: "Provides morale aura to nearby allies, reducing their fear accumulation.",
71
+ },
72
+ standardBearer: {
73
+ id: "standardBearer",
74
+ name: "Standard-bearer",
75
+ description: "Carries a rallying standard; provides a smaller morale aura to nearby allies.",
76
+ },
77
+ };
78
+ const MULT_ACCESSORS = {
79
+ // Resilience
80
+ shockTolerance: {
81
+ get: (a) => a.resilience.shockTolerance,
82
+ set: (a, v) => { a.resilience.shockTolerance = v; },
83
+ max: 10 * SCALE.Q,
84
+ },
85
+ concussionTolerance: {
86
+ get: (a) => a.resilience.concussionTolerance,
87
+ set: (a, v) => { a.resilience.concussionTolerance = v; },
88
+ max: 10 * SCALE.Q,
89
+ },
90
+ distressTolerance: {
91
+ get: (a) => a.resilience.distressTolerance,
92
+ set: (a, v) => { a.resilience.distressTolerance = v; },
93
+ max: 10 * SCALE.Q,
94
+ },
95
+ // Integrity (your traits imply these exist; adjust nesting if needed)
96
+ surfaceIntegrity: {
97
+ get: (a) => a.resilience.surfaceIntegrity,
98
+ set: (a, v) => { a.resilience.surfaceIntegrity = v; },
99
+ max: 10 * SCALE.Q,
100
+ },
101
+ bulkIntegrity: {
102
+ get: (a) => a.resilience.bulkIntegrity,
103
+ set: (a, v) => { a.resilience.bulkIntegrity = v; },
104
+ max: 10 * SCALE.Q,
105
+ },
106
+ structureIntegrity: {
107
+ get: (a) => a.resilience.structureIntegrity,
108
+ set: (a, v) => { a.resilience.structureIntegrity = v; },
109
+ max: 10 * SCALE.Q,
110
+ },
111
+ // Morphology / structure scaling
112
+ structureScale: {
113
+ get: (a) => a.morphology.structureScale,
114
+ set: (a, v) => { a.morphology.structureScale = v; },
115
+ max: 10 * SCALE.Q,
116
+ },
117
+ // Thermoregulation / tolerances
118
+ heatTolerance: {
119
+ get: (a) => a.resilience.heatTolerance,
120
+ set: (a, v) => { a.resilience.heatTolerance = v; },
121
+ max: 10 * SCALE.Q,
122
+ },
123
+ coldTolerance: {
124
+ get: (a) => a.resilience.coldTolerance,
125
+ set: (a, v) => { a.resilience.coldTolerance = v; },
126
+ max: 10 * SCALE.Q,
127
+ },
128
+ // Control / coordination quality
129
+ controlQuality: {
130
+ get: (a) => a.control.controlQuality,
131
+ set: (a, v) => { a.control.controlQuality = v; },
132
+ max: 10 * SCALE.Q,
133
+ },
134
+ };
135
+ function applyMult(a, key, mult) {
136
+ const acc = MULT_ACCESSORS[key];
137
+ const current = acc.get(a);
138
+ const next = clampQ(qMul(current, mult), 0, acc.max ?? (10 * SCALE.Q));
139
+ acc.set(a, next);
140
+ }
141
+ export const TRAIT_MUTATORS = (() => {
142
+ const out = {};
143
+ for (const id of Object.keys(TRAITS)) {
144
+ const trait = TRAITS[id];
145
+ out[id] = (a) => {
146
+ if (!trait.mult)
147
+ return;
148
+ for (const [k, mult] of Object.entries(trait.mult)) {
149
+ applyMult(a, k, mult);
150
+ }
151
+ };
152
+ }
153
+ return out;
154
+ })();
155
+ export function buildTraitProfile(traits) {
156
+ let immuneMask = 0;
157
+ let resistantMask = 0;
158
+ for (const id of traits) {
159
+ const t = TRAITS[id];
160
+ if (t.immuneTo)
161
+ immuneMask |= t.immuneTo;
162
+ if (t.resistantTo)
163
+ resistantMask |= t.resistantTo;
164
+ }
165
+ return { traits: [...traits].sort(), immuneMask, resistantMask };
166
+ }
167
+ export function applyTraitsToAttributes(base, traits) {
168
+ const out = structuredClone(base);
169
+ // Deterministic ordering
170
+ const sorted = [...traits].sort();
171
+ for (const t of sorted) {
172
+ const mut = TRAIT_MUTATORS[t];
173
+ if (!mut)
174
+ throw new Error(`Unknown trait: ${t}`);
175
+ mut(out);
176
+ }
177
+ return out;
178
+ }
@@ -0,0 +1,117 @@
1
+ import type { I32, Q } from "./units.js";
2
+ export interface LanguageCapacity {
3
+ /** Language identifier (e.g., "common", "elvish", "klingonese"). */
4
+ languageId: string;
5
+ /** Fluency level: q(1.0) = native, q(0.50) = conversational, q(0.20) = survival. */
6
+ fluency_Q: Q;
7
+ }
8
+ export interface CognitiveProfile {
9
+ /** Language, argument complexity, written/spoken command clarity. */
10
+ linguistic: Q;
11
+ /** Deductive reasoning, planning horizon, pattern abstraction. */
12
+ logicalMathematical: Q;
13
+ /** 3-D world modelling, navigation, cover identification, targeting lead. */
14
+ spatial: Q;
15
+ /** Proprioception, fine motor precision, tool mastery. */
16
+ bodilyKinesthetic: Q;
17
+ /** Rhythm, acoustic pattern recognition, sound cue detection. */
18
+ musical: Q;
19
+ /** Social reading, empathy, leadership radius, teaching quality. */
20
+ interpersonal: Q;
21
+ /** Self-regulation, focus, willpower, fear resistance. */
22
+ intrapersonal: Q;
23
+ /** Pattern recognition in living systems, tracking, herbalism, taming. */
24
+ naturalist: Q;
25
+ /** Empathy across species boundaries; reading non-human intent. */
26
+ interSpecies: Q;
27
+ /** Phase 36: species IDs with which the entity has deep familiarity. */
28
+ speciesAffinity?: string[];
29
+ /** Phase 36: map of species ID → comprehension quality for signaling. */
30
+ signalVocab?: Map<string, Q>;
31
+ }
32
+ export type LocomotionMode = "ground" | "flight" | "swim" | "climb";
33
+ export interface LocomotionCapacity {
34
+ mode: LocomotionMode;
35
+ /** Maximum speed in this mode [SCALE.mps]. */
36
+ maxSpeed_mps: number;
37
+ /** Energy cost multiplier on peakPower_W per unit distance. */
38
+ costMul: Q;
39
+ /** Target altitude maintained during flight [SCALE.m]; ignored for other modes. */
40
+ cruiseAlt_m?: number;
41
+ }
42
+ export interface Perception {
43
+ visionRange_m: I32;
44
+ visionArcDeg: number;
45
+ halfArcCosQ: Q;
46
+ hearingRange_m: I32;
47
+ decisionLatency_s: I32;
48
+ attentionDepth: number;
49
+ threatHorizon_m: I32;
50
+ }
51
+ export interface Morphology {
52
+ stature_m: I32;
53
+ mass_kg: I32;
54
+ actuatorMass_kg: I32;
55
+ actuatorScale: Q;
56
+ structureScale: Q;
57
+ reachScale: Q;
58
+ }
59
+ export interface Performance {
60
+ peakForce_N: I32;
61
+ peakPower_W: I32;
62
+ continuousPower_W: I32;
63
+ reserveEnergy_J: I32;
64
+ conversionEfficiency: Q;
65
+ }
66
+ export interface Control {
67
+ controlQuality: Q;
68
+ reactionTime_s: I32;
69
+ stability: Q;
70
+ fineControl: Q;
71
+ }
72
+ export interface Resilience {
73
+ surfaceIntegrity: Q;
74
+ bulkIntegrity: Q;
75
+ structureIntegrity: Q;
76
+ distressTolerance: Q;
77
+ shockTolerance: Q;
78
+ concussionTolerance: Q;
79
+ heatTolerance: Q;
80
+ coldTolerance: Q;
81
+ fatigueRate: Q;
82
+ recoveryRate: Q;
83
+ magicResist?: Q;
84
+ fearResponse?: "flight" | "freeze" | "berserk";
85
+ }
86
+ export type PersonalityId = "berserker" | "coward" | "guardian" | "schemer" | "soldier";
87
+ /**
88
+ * Four orthogonal behavioural axes that modulate decisions on top of the base AIPolicy.
89
+ * All fields are Q-coded [0, SCALE.Q]; q(0.50) is neutral (no change from baseline).
90
+ */
91
+ export interface PersonalityTraits {
92
+ /** 0 = passive/retreat-prone; q(1.0) = fights to the end, ignores hesitation. */
93
+ aggression: Q;
94
+ /** 0 = reckless; q(1.0) = maximises defensive intensity and cover-seeking. */
95
+ caution: Q;
96
+ /** 0 = pure self-preservation; q(1.0) = overrides focus target to shield allies. */
97
+ loyalty: Q;
98
+ /** 0 = locks onto first target; q(1.0) = hunts the most wounded enemy. */
99
+ opportunism: Q;
100
+ }
101
+ export interface IndividualAttributes {
102
+ morphology: Morphology;
103
+ performance: Performance;
104
+ control: Control;
105
+ resilience: Resilience;
106
+ perception?: Perception;
107
+ /** Phase 32A: declared locomotion modes (absent = ground-only). */
108
+ locomotionModes?: LocomotionCapacity[];
109
+ /** Phase 33: Gardner's multiple intelligences + inter-species. */
110
+ cognition?: CognitiveProfile;
111
+ /** Phase 37: Language capacities for multilingual communication. */
112
+ languages?: LanguageCapacity[];
113
+ }
114
+ export interface EnergyState {
115
+ reserveEnergy_J: I32;
116
+ fatigue: Q;
117
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ export type I32 = number;
2
+ export type Q = number;
3
+ export declare const SCALE: {
4
+ Q: number;
5
+ m: number;
6
+ s: number;
7
+ kg: number;
8
+ N: number;
9
+ W: number;
10
+ J: number;
11
+ mps: number;
12
+ mps2: number;
13
+ };
14
+ export declare const G_mps2: I32;
15
+ export declare const q: (x: number) => Q;
16
+ export declare const clampQ: (x: Q, lo?: number, hi?: number) => Q;
17
+ export declare const qMul: (a: Q, b: Q) => Q;
18
+ export declare const qDiv: (a: Q, b: Q) => Q;
19
+ export declare const mulDiv: (a: I32, b: I32, div: I32) => I32;
20
+ export declare const to: {
21
+ m: (x: number) => I32;
22
+ s: (x: number) => I32;
23
+ kg: (x: number) => I32;
24
+ N: (x: number) => I32;
25
+ W: (x: number) => I32;
26
+ J: (x: number) => I32;
27
+ mps: (x: number) => I32;
28
+ mps2: (x: number) => I32;
29
+ };
30
+ export declare const from: {
31
+ m: (x: I32) => number;
32
+ s: (x: I32) => number;
33
+ kg: (x: I32) => number;
34
+ N: (x: I32) => number;
35
+ W: (x: I32) => number;
36
+ J: (x: I32) => number;
37
+ mps: (x: I32) => number;
38
+ mps2: (x: I32) => number;
39
+ };
40
+ export declare const sqrtQ: (xQ: Q) => Q;
41
+ export declare const cbrtQ: (xQ: Q) => Q;
@@ -0,0 +1,64 @@
1
+ export const SCALE = {
2
+ Q: 10_000, // 1.0 == 10000
3
+ m: 10_000, // 0.1 mm
4
+ s: 10_000, // 0.1 ms
5
+ kg: 1_000, // 1 g
6
+ N: 100, // 0.01 N
7
+ W: 1, // 1 W
8
+ J: 1, // 1 J
9
+ mps: 10_000, // 0.1 mm/s
10
+ mps2: 10_000, // 0.1 mm/s^2
11
+ };
12
+ export const G_mps2 = Math.round(9.80665 * SCALE.mps2);
13
+ export const q = (x) => Math.round(x * SCALE.Q);
14
+ export const clampQ = (x, lo = 0, hi = SCALE.Q) => Math.max(lo, Math.min(hi, x));
15
+ export const qMul = (a, b) => Math.trunc((a * b) / SCALE.Q);
16
+ export const qDiv = (a, b) => Math.trunc((a * SCALE.Q) / b);
17
+ export const mulDiv = (a, b, div) => Number((BigInt(a) * BigInt(b)) / BigInt(div));
18
+ export const to = {
19
+ m: (x) => Math.round(x * SCALE.m),
20
+ s: (x) => Math.round(x * SCALE.s),
21
+ kg: (x) => Math.round(x * SCALE.kg),
22
+ N: (x) => Math.round(x * SCALE.N),
23
+ W: (x) => Math.round(x * SCALE.W),
24
+ J: (x) => Math.round(x * SCALE.J),
25
+ mps: (x) => Math.round(x * SCALE.mps),
26
+ mps2: (x) => Math.round(x * SCALE.mps2),
27
+ };
28
+ export const from = {
29
+ m: (x) => x / SCALE.m,
30
+ s: (x) => x / SCALE.s,
31
+ kg: (x) => x / SCALE.kg,
32
+ N: (x) => x / SCALE.N,
33
+ W: (x) => x / SCALE.W,
34
+ J: (x) => x / SCALE.J,
35
+ mps: (x) => x / SCALE.mps,
36
+ mps2: (x) => x / SCALE.mps2,
37
+ };
38
+ // Deterministic integer roots for Q-scaled values
39
+ export const sqrtQ = (xQ) => {
40
+ const x = BigInt(Math.max(1, xQ));
41
+ const X = x * BigInt(SCALE.Q);
42
+ let r = BigInt(SCALE.Q);
43
+ for (let i = 0; i < 10; i++) {
44
+ const rNew = (r + X / r) / 2n;
45
+ if (rNew === r)
46
+ break; // Converged
47
+ r = rNew;
48
+ }
49
+ return Number(r);
50
+ };
51
+ export const cbrtQ = (xQ) => {
52
+ const x = BigInt(Math.max(1, xQ));
53
+ const X = x * BigInt(SCALE.Q) * BigInt(SCALE.Q);
54
+ let r = BigInt(SCALE.Q);
55
+ for (let i = 0; i < 12; i++) {
56
+ const r2 = r * r;
57
+ r = (2n * r + X / r2) / 3n;
58
+ if (r <= 0n) {
59
+ r = 1n;
60
+ break;
61
+ }
62
+ }
63
+ return Number(r);
64
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Phase 17: Historical weapons database
3
+ * Spans six eras with realistic physical properties calibrated to archaeological and
4
+ * biomechanics literature. All units follow the project SI fixed-point conventions.
5
+ */
6
+ import type { Weapon, RangedWeapon } from "./equipment.js";
7
+ export declare const PREHISTORIC_MELEE: Weapon[];
8
+ export declare const CLASSICAL_MELEE: Weapon[];
9
+ export declare const MEDIEVAL_MELEE: Weapon[];
10
+ export declare const RENAISSANCE_MELEE: Weapon[];
11
+ export declare const EARLY_MODERN_MELEE: Weapon[];
12
+ export declare const CONTEMPORARY_MELEE: Weapon[];
13
+ export declare const PREHISTORIC_RANGED: RangedWeapon[];
14
+ export declare const CLASSICAL_RANGED: RangedWeapon[];
15
+ export declare const MEDIEVAL_RANGED: RangedWeapon[];
16
+ export declare const RENAISSANCE_RANGED: RangedWeapon[];
17
+ export declare const EARLY_MODERN_RANGED: RangedWeapon[];
18
+ export declare const CONTEMPORARY_RANGED: RangedWeapon[];
19
+ export declare const ALL_HISTORICAL_MELEE: Weapon[];
20
+ export declare const ALL_HISTORICAL_RANGED: RangedWeapon[];