@v12-engine/engine 0.0.0-stage → 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 (341) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abilities/buffs.d.ts +83 -0
  3. package/dist/abilities/castTold.d.ts +12 -0
  4. package/dist/abilities/charges.d.ts +28 -0
  5. package/dist/abilities/dispel.d.ts +9 -0
  6. package/dist/abilities/effectFields.d.ts +10 -0
  7. package/dist/abilities/effects/buff.d.ts +8 -0
  8. package/dist/abilities/effects/core.d.ts +1 -0
  9. package/dist/abilities/effects/damage.d.ts +1 -0
  10. package/dist/abilities/effects/heal.d.ts +2 -0
  11. package/dist/abilities/effects/missile.d.ts +1 -0
  12. package/dist/abilities/effects/moves.d.ts +11 -0
  13. package/dist/abilities/effects/passives.d.ts +15 -0
  14. package/dist/abilities/effects/sight.d.ts +4 -0
  15. package/dist/abilities/effects/spawn.d.ts +2 -0
  16. package/dist/abilities/effects/timed.d.ts +4 -0
  17. package/dist/abilities/effects/trade.d.ts +1 -0
  18. package/dist/abilities/effects.d.ts +122 -0
  19. package/dist/abilities/land.d.ts +21 -0
  20. package/dist/abilities/scaled.d.ts +21 -0
  21. package/dist/abilities/text.d.ts +113 -0
  22. package/dist/ai/area.d.ts +53 -0
  23. package/dist/ai/brain.d.ts +528 -0
  24. package/dist/ai/budget.d.ts +67 -0
  25. package/dist/ai/checks.d.ts +115 -0
  26. package/dist/ai/computer.d.ts +166 -0
  27. package/dist/ai/defence.d.ts +108 -0
  28. package/dist/ai/define.d.ts +21 -0
  29. package/dist/ai/economy.d.ts +129 -0
  30. package/dist/ai/geometry.d.ts +35 -0
  31. package/dist/ai/goals.d.ts +360 -0
  32. package/dist/ai/index.d.ts +38 -0
  33. package/dist/ai/knowledge.d.ts +418 -0
  34. package/dist/ai/lanes.d.ts +232 -0
  35. package/dist/ai/melee/build.d.ts +61 -0
  36. package/dist/ai/melee/goals.d.ts +299 -0
  37. package/dist/ai/melee/heroes.d.ts +27 -0
  38. package/dist/ai/melee/index.d.ts +14 -0
  39. package/dist/ai/melee/production.d.ts +8 -0
  40. package/dist/ai/melee/surrender.d.ts +24 -0
  41. package/dist/ai/micro.d.ts +278 -0
  42. package/dist/ai/mission.d.ts +195 -0
  43. package/dist/ai/missionRules.d.ts +18 -0
  44. package/dist/ai/module.d.ts +116 -0
  45. package/dist/ai/options.d.ts +61 -0
  46. package/dist/ai/plans/build.d.ts +280 -0
  47. package/dist/ai/plans/placement.d.ts +82 -0
  48. package/dist/ai/plans/plans.d.ts +105 -0
  49. package/dist/ai/plans/production.d.ts +210 -0
  50. package/dist/ai/plans/purse.d.ts +73 -0
  51. package/dist/ai/plans/tech.d.ts +37 -0
  52. package/dist/ai/profiles.d.ts +204 -0
  53. package/dist/ai/reach.d.ts +4 -0
  54. package/dist/ai/report.d.ts +203 -0
  55. package/dist/ai/roles.d.ts +133 -0
  56. package/dist/ai/rules.d.ts +288 -0
  57. package/dist/ai/scouting.d.ts +98 -0
  58. package/dist/ai/settings.d.ts +73 -0
  59. package/dist/ai/squads.d.ts +429 -0
  60. package/dist/ai/strength.d.ts +167 -0
  61. package/dist/ai/task.d.ts +118 -0
  62. package/dist/ai/tasks/attack.d.ts +7 -0
  63. package/dist/ai/tasks/capture.d.ts +21 -0
  64. package/dist/ai/tasks/creep.d.ts +16 -0
  65. package/dist/ai/tasks/defend.d.ts +29 -0
  66. package/dist/ai/tasks/drop.d.ts +34 -0
  67. package/dist/ai/tasks/escort.d.ts +16 -0
  68. package/dist/ai/tasks/gather.d.ts +23 -0
  69. package/dist/ai/tasks/harass.d.ts +7 -0
  70. package/dist/ai/tasks/hold.d.ts +20 -0
  71. package/dist/ai/tasks/index.d.ts +32 -0
  72. package/dist/ai/tasks/move.d.ts +19 -0
  73. package/dist/ai/tasks/patrol.d.ts +8 -0
  74. package/dist/ai/tasks/retreat.d.ts +20 -0
  75. package/dist/ai/tasks/scout.d.ts +29 -0
  76. package/dist/ai/tasks/shared.d.ts +74 -0
  77. package/dist/ai/team.d.ts +155 -0
  78. package/dist/ai/threat.d.ts +91 -0
  79. package/dist/ai/view.d.ts +366 -0
  80. package/dist/ai/waves.d.ts +126 -0
  81. package/dist/ai.js +6239 -0
  82. package/dist/ai.js.map +1 -0
  83. package/dist/aiTesting.d.ts +179 -0
  84. package/dist/areas.d.ts +149 -0
  85. package/dist/attacks.d.ts +66 -0
  86. package/dist/attributes.d.ts +66 -0
  87. package/dist/brain-BvVdUhX8.js +7659 -0
  88. package/dist/brain-BvVdUhX8.js.map +1 -0
  89. package/dist/builds-C6LfgvEU.js +460 -0
  90. package/dist/builds-C6LfgvEU.js.map +1 -0
  91. package/dist/bytes.d.ts +6 -0
  92. package/dist/camps.d.ts +95 -0
  93. package/dist/capture.d.ts +131 -0
  94. package/dist/cellLayers.d.ts +75 -0
  95. package/dist/cinematics.d.ts +194 -0
  96. package/dist/clock.d.ts +32 -0
  97. package/dist/commands.d.ts +235 -0
  98. package/dist/components.d.ts +184 -0
  99. package/dist/computers.d.ts +108 -0
  100. package/dist/concealment.d.ts +61 -0
  101. package/dist/coreComponents-syuh2fPG.js +5149 -0
  102. package/dist/coreComponents-syuh2fPG.js.map +1 -0
  103. package/dist/coreComponents.d.ts +1 -0
  104. package/dist/dashing.d.ts +8 -0
  105. package/dist/debug.d.ts +36 -0
  106. package/dist/debug.js +3 -0
  107. package/dist/debugCommands-CzjrSm66.js +14739 -0
  108. package/dist/debugCommands-CzjrSm66.js.map +1 -0
  109. package/dist/debugCommands.d.ts +213 -0
  110. package/dist/debugging.d.ts +10 -0
  111. package/dist/definitions.d.ts +43 -0
  112. package/dist/defs.d.ts +1162 -0
  113. package/dist/denying.d.ts +81 -0
  114. package/dist/destructibles.d.ts +27 -0
  115. package/dist/determinism-BCymQwiE.js +518 -0
  116. package/dist/determinism-BCymQwiE.js.map +1 -0
  117. package/dist/determinism.d.ts +121 -0
  118. package/dist/dialog.d.ts +94 -0
  119. package/dist/effectRefs.d.ts +16 -0
  120. package/dist/effects.d.ts +80 -0
  121. package/dist/endings.d.ts +22 -0
  122. package/dist/engagement.d.ts +108 -0
  123. package/dist/engineEvents.d.ts +710 -0
  124. package/dist/entity.d.ts +409 -0
  125. package/dist/entityIndex.d.ts +50 -0
  126. package/dist/errors.d.ts +85 -0
  127. package/dist/events.d.ts +97 -0
  128. package/dist/exactMath.d.ts +63 -0
  129. package/dist/features.d.ts +10 -0
  130. package/dist/fields.d.ts +114 -0
  131. package/dist/fixture.d.ts +17 -0
  132. package/dist/fog.d.ts +110 -0
  133. package/dist/formation.d.ts +111 -0
  134. package/dist/friendlyFire.d.ts +26 -0
  135. package/dist/game-DiJEN-Ks.js +5800 -0
  136. package/dist/game-DiJEN-Ks.js.map +1 -0
  137. package/dist/game.d.ts +501 -0
  138. package/dist/gameData.d.ts +325 -0
  139. package/dist/gameFiles.d.ts +26 -0
  140. package/dist/gates.d.ts +28 -0
  141. package/dist/generate.d.ts +403 -0
  142. package/dist/generateWorker.d.ts +39 -0
  143. package/dist/grid.d.ts +53 -0
  144. package/dist/ground.d.ts +127 -0
  145. package/dist/groundSpeed.d.ts +22 -0
  146. package/dist/hero.d.ts +177 -0
  147. package/dist/home.d.ts +14 -0
  148. package/dist/hooks.d.ts +780 -0
  149. package/dist/hotReload.d.ts +76 -0
  150. package/dist/ids.d.ts +26 -0
  151. package/dist/index.d.ts +227 -0
  152. package/dist/index.js +4701 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/inspect-D9dWHmZ0.js +491 -0
  155. package/dist/inspect-D9dWHmZ0.js.map +1 -0
  156. package/dist/inspect.d.ts +176 -0
  157. package/dist/inventory.d.ts +18 -0
  158. package/dist/items.d.ts +91 -0
  159. package/dist/lanes.d.ts +213 -0
  160. package/dist/life.d.ts +53 -0
  161. package/dist/local-Dkovq42k.js +1379 -0
  162. package/dist/local-Dkovq42k.js.map +1 -0
  163. package/dist/log.d.ts +140 -0
  164. package/dist/manaBurn.d.ts +39 -0
  165. package/dist/map/file.d.ts +114 -0
  166. package/dist/map/images.d.ts +18 -0
  167. package/dist/map/look.d.ts +47 -0
  168. package/dist/map/pathProfile.d.ts +13 -0
  169. package/dist/map/resize.d.ts +54 -0
  170. package/dist/map/schema.d.ts +10 -0
  171. package/dist/map/terrain.d.ts +32 -0
  172. package/dist/map/types.d.ts +613 -0
  173. package/dist/map.d.ts +7 -0
  174. package/dist/mapCheck/cells.d.ts +19 -0
  175. package/dist/mapCheck/rule.d.ts +30 -0
  176. package/dist/mapCheck/rules/names.d.ts +3 -0
  177. package/dist/mapCheck/rules/objects.d.ts +3 -0
  178. package/dist/mapCheck/rules/paths.d.ts +3 -0
  179. package/dist/mapCheck/rules/players.d.ts +3 -0
  180. package/dist/mapCheck/rules/races.d.ts +3 -0
  181. package/dist/mapCheck/rules/random.d.ts +3 -0
  182. package/dist/mapCheck/rules/regions.d.ts +3 -0
  183. package/dist/mapCheck/rules/targets.d.ts +3 -0
  184. package/dist/mapCheck/rules/walking.d.ts +3 -0
  185. package/dist/mapCheck.d.ts +23 -0
  186. package/dist/mapFields.d.ts +364 -0
  187. package/dist/mapFile.d.ts +23 -0
  188. package/dist/mapMeasure.d.ts +95 -0
  189. package/dist/mapMerge.d.ts +19 -0
  190. package/dist/mapObjectives.d.ts +82 -0
  191. package/dist/mapObjects.d.ts +1 -0
  192. package/dist/math.d.ts +44 -0
  193. package/dist/messages.d.ts +150 -0
  194. package/dist/missionRules-C-bGxm0Q.js +523 -0
  195. package/dist/missionRules-C-bGxm0Q.js.map +1 -0
  196. package/dist/missionRules.d.ts +179 -0
  197. package/dist/mods.d.ts +146 -0
  198. package/dist/names.d.ts +93 -0
  199. package/dist/navigation/agentParams.d.ts +4 -0
  200. package/dist/navigation/air.d.ts +89 -0
  201. package/dist/navigation/builds.d.ts +140 -0
  202. package/dist/navigation/groundAreas.d.ts +23 -0
  203. package/dist/navigation/navigation.d.ts +127 -0
  204. package/dist/navigation/recast.d.ts +214 -0
  205. package/dist/navigation/sidePaths.d.ts +69 -0
  206. package/dist/navigation/sized.d.ts +1 -0
  207. package/dist/navigation-worker.js +11 -0
  208. package/dist/navigation-worker.js.map +1 -0
  209. package/dist/nearest.d.ts +8 -0
  210. package/dist/noise.d.ts +12 -0
  211. package/dist/objectives.d.ts +93 -0
  212. package/dist/orders/basic.d.ts +96 -0
  213. package/dist/orders/build.d.ts +91 -0
  214. package/dist/orders/cast.d.ts +105 -0
  215. package/dist/orders/facts.d.ts +14 -0
  216. package/dist/orders/harvest.d.ts +94 -0
  217. package/dist/orders/idle.d.ts +7 -0
  218. package/dist/orders/items.d.ts +14 -0
  219. package/dist/orders/queue.d.ts +24 -0
  220. package/dist/pack.schema.json +6621 -0
  221. package/dist/packs/director/index.d.ts +81 -0
  222. package/dist/packs/heroes/campaign.d.ts +137 -0
  223. package/dist/packs/heroes/carry.d.ts +59 -0
  224. package/dist/packs/heroes/commands.d.ts +6 -0
  225. package/dist/packs/heroes/hire.d.ts +9 -0
  226. package/dist/packs/heroes/index.d.ts +12 -0
  227. package/dist/packs/heroes/making.d.ts +16 -0
  228. package/dist/packs/heroes/respawn.d.ts +42 -0
  229. package/dist/packs/moba/index.d.ts +34 -0
  230. package/dist/packs/pack.d.ts +84 -0
  231. package/dist/packs-g5thvmGn.js +3199 -0
  232. package/dist/packs-g5thvmGn.js.map +1 -0
  233. package/dist/packs.d.ts +84 -0
  234. package/dist/paths.d.ts +51 -0
  235. package/dist/plain.d.ts +17 -0
  236. package/dist/player.d.ts +117 -0
  237. package/dist/portals.d.ts +66 -0
  238. package/dist/prefabs.d.ts +139 -0
  239. package/dist/presetBuildings.d.ts +52 -0
  240. package/dist/presetGround.d.ts +22 -0
  241. package/dist/profiles-B3NS9jwk.js +335 -0
  242. package/dist/profiles-B3NS9jwk.js.map +1 -0
  243. package/dist/races.d.ts +136 -0
  244. package/dist/randomGroups.d.ts +2 -0
  245. package/dist/registry.d.ts +464 -0
  246. package/dist/remains.d.ts +119 -0
  247. package/dist/replication.d.ts +103 -0
  248. package/dist/rng.d.ts +17 -0
  249. package/dist/rules.d.ts +395 -0
  250. package/dist/rulesCheck.d.ts +37 -0
  251. package/dist/runes.d.ts +41 -0
  252. package/dist/save.d.ts +277 -0
  253. package/dist/scenario.d.ts +56 -0
  254. package/dist/scheduler.d.ts +67 -0
  255. package/dist/score.d.ts +306 -0
  256. package/dist/sequences.d.ts +132 -0
  257. package/dist/server/doorman.d.ts +21 -0
  258. package/dist/server/gameServer.d.ts +346 -0
  259. package/dist/server/index.d.ts +24 -0
  260. package/dist/server/lobby.d.ts +1 -0
  261. package/dist/server/log.d.ts +13 -0
  262. package/dist/server/match.d.ts +24 -0
  263. package/dist/server/mode.d.ts +168 -0
  264. package/dist/server/navigation-worker.d.ts +1 -0
  265. package/dist/server/navigation.d.ts +11 -0
  266. package/dist/server/ops.d.ts +78 -0
  267. package/dist/server/packs.d.ts +15 -0
  268. package/dist/server/ratings.d.ts +62 -0
  269. package/dist/server/relay.d.ts +34 -0
  270. package/dist/server/rooms.d.ts +162 -0
  271. package/dist/server/seat.d.ts +2 -0
  272. package/dist/server/seatSettings.d.ts +15 -0
  273. package/dist/server/secret.d.ts +5 -0
  274. package/dist/server/start.d.ts +54 -0
  275. package/dist/server/websocket.d.ts +74 -0
  276. package/dist/server.js +2861 -0
  277. package/dist/server.js.map +1 -0
  278. package/dist/session/can.d.ts +20 -0
  279. package/dist/session/commandReplay.d.ts +92 -0
  280. package/dist/session/debug.d.ts +65 -0
  281. package/dist/session/delay.d.ts +15 -0
  282. package/dist/session/delta.d.ts +98 -0
  283. package/dist/session/entityState.d.ts +1 -0
  284. package/dist/session/local.d.ts +214 -0
  285. package/dist/session/memory.d.ts +27 -0
  286. package/dist/session/protocol.d.ts +1155 -0
  287. package/dist/session/remote.d.ts +530 -0
  288. package/dist/session/replay.d.ts +114 -0
  289. package/dist/session/seed.d.ts +7 -0
  290. package/dist/session/share.d.ts +78 -0
  291. package/dist/session/socket.d.ts +8 -0
  292. package/dist/session/wire.d.ts +153 -0
  293. package/dist/session/worker.d.ts +227 -0
  294. package/dist/shared.d.ts +171 -0
  295. package/dist/sides.d.ts +75 -0
  296. package/dist/sight.d.ts +27 -0
  297. package/dist/simulate-oXBiw1Ff.js +167 -0
  298. package/dist/simulate-oXBiw1Ff.js.map +1 -0
  299. package/dist/simulate-worker.d.ts +1 -0
  300. package/dist/simulate-worker.js +28 -0
  301. package/dist/simulate-worker.js.map +1 -0
  302. package/dist/simulate.d.ts +154 -0
  303. package/dist/smart.d.ts +9 -0
  304. package/dist/spatial.d.ts +62 -0
  305. package/dist/spawning.d.ts +33 -0
  306. package/dist/stances.d.ts +76 -0
  307. package/dist/start.d.ts +71 -0
  308. package/dist/stats.d.ts +122 -0
  309. package/dist/summons.d.ts +63 -0
  310. package/dist/systems/abilities.d.ts +3 -0
  311. package/dist/systems/combat.d.ts +71 -0
  312. package/dist/systems/combatTold.d.ts +14 -0
  313. package/dist/systems/construction.d.ts +34 -0
  314. package/dist/systems/economy.d.ts +21 -0
  315. package/dist/systems/fog.d.ts +19 -0
  316. package/dist/systems/life.d.ts +3 -0
  317. package/dist/systems/movement.d.ts +105 -0
  318. package/dist/systems/orders.d.ts +7 -0
  319. package/dist/systems/production.d.ts +49 -0
  320. package/dist/systems/productionQueue.d.ts +40 -0
  321. package/dist/systems/victory.d.ts +14 -0
  322. package/dist/talk.d.ts +65 -0
  323. package/dist/tech.d.ts +62 -0
  324. package/dist/techTree.d.ts +38 -0
  325. package/dist/terrain.d.ts +173 -0
  326. package/dist/terrainSave.d.ts +29 -0
  327. package/dist/testing.d.ts +58 -0
  328. package/dist/testing.js +822 -0
  329. package/dist/testing.js.map +1 -0
  330. package/dist/tiles.d.ts +34 -0
  331. package/dist/timers.d.ts +146 -0
  332. package/dist/tomes.d.ts +48 -0
  333. package/dist/trade.d.ts +28 -0
  334. package/dist/transport.d.ts +76 -0
  335. package/dist/tunables.d.ts +45 -0
  336. package/dist/upkeep.d.ts +16 -0
  337. package/dist/veterancy.d.ts +80 -0
  338. package/dist/walls.d.ts +86 -0
  339. package/dist/world.d.ts +1118 -0
  340. package/package.json +80 -5
  341. package/README.md +0 -3
@@ -0,0 +1,528 @@
1
+ import type { PlayerId } from '#engine/entity';
2
+ import { type Logger } from '#engine/log';
3
+ import { type AiModule, type AiModuleDef, type ModuleKey } from './module';
4
+ import type { AiArea, AreaKey, AreaMemories } from './area';
5
+ import type { Registry } from '#engine/registry';
6
+ import { Rng } from '#engine/rng';
7
+ import type { GameSession, PlayerCommand, PlayerState, SessionEvent, Snapshot } from '#engine/session/protocol';
8
+ import type { AiOptions } from './options';
9
+ import type { BrainSeat } from '#engine/computers';
10
+ import { ThinkBudget, type ThinkBudgetOptions } from './budget';
11
+ import type { ComputerPlayer } from './computer';
12
+ import { type GoalDef, Goals, type PickingOptions } from './goals';
13
+ import { Knowledge, type KnowledgeOptions } from './knowledge';
14
+ import { Plans } from './plans/plans';
15
+ import { Purse } from './plans/purse';
16
+ import { type AiProfile } from './profiles';
17
+ import { type AiDecision, type AiReport, type AiStats, Decisions } from './report';
18
+ import type { AiConditionTest, AiRule } from './rules';
19
+ import { type AiSettings } from './settings';
20
+ import { Squads } from './squads';
21
+ import type { TeamBoard } from './team';
22
+ import type { Strength, StrengthFormula } from './strength';
23
+ import type { ThreatMap } from './threat';
24
+ import { AiView } from './view';
25
+ /**
26
+ * What a computer player is made of, defined once (`defineBrain`) and seated as often as wanted
27
+ * (`world.computers.seat`). A game lists the brains it seats in `GameModule.brains`, so that a save that remembers a
28
+ * seat by its brain's id finds it again when loaded
29
+ *
30
+ * @beta
31
+ */
32
+ export interface BrainDef {
33
+ /** Unique among the brains of a game, prefixed as components are (the engine's `core.melee`, a game's `mygame.raiders`): what a save remembers a seat by */
34
+ id: string;
35
+ /** The parts of a think, in the order they run where `before` and `after` say nothing */
36
+ modules: AiModuleDef[];
37
+ /**
38
+ * Modules of the list left out, by id (`meleeBrain.with({ without: ['scouting', 'melee.heroes'] })`): a variant of a
39
+ * brain with a part fewer. A module whose id is not known before it is made (a plain function, not `defineModule`)
40
+ * cannot be left out by name
41
+ */
42
+ without?: string[];
43
+ /**
44
+ * Rules of its own (`when(…).do(…)`, B2), checked each think by its `rules()` module: the melee brain's reads them
45
+ * (`meleeBrain.with({ rules: [...] })`); a brain of one's own gives them to its `rules()` module itself. Code,
46
+ * registered again with the brain
47
+ */
48
+ rules?: AiRule[];
49
+ /**
50
+ * Seconds between thinks, where the seat's options say none (`AiOptions.every`): 1 when left out. A function of the
51
+ * seat's options, for a brain that thinks faster on a harder difficulty
52
+ */
53
+ every?: number | ((options: AiOptions) => number);
54
+ /**
55
+ * What its picture of the game carries (`ComputerSeatOptions.snapshot`): `lean` when left out, what the kit reads (the
56
+ * entities, the players, the items, the deaths, damage, healing, pings, chat and the game's own events) and none of
57
+ * what a screen needs, which is cheaper. `full` for a brain of a game's own that reads the rest (projectiles, corpses,
58
+ * reveals, the other events)
59
+ */
60
+ snapshot?: 'lean' | 'full';
61
+ /**
62
+ * How it is seated at a player (`world.computers.seat`): what `defineBrain` gives it, the seat of the engine's kit
63
+ * (`createBrainSystem`, with what the map says of the player under the options). The engine's core seats a brain
64
+ * through it, and loads nothing of the kit for it
65
+ */
66
+ seat?: BrainSeat;
67
+ /**
68
+ * How it remembers what it saw (`Brain.knowledge`): how long, how much, what counts as the enemy's army. `false` for
69
+ * a brain that remembers nothing between thinks and would rather not pay for it (a tower defense's waves)
70
+ */
71
+ knowledge?: KnowledgeOptions | false;
72
+ /**
73
+ * How strong a unit is, in place of the kit's formula (`defaultStrength`): what `odds`, the threat map and
74
+ * `UnitSet.strength()` are made of. The seat's `AiOptions.strength` goes over it; this one is code the game registers
75
+ * again, so it is there after a load
76
+ */
77
+ strength?: StrengthFormula;
78
+ /** Conditions of its own, by id, for the data form (`{ is: id, args }`): over the game's of the same id (`GameAi.conditions`) */
79
+ conditions?: Record<string, AiConditionTest>;
80
+ /**
81
+ * What it could do, scored each think and run with what each claims (`defineGoal`, `ai.goals`): picked by the
82
+ * `goals()` module in its place among the modules, or by a module of the brain's own. Code, registered again with
83
+ * the brain: there after a load, where a goal in the seat's options is not
84
+ */
85
+ goals?: GoalDef[];
86
+ /** How it picks among its goals where a goal does not say for itself: the least score, the margin, the commitment */
87
+ picking?: PickingOptions;
88
+ /**
89
+ * Its own settings (`AiSettings`, keyed by area: how it plans, how its squads go and the tasks they may be on, how it
90
+ * fights, runs its economy, defends, scouts, plays with its team, its waves): the bottom layer, under the game's
91
+ * defaults, the difficulty, the personality, the map's and the seat's (`resolveProfile`); what its modules were made
92
+ * with under all of them. Code, registered again with the brain
93
+ */
94
+ settings?: AiSettings;
95
+ /**
96
+ * This brain and more: goals, modules, rules and `without` added to its own, its settings layered over its own,
97
+ * anything else in place of its own (`meleeBrain.with({ goals: [raid] })`, `meleeBrain.with({ id: 'mygame.camp', rules, without: ['scouting'] })`).
98
+ * Given by `defineBrain`
99
+ */
100
+ with?(more: BrainExtension): BrainDef;
101
+ }
102
+ /**
103
+ * What `BrainDef.with` adds to a brain: goals, modules, rules and modules left out beside its own, settings over its
104
+ * own, the rest in place of its own
105
+ *
106
+ * @beta
107
+ */
108
+ export type BrainExtension = Partial<Omit<BrainDef, 'with'>>;
109
+ /**
110
+ * A word the game told a computer player (`world.computers.tell`), waiting for a module to take it
111
+ *
112
+ * @beta
113
+ */
114
+ export interface Told {
115
+ /** The word: what the game and the brain agreed on (`'raid'`) */
116
+ word: string;
117
+ /** What came with it: plain data */
118
+ data?: unknown;
119
+ /** The tick it was told at */
120
+ tick: number;
121
+ }
122
+ /**
123
+ * What a brain remembers between thinks, as a save keeps it: its own numbers, each module's memory with its version,
124
+ * the words it was told and not yet taken
125
+ *
126
+ * @beta
127
+ */
128
+ export interface BrainMemory {
129
+ /** The version of this shape */
130
+ v: 2;
131
+ /** Where the brain's own numbers are in their sequence (`Rng.save`) */
132
+ rng: number;
133
+ /** How many times it has thought: what `AiModule.everyThinks` counts in */
134
+ thinks: number;
135
+ /** Whether it sits still (`world.computers.pause`) */
136
+ paused?: boolean;
137
+ /** The words it was told and no module has taken yet */
138
+ told: Told[];
139
+ /** What each module remembers, under its id, with the version it was saved as */
140
+ modules: Record<string, {
141
+ v: number;
142
+ data: unknown;
143
+ }>;
144
+ /**
145
+ * What each of its areas remembers, by the area's id (`AiArea`): its knowledge, goals, plans and squads, its economy,
146
+ * scouting and the rest of the kit's, a game's own. Left out by an area with nothing to remember
147
+ */
148
+ areas?: AreaMemories;
149
+ /** What it decided last (`Brain.decisions`): the last fifty lines, for whoever reads a save */
150
+ decisions?: AiDecision[];
151
+ /**
152
+ * The orders it sent lately (`Brain.sentTo`), by unit: what keeps it from telling a unit again what it is doing, in a
153
+ * game loaded from the save too. Left out while there are none
154
+ */
155
+ orders?: {
156
+ unit: number;
157
+ key: string;
158
+ tick: number;
159
+ }[];
160
+ /**
161
+ * What its seat heard since it last thought (`GameSession.pendingEvents`): the damage, deaths and pings its next think
162
+ * reads, which a game loaded from the save would not have heard otherwise
163
+ */
164
+ heard?: SessionEvent[];
165
+ /**
166
+ * A think under way across ticks as the game was saved (`BrainContext.budget`): the rest of this memory is the brain
167
+ * as that think began, and this is how far it had got, over what picture: each pass run so far, as the module (its
168
+ * index), the units the tick had looked at before it (`ThinkBudget.units`) and how many words it had been told by then
169
+ * (`told`). A game loaded from the save runs the
170
+ * same passes again under the same budget over the same picture, sending nothing (their commands are in the game
171
+ * already), and goes on from there as the saved game did. `slice` is the form before passes: so many modules run once each
172
+ */
173
+ thinking?: {
174
+ snapshot: Snapshot;
175
+ passes?: [module: number, units: number, heard: number][];
176
+ slice?: number;
177
+ };
178
+ }
179
+ /**
180
+ * What follows a brain's play from outside it (`Brain.watch`): the commands it sends, its thinks as each ends, what it
181
+ * decides. For tests and tools (`watchComputer`, `recordDecisions`, the invariants of `ai/checks.ts`): a watcher reads,
182
+ * it never changes what the brain does
183
+ *
184
+ * @beta
185
+ */
186
+ export interface BrainWatcher {
187
+ /** A command it sent, as it goes (`Brain.send`): not one held back past its profile's cap */
188
+ sent?(command: PlayerCommand, brain: Brain): void;
189
+ /** A think ended, all its ticks where it was sliced: the picture it read is still `brain.view` */
190
+ thought?(brain: Brain): void;
191
+ /** It wrote a decision down (`Brain.decide`) */
192
+ decided?(decision: AiDecision, brain: Brain): void;
193
+ }
194
+ /**
195
+ * What a seat hands a brain as it is made, besides its session and its options (`createComputerSystem`'s `make`)
196
+ *
197
+ * @beta
198
+ */
199
+ export interface BrainContext {
200
+ /** What the brain's own numbers start from: the world's seed and the player, as the seat works it out */
201
+ seed?: number;
202
+ /**
203
+ * How much of a think one tick may do (`ThinkBudgetOptions`: modules a tick, units looked at a tick, the milliseconds a
204
+ * module is warned over), or the modules a tick as a number. A think with more goes on at the next tick, over the same
205
+ * picture of the game, so that no tick does all of it. Everything in one tick when left out
206
+ */
207
+ budget?: number | ThinkBudgetOptions;
208
+ /** Whether to time each module this think: on while the world's scheduler profiles. Timing never decides anything */
209
+ profiling?: () => boolean;
210
+ /**
211
+ * The board of its team (`TeamBoard`), shared by the computers of one team and kept by the world (`core.ai.teams`):
212
+ * read anew each time, for a load replaces it. A brain with none plays alone
213
+ */
214
+ team?: () => TeamBoard;
215
+ /**
216
+ * Whether every think is checked against the invariants (`checkBrain`): its world's (`world.checks.ai`), as its seat
217
+ * says. The process's (`debugChecks.ai`) for a brain made by hand
218
+ */
219
+ checks?: boolean;
220
+ }
221
+ /**
222
+ * A computer player made of modules (`defineBrain`), seated at a world (`world.computers.seat`). What
223
+ * a module is handed as it thinks (`ai`): the picture of the game (`snapshot`), the seat it plays through (`session`),
224
+ * its options, its numbers (`rng`), its log, and `send` for its commands. A brain is a `ComputerPlayer`: `think`, and
225
+ * `save` and `restore` for what it remembers
226
+ *
227
+ * @beta
228
+ */
229
+ export declare class Brain implements ComputerPlayer {
230
+ /** What it was made from */
231
+ readonly def: BrainDef;
232
+ /** The seat it plays through: the snapshots it sees, the commands it sends */
233
+ readonly session: GameSession;
234
+ /** What it was seated with: a brain's own options read theirs from it */
235
+ readonly options: AiOptions;
236
+ /** Its modules, in the order they run */
237
+ readonly modules: readonly AiModule[];
238
+ /**
239
+ * Its own numbers, for whatever it leaves to chance (which base to scout first): seeded from the world's and the
240
+ * player's, kept in its memory, so that the same game plays the same way. Never `Math.random`
241
+ */
242
+ readonly rng: Rng;
243
+ /** Where it says what it does: the world's log, with the player it plays and its brain on each line */
244
+ readonly log: Logger;
245
+ /** Whether it sits still (`world.computers.pause`). Kept in a save */
246
+ paused: boolean;
247
+ /**
248
+ * What it sees, as of its last think: the snapshot of its seat, plain data, and the only input a brain has. Taken once
249
+ * a think: every module of the think reads the same picture
250
+ */
251
+ snapshot: Snapshot;
252
+ /**
253
+ * Its reading of the picture (`AiView`): the snapshot indexed once a think and asked as sets (`view.mine.idle()`,
254
+ * `view.enemies.near(home, 20)`), with what unit types are for (`view.roles`) and the map's facts. What a module
255
+ * reads the game through
256
+ */
257
+ view: AiView;
258
+ /**
259
+ * What it remembers of the enemy, the map and itself, with when (`Knowledge`): their bases and army as last seen,
260
+ * when each place was last looked at, its own losses and income. Brought up to date as each think begins, after the
261
+ * view; kept in a save
262
+ */
263
+ readonly knowledge: Knowledge;
264
+ /**
265
+ * What it could do (`Goals`): its goals scored each think from their considerations, the best given what they
266
+ * claim of its units and money, each run while it holds its claim. Its definition's goals and the seat's; a module
267
+ * adds its own (`ai.goals.add`). Picked by the `goals()` module, or by one of the brain's own in its place
268
+ */
269
+ readonly goals: Goals;
270
+ /**
271
+ * What it has to spend this think (`Purse`): its resources less what builders on their way will pay and what is
272
+ * held (a goal's money claim, a want saving up), rebuilt from the picture as each think begins. The one ledger:
273
+ * everything that spends, spends through it. `view.me.purse` is what is free
274
+ */
275
+ readonly purse: Purse;
276
+ /**
277
+ * Its plans (`Plans`): the build plan (`plans.build`: wants, the steps to each through the tech tree, spots,
278
+ * builders, saving up), the production plan (`plans.production`: the composition, counters, supply ahead,
279
+ * research), the game's build order over both, and `plans.want` to add to them. Run by the `build()` and
280
+ * `production()` modules, or by one of the brain's own
281
+ */
282
+ readonly plans: Plans;
283
+ /**
284
+ * Its squads (`Squads`): named groups of its units, each with a task (attack there, defend here, gather and go), made
285
+ * by its goals, rules and modules out of what they hold, and watched by the `squads()` module think after think:
286
+ * orders sent once and watched, regroups, retreats on the odds, reinforcements. Kept in a save
287
+ */
288
+ readonly squads: Squads;
289
+ /**
290
+ * How it plays (`AiProfile`), resolved (`resolveProfile`): how well it plays (the engine's, the game's, the
291
+ * difficulty's, the personality's, the seat's `every` and `budget`) and its settings, the brain's, the game's, the
292
+ * difficulty's, the personality's, the map's and the seat's each over the one before (a flag's function left out)
293
+ */
294
+ readonly profile: AiProfile;
295
+ /** Its settings' layers, lowest first (`ResolvedProfile.layers`): what `settings` is worked out from */
296
+ private readonly layers;
297
+ /** How many times it has thought */
298
+ thinks: number;
299
+ /**
300
+ * What it decided, the last fifty (`decide`): the goals picked and stopped, with the reason that weighed most, and
301
+ * what its modules write down. Kept in a save
302
+ */
303
+ readonly decisions: Decisions;
304
+ /** The board of its team, shared by its team's computers: what its seat was given (`BrainContext.team`), for its team play */
305
+ readonly teamBoard: BrainContext['team'];
306
+ /** Its areas, in the order they were made (`area`) */
307
+ private readonly areaList;
308
+ /** What a save remembered of areas not made yet, by id: taken by each as a module first asks for it */
309
+ private waiting;
310
+ /** What was worked out for this think, by key (`cache`): thrown away with the picture */
311
+ private readonly memo;
312
+ /**
313
+ * How strong things are (`Strength`): a unit, a group, one force against another (`odds`), what answers what
314
+ * (`counterFor`). The view's: the kit's formula unless the brain or the seat was given one
315
+ */
316
+ get strength(): Strength;
317
+ /**
318
+ * Where the strength is (`ThreatMap`): the friendly and the enemy strength that reaches each cell of a coarse grid
319
+ * over the map, by layer. Made from the think's picture when first asked; `threat.at(undefined)` is all zeros
320
+ */
321
+ get threat(): ThreatMap;
322
+ /** Commands it sent this think */
323
+ sent: number;
324
+ /** Commands it would have sent this think past what its profile lets a think send (`commandsPerThink`): not sent */
325
+ held: number;
326
+ /**
327
+ * What its play adds up to since it was seated (`AiStats`): commands sent, held and refused, seconds its fighters
328
+ * stood idle, orders sent again for the same thing, seconds its building waited on money. For the report and
329
+ * `simulate`, never for a decision; not kept in a save
330
+ */
331
+ readonly stats: AiStats;
332
+ /** The tick of the think before, for what is counted by the seconds between thinks */
333
+ private lastThink;
334
+ /** The last order each unit was sent, with the tick: what an order sent again for the same thing is counted against (`AiStats.churn`) */
335
+ private readonly lastOrders;
336
+ /**
337
+ * How much of a think one tick may do (`ThinkBudget`): so many modules, so many units looked at as the modules say
338
+ * (`budget.spent(n)`), the think going on at the next tick from where it stopped (`budget.later()`). Counted in work,
339
+ * never in milliseconds, so that the game is the same on every machine. What the seat was given (`BrainContext.budget`)
340
+ */
341
+ readonly budget: ThinkBudget;
342
+ /** Milliseconds each module took, averaged over thinks, by id: while the world profiles (`BrainContext.profiling`) */
343
+ readonly moduleTiming: Record<string, number>;
344
+ /** The most milliseconds each module took in one pass, by id: always, as the warning (`ThinkBudgetOptions.warnAfterMs`) is */
345
+ readonly moduleLongest: Record<string, number>;
346
+ /** Milliseconds taking the picture of the game took (the seat's `snapshot()`), averaged: while the world profiles */
347
+ snapshotTiming: number | undefined;
348
+ /** Milliseconds reading the picture into the view took (`AiView`, the ledger with it), averaged: while the world profiles */
349
+ viewTiming: number | undefined;
350
+ /** Milliseconds bringing the knowledge up to date took, averaged: while the world profiles */
351
+ knowledgeTiming: number | undefined;
352
+ /** Ticks the last think took, all its passes: 1 unless its budget sliced it */
353
+ thinkTicks: number;
354
+ /** Ticks of the think under way so far */
355
+ private ticksSoFar;
356
+ /** The modules the log has warned of taking over `warnAfterMs`, once each */
357
+ private readonly warned;
358
+ /**
359
+ * The passes of the think under way: each module run, with the units the tick had looked at before it. What a save in
360
+ * the middle of the think keeps (`BrainMemory.thinking`), kept only where the budget may slice
361
+ */
362
+ private passes;
363
+ private heard;
364
+ /** Who follows its play from outside (`watch`): none in a game, so nothing is paid for it there */
365
+ private watchers;
366
+ /** The module a think under way goes on from, at the next tick: none between thinks (`budget`) */
367
+ private slice;
368
+ /**
369
+ * What it remembered as the think under way began, for a think sliced across ticks: what a save taken before the
370
+ * think ends keeps, with how far it got (`BrainMemory.thinking`)
371
+ */
372
+ private began;
373
+ /** The words told it since the think under way began: a save taken before it ends keeps them beside what it began with */
374
+ private toldDuring;
375
+ /** A think a save was taken in the middle of: run again to where it was, then on, at the next tick (`restore`) */
376
+ private resume;
377
+ /** While the modules a loaded game had run already are run again: nothing is sent, said or watched */
378
+ private replaying;
379
+ /** While a pass is run again: how many of the words it was told the pass had heard then, the rest told it after */
380
+ private replayHeard;
381
+ private readonly profiling;
382
+ constructor(
383
+ /** What it was made from */
384
+ def: BrainDef,
385
+ /** The seat it plays through: the snapshots it sees, the commands it sends */
386
+ session: GameSession,
387
+ /** What it was seated with: a brain's own options read theirs from it */
388
+ options: AiOptions, context?: BrainContext);
389
+ /**
390
+ * An area of its (`AiArea`): its economy (`ai.area(Economy)`), its scouting, a game's own (`defineArea`), made the
391
+ * first time it is asked for, with what a save remembered of it. What its modules share beyond what every module
392
+ * does (`knowledge`, `goals`, `plans`, `squads`, `purse`)
393
+ */
394
+ area<T extends AiArea>(key: AreaKey<T>): T;
395
+ /**
396
+ * An area made already, by id: none where no module has asked for it. For a part of the kit that reads another's
397
+ * area where there is one and needs nothing of it where there is none (whether a squad's fights are the micro's)
398
+ */
399
+ made<T extends AiArea>(id: string): T | undefined;
400
+ /** Its areas, in the order they were made: what its memory and its report are made of */
401
+ areas(): readonly AiArea[];
402
+ /** Puts an area among its own, with what a save remembered of it */
403
+ private register;
404
+ /**
405
+ * Follows its play from outside (`BrainWatcher`): the commands it sends, its thinks as each ends, what it decides.
406
+ * Returns the way to stop. What `watchComputer` and `recordDecisions` of `@v12-engine/engine/testing` stand on
407
+ */
408
+ watch(watcher: BrainWatcher): () => void;
409
+ /** The player it plays */
410
+ get playerId(): PlayerId;
411
+ /** The game's definitions, as the seat has them */
412
+ get registry(): Registry;
413
+ /** The tick of its picture of the game */
414
+ get tick(): number;
415
+ /** Seconds into the game, as of its picture of it */
416
+ get time(): number;
417
+ /** The player it plays, as its picture shows them: resources, supply, tech (`own`). Nothing once out of the game. `view.me` is the same, never nothing */
418
+ get me(): PlayerState | undefined;
419
+ /** A module of its, by key with its shape (`MELEE_ARMY`, `moduleKey`), or by id */
420
+ module<M extends AiModule>(key: ModuleKey<M>): M | undefined;
421
+ module(id: string): AiModule | undefined;
422
+ /**
423
+ * What its areas play by this think (`AiSettings`): its settings' layers worked out, a flag that is a function of the
424
+ * brain asked now. Each area reads its own (`ai.settings.economy`), over what its module was made with
425
+ */
426
+ get settings(): AiSettings;
427
+ /**
428
+ * What was worked out once for this think, by key: a consideration asked by several goals, a set a few modules
429
+ * read (`ai.cache('intruders', () => ...)`). Thrown away as the next think takes its picture
430
+ */
431
+ cache<T>(key: string, compute: () => T): T;
432
+ /** Whether a think is under way across ticks (`budget`): the seat asks it to think on at the next tick */
433
+ get busy(): boolean;
434
+ /**
435
+ * One think, or one tick of it. A new picture of the game is taken, and the modules run over it in their order, as
436
+ * many a tick as the budget allows (`budget`): so many modules, so many units looked at as they say. A module's error
437
+ * is the seat's to catch, as a system's is
438
+ */
439
+ think(): void;
440
+ /**
441
+ * One pass of a module: run once, timed, and the think moved on past it, unless it stopped for the tick with more to
442
+ * do (`budget.later()`), in which case it is where the think goes on at the next tick. Gives whether the think may go
443
+ * on this tick
444
+ */
445
+ private pass;
446
+ /** Seconds between the think before and this one's picture: 0 for the first think */
447
+ private sinceLastThink;
448
+ /**
449
+ * Counts, as a think begins, what its play adds up to (`stats`): the fighters that stood idle since the last think,
450
+ * the commands the game refused since, and the orders it no longer needs to remember for the churn
451
+ */
452
+ private count;
453
+ /**
454
+ * Sends a command, as the player would: counted (`sent`), carried out at the next tick. Returns the command's number;
455
+ * -1 for one past what its profile lets a think send (`commandsPerThink`, a person's hands), which is not sent
456
+ */
457
+ send(command: PlayerCommand): number;
458
+ /**
459
+ * Counts an order sent to a unit for the same thing as its last within a few seconds (`AiStats.churn`): a unit told
460
+ * to attack-move there every think never arrives, it stops and starts. The squads send an order once and watch it;
461
+ * this is how a test or `simulate` sees that they do
462
+ */
463
+ private churn;
464
+ /**
465
+ * The last order it sent a unit lately (within a few seconds), as a key (`orderKey`: its kind, its target, its
466
+ * place to the cell) with the tick: what keeps a module from telling a unit again what it is already doing, when the
467
+ * unit changed hands (a squad of another goal) since. None for a unit told nothing lately
468
+ */
469
+ sentTo(unit: number): {
470
+ key: string;
471
+ tick: number;
472
+ } | undefined;
473
+ /**
474
+ * The words the game told it and no module has taken yet (`world.computers.tell`), oldest first; those of one word
475
+ * where given. Reading them takes nothing: `takeTold` does, as a told rule (`when.told`) does when it fires
476
+ */
477
+ told(word?: string): readonly Told[];
478
+ /**
479
+ * Writes down a decision (`decisions`), with the reason that weighed most, in words: what the report's log and the
480
+ * debug panel show, and the world's log at its `debug` level. `kind` says what it is about (`army`, `build`)
481
+ */
482
+ decide(line: string, about?: {
483
+ kind?: string;
484
+ goal?: string;
485
+ }): void;
486
+ /**
487
+ * What it is thinking, as plain data (`AiReport`): its goals with their considerations, what it knows, its roles,
488
+ * its economy, what it was told, what it decided, and each module's section. Made when asked: nothing in a think
489
+ * waits for it. What `inspect` gives, and the debug panel's AI tab draws
490
+ */
491
+ report(): AiReport;
492
+ /**
493
+ * A goal's row of the report as a sentence: what it scored and why, whether it runs and with what, or what kept it
494
+ * from running. Nothing for a goal the brain does not have
495
+ */
496
+ explain(goal: string): string | undefined;
497
+ /** Takes in a word from the game: a module takes it with `takeTold`. What the seat calls for `world.computers.tell` */
498
+ tell(word: string, data: unknown, tick: number): void;
499
+ /** Takes the words of one kind out of what it was told, oldest first, as many as `count` (all when left out): they are heard no more */
500
+ takeTold(word: string, count?: number): Told[];
501
+ /**
502
+ * What it remembers, for a save: its numbers, each module's memory with its version, what it was told. A think under
503
+ * way (`budget`) is kept as it began, with how far it got and its picture (`BrainMemory.thinking`): the game loaded
504
+ * from the save runs it on to its end as the saved game does
505
+ */
506
+ save(): BrainMemory;
507
+ /** What its areas remember, by id: those that remember anything, and what a save had of areas not made since */
508
+ private areaMemories;
509
+ /** What it remembers, but what its seat heard since it last thought */
510
+ private memory;
511
+ /**
512
+ * Takes back what `save` gave. A module's memory of another version goes through its `migrate`; without one, or with
513
+ * nothing in the save for it, the module starts afresh, and the log says so once. Memory of a module the brain no
514
+ * longer has is dropped, said too
515
+ */
516
+ restore(memory: BrainMemory): void;
517
+ /** What it is thinking, for the debug tools: its report (`report`) */
518
+ inspect(): AiReport;
519
+ /** Lets its modules go of what they hold outside the brain */
520
+ dispose(): void;
521
+ }
522
+ /**
523
+ * Makes a brain from its definition for a seat: the session it plays through, the options it is seated with. What
524
+ * a brain's seat does (`createBrainSystem`); for a seat made another way (`createComputerSystem`'s `make`)
525
+ *
526
+ * @beta
527
+ */
528
+ export declare function createBrain(def: BrainDef, session: GameSession, options: AiOptions, context?: BrainContext): Brain;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * How much of a think one tick may do (`AiOptions.budget`, `AiProfile.budget`, `ComputerSeatOptions.budget`), counted in
3
+ * work and never in milliseconds: the same on every machine, so that a game with a sliced think is the same game
4
+ * everywhere. Nothing is limited where a field is left out
5
+ *
6
+ * @beta
7
+ */
8
+ export interface ThinkBudgetOptions {
9
+ /**
10
+ * Modules of a brain a think may run in one tick: a think with more goes on at the next tick, over the same picture of
11
+ * the game. All of them in one tick when left out
12
+ */
13
+ modulesPerTick?: number;
14
+ /**
15
+ * Units a tick's modules may look at, as the modules say (`ai.budget.spent(n)`): a module that walks the squads or the
16
+ * bases stops once the tick has looked at this many, and goes on at the next tick from where it was (`later`). No
17
+ * limit when left out. A module that says nothing of what it looks at is never stopped by it
18
+ */
19
+ unitsPerTick?: number;
20
+ /**
21
+ * Milliseconds a module may take before the log says so (once a module, a warning): what to measure first. A module
22
+ * is never cut short for it. 4 when left out; `false` for never
23
+ */
24
+ warnAfterMs?: number | false;
25
+ }
26
+ /**
27
+ * The budget of the think under way, as a module reads it (`ai.budget`): what this tick may still do, and the way to say
28
+ * what was looked at (`spent`) and to go on at the next tick (`later`). A module that walks units looks at them a few at
29
+ * a time:
30
+ *
31
+ * for (; this.cursor < squads.length; this.cursor++) {
32
+ * look(squads[this.cursor])
33
+ * if (!ai.budget.spent(squads[this.cursor].size) && this.cursor + 1 < squads.length) return ai.budget.later()
34
+ * }
35
+ *
36
+ * @beta
37
+ */
38
+ export declare class ThinkBudget {
39
+ /** Modules a tick may run: `Infinity` where unlimited */
40
+ readonly modulesPerTick: number;
41
+ /** Units a tick's modules may look at, as they say: `Infinity` where unlimited */
42
+ readonly unitsPerTick: number;
43
+ /** Milliseconds a module may take before the log says so: none for never */
44
+ readonly warnAfterMs: number | undefined;
45
+ /** Units looked at this tick, as the modules said (`spent`) */
46
+ units: number;
47
+ /** Whether the module running asked to go on at the next tick (`later`) */
48
+ deferred: boolean;
49
+ constructor(options?: number | ThinkBudgetOptions);
50
+ /** Whether the budget may slice a think over ticks at all: one that limits nothing never does, and nothing is kept for it */
51
+ get slices(): boolean;
52
+ /** Whether this tick may look at more: a module that walks units stops where it may not, and says `later` */
53
+ get room(): boolean;
54
+ /**
55
+ * Says the module looked at so many units (one when left out). Gives whether this tick may look at more: where it may
56
+ * not, a module with more to do remembers where it was and says `later`
57
+ */
58
+ spent(units?: number): boolean;
59
+ /**
60
+ * The module running stops here for this tick and is run again at the next, going on from where it remembers it was,
61
+ * over the same picture. Honoured where the module looked at something this tick (`spent`): one that looked at
62
+ * nothing and asks to go on would never end, so it is taken to be done, and the log says so
63
+ */
64
+ later(): void;
65
+ /** The budget as the report shows it: the limits, where there are any */
66
+ report(): ThinkBudgetOptions | undefined;
67
+ }