@v12-engine/engine 0.0.0-stage → 0.1.1
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.
- package/LICENSE +21 -0
- package/dist/abilities/buffs.d.ts +83 -0
- package/dist/abilities/castTold.d.ts +12 -0
- package/dist/abilities/charges.d.ts +28 -0
- package/dist/abilities/dispel.d.ts +9 -0
- package/dist/abilities/effectFields.d.ts +10 -0
- package/dist/abilities/effects/buff.d.ts +8 -0
- package/dist/abilities/effects/core.d.ts +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -0
- package/dist/abilities/effects/missile.d.ts +1 -0
- package/dist/abilities/effects/moves.d.ts +11 -0
- package/dist/abilities/effects/passives.d.ts +15 -0
- package/dist/abilities/effects/sight.d.ts +4 -0
- package/dist/abilities/effects/spawn.d.ts +2 -0
- package/dist/abilities/effects/timed.d.ts +4 -0
- package/dist/abilities/effects/trade.d.ts +1 -0
- package/dist/abilities/effects.d.ts +122 -0
- package/dist/abilities/land.d.ts +21 -0
- package/dist/abilities/scaled.d.ts +21 -0
- package/dist/abilities/text.d.ts +113 -0
- package/dist/ai/area.d.ts +53 -0
- package/dist/ai/brain.d.ts +528 -0
- package/dist/ai/budget.d.ts +67 -0
- package/dist/ai/checks.d.ts +115 -0
- package/dist/ai/computer.d.ts +166 -0
- package/dist/ai/defence.d.ts +108 -0
- package/dist/ai/define.d.ts +21 -0
- package/dist/ai/economy.d.ts +129 -0
- package/dist/ai/geometry.d.ts +35 -0
- package/dist/ai/goals.d.ts +360 -0
- package/dist/ai/index.d.ts +38 -0
- package/dist/ai/knowledge.d.ts +418 -0
- package/dist/ai/lanes.d.ts +232 -0
- package/dist/ai/melee/build.d.ts +61 -0
- package/dist/ai/melee/goals.d.ts +299 -0
- package/dist/ai/melee/heroes.d.ts +27 -0
- package/dist/ai/melee/index.d.ts +14 -0
- package/dist/ai/melee/production.d.ts +8 -0
- package/dist/ai/melee/surrender.d.ts +24 -0
- package/dist/ai/micro.d.ts +278 -0
- package/dist/ai/mission.d.ts +195 -0
- package/dist/ai/missionRules.d.ts +18 -0
- package/dist/ai/module.d.ts +116 -0
- package/dist/ai/options.d.ts +61 -0
- package/dist/ai/plans/build.d.ts +280 -0
- package/dist/ai/plans/placement.d.ts +82 -0
- package/dist/ai/plans/plans.d.ts +105 -0
- package/dist/ai/plans/production.d.ts +210 -0
- package/dist/ai/plans/purse.d.ts +73 -0
- package/dist/ai/plans/tech.d.ts +37 -0
- package/dist/ai/profiles.d.ts +204 -0
- package/dist/ai/reach.d.ts +4 -0
- package/dist/ai/report.d.ts +203 -0
- package/dist/ai/roles.d.ts +133 -0
- package/dist/ai/rules.d.ts +288 -0
- package/dist/ai/scouting.d.ts +98 -0
- package/dist/ai/settings.d.ts +73 -0
- package/dist/ai/squads.d.ts +429 -0
- package/dist/ai/strength.d.ts +167 -0
- package/dist/ai/task.d.ts +118 -0
- package/dist/ai/tasks/attack.d.ts +7 -0
- package/dist/ai/tasks/capture.d.ts +21 -0
- package/dist/ai/tasks/creep.d.ts +16 -0
- package/dist/ai/tasks/defend.d.ts +29 -0
- package/dist/ai/tasks/drop.d.ts +34 -0
- package/dist/ai/tasks/escort.d.ts +16 -0
- package/dist/ai/tasks/gather.d.ts +23 -0
- package/dist/ai/tasks/harass.d.ts +7 -0
- package/dist/ai/tasks/hold.d.ts +20 -0
- package/dist/ai/tasks/index.d.ts +32 -0
- package/dist/ai/tasks/move.d.ts +19 -0
- package/dist/ai/tasks/patrol.d.ts +8 -0
- package/dist/ai/tasks/retreat.d.ts +20 -0
- package/dist/ai/tasks/scout.d.ts +29 -0
- package/dist/ai/tasks/shared.d.ts +74 -0
- package/dist/ai/team.d.ts +155 -0
- package/dist/ai/threat.d.ts +91 -0
- package/dist/ai/view.d.ts +366 -0
- package/dist/ai/waves.d.ts +126 -0
- package/dist/ai.js +6239 -0
- package/dist/ai.js.map +1 -0
- package/dist/aiTesting.d.ts +179 -0
- package/dist/areas.d.ts +149 -0
- package/dist/attacks.d.ts +66 -0
- package/dist/attributes.d.ts +66 -0
- package/dist/brain-BvVdUhX8.js +7659 -0
- package/dist/brain-BvVdUhX8.js.map +1 -0
- package/dist/builds-C6LfgvEU.js +460 -0
- package/dist/builds-C6LfgvEU.js.map +1 -0
- package/dist/bytes.d.ts +6 -0
- package/dist/camps.d.ts +95 -0
- package/dist/capture.d.ts +131 -0
- package/dist/cellLayers.d.ts +75 -0
- package/dist/cinematics.d.ts +194 -0
- package/dist/clock.d.ts +32 -0
- package/dist/commands.d.ts +235 -0
- package/dist/components.d.ts +184 -0
- package/dist/computers.d.ts +108 -0
- package/dist/concealment.d.ts +61 -0
- package/dist/coreComponents-syuh2fPG.js +5149 -0
- package/dist/coreComponents-syuh2fPG.js.map +1 -0
- package/dist/coreComponents.d.ts +1 -0
- package/dist/dashing.d.ts +8 -0
- package/dist/debug.d.ts +36 -0
- package/dist/debug.js +3 -0
- package/dist/debugCommands-CzjrSm66.js +14739 -0
- package/dist/debugCommands-CzjrSm66.js.map +1 -0
- package/dist/debugCommands.d.ts +213 -0
- package/dist/debugging.d.ts +10 -0
- package/dist/definitions.d.ts +43 -0
- package/dist/defs.d.ts +1162 -0
- package/dist/denying.d.ts +81 -0
- package/dist/destructibles.d.ts +27 -0
- package/dist/determinism-BCymQwiE.js +518 -0
- package/dist/determinism-BCymQwiE.js.map +1 -0
- package/dist/determinism.d.ts +121 -0
- package/dist/dialog.d.ts +94 -0
- package/dist/effectRefs.d.ts +16 -0
- package/dist/effects.d.ts +80 -0
- package/dist/endings.d.ts +22 -0
- package/dist/engagement.d.ts +108 -0
- package/dist/engineEvents.d.ts +710 -0
- package/dist/entity.d.ts +409 -0
- package/dist/entityIndex.d.ts +50 -0
- package/dist/errors.d.ts +85 -0
- package/dist/events.d.ts +97 -0
- package/dist/exactMath.d.ts +63 -0
- package/dist/features.d.ts +10 -0
- package/dist/fields.d.ts +114 -0
- package/dist/fixture.d.ts +17 -0
- package/dist/fog.d.ts +110 -0
- package/dist/formation.d.ts +111 -0
- package/dist/friendlyFire.d.ts +26 -0
- package/dist/game-DiJEN-Ks.js +5800 -0
- package/dist/game-DiJEN-Ks.js.map +1 -0
- package/dist/game.d.ts +501 -0
- package/dist/gameData.d.ts +325 -0
- package/dist/gameFiles.d.ts +26 -0
- package/dist/gates.d.ts +28 -0
- package/dist/generate.d.ts +403 -0
- package/dist/generateWorker.d.ts +39 -0
- package/dist/grid.d.ts +53 -0
- package/dist/ground.d.ts +127 -0
- package/dist/groundSpeed.d.ts +22 -0
- package/dist/hero.d.ts +177 -0
- package/dist/home.d.ts +14 -0
- package/dist/hooks.d.ts +780 -0
- package/dist/hotReload.d.ts +76 -0
- package/dist/ids.d.ts +26 -0
- package/dist/index.d.ts +227 -0
- package/dist/index.js +4701 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect-D9dWHmZ0.js +491 -0
- package/dist/inspect-D9dWHmZ0.js.map +1 -0
- package/dist/inspect.d.ts +176 -0
- package/dist/inventory.d.ts +18 -0
- package/dist/items.d.ts +91 -0
- package/dist/lanes.d.ts +213 -0
- package/dist/life.d.ts +53 -0
- package/dist/local-Dkovq42k.js +1379 -0
- package/dist/local-Dkovq42k.js.map +1 -0
- package/dist/log.d.ts +140 -0
- package/dist/manaBurn.d.ts +39 -0
- package/dist/map/file.d.ts +114 -0
- package/dist/map/images.d.ts +18 -0
- package/dist/map/look.d.ts +47 -0
- package/dist/map/pathProfile.d.ts +13 -0
- package/dist/map/resize.d.ts +54 -0
- package/dist/map/schema.d.ts +10 -0
- package/dist/map/terrain.d.ts +32 -0
- package/dist/map/types.d.ts +613 -0
- package/dist/map.d.ts +7 -0
- package/dist/mapCheck/cells.d.ts +19 -0
- package/dist/mapCheck/rule.d.ts +30 -0
- package/dist/mapCheck/rules/names.d.ts +3 -0
- package/dist/mapCheck/rules/objects.d.ts +3 -0
- package/dist/mapCheck/rules/paths.d.ts +3 -0
- package/dist/mapCheck/rules/players.d.ts +3 -0
- package/dist/mapCheck/rules/races.d.ts +3 -0
- package/dist/mapCheck/rules/random.d.ts +3 -0
- package/dist/mapCheck/rules/regions.d.ts +3 -0
- package/dist/mapCheck/rules/targets.d.ts +3 -0
- package/dist/mapCheck/rules/walking.d.ts +3 -0
- package/dist/mapCheck.d.ts +23 -0
- package/dist/mapFields.d.ts +364 -0
- package/dist/mapFile.d.ts +23 -0
- package/dist/mapMeasure.d.ts +95 -0
- package/dist/mapMerge.d.ts +19 -0
- package/dist/mapObjectives.d.ts +82 -0
- package/dist/mapObjects.d.ts +1 -0
- package/dist/math.d.ts +44 -0
- package/dist/messages.d.ts +150 -0
- package/dist/missionRules-C-bGxm0Q.js +523 -0
- package/dist/missionRules-C-bGxm0Q.js.map +1 -0
- package/dist/missionRules.d.ts +179 -0
- package/dist/mods.d.ts +146 -0
- package/dist/names.d.ts +93 -0
- package/dist/navigation/agentParams.d.ts +4 -0
- package/dist/navigation/air.d.ts +89 -0
- package/dist/navigation/builds.d.ts +140 -0
- package/dist/navigation/groundAreas.d.ts +23 -0
- package/dist/navigation/navigation.d.ts +127 -0
- package/dist/navigation/recast.d.ts +214 -0
- package/dist/navigation/sidePaths.d.ts +69 -0
- package/dist/navigation/sized.d.ts +1 -0
- package/dist/navigation-worker.js +11 -0
- package/dist/navigation-worker.js.map +1 -0
- package/dist/nearest.d.ts +8 -0
- package/dist/noise.d.ts +12 -0
- package/dist/objectives.d.ts +93 -0
- package/dist/orders/basic.d.ts +96 -0
- package/dist/orders/build.d.ts +91 -0
- package/dist/orders/cast.d.ts +105 -0
- package/dist/orders/facts.d.ts +14 -0
- package/dist/orders/harvest.d.ts +94 -0
- package/dist/orders/idle.d.ts +7 -0
- package/dist/orders/items.d.ts +14 -0
- package/dist/orders/queue.d.ts +24 -0
- package/dist/pack.schema.json +6621 -0
- package/dist/packs/director/index.d.ts +81 -0
- package/dist/packs/heroes/campaign.d.ts +137 -0
- package/dist/packs/heroes/carry.d.ts +59 -0
- package/dist/packs/heroes/commands.d.ts +6 -0
- package/dist/packs/heroes/hire.d.ts +9 -0
- package/dist/packs/heroes/index.d.ts +12 -0
- package/dist/packs/heroes/making.d.ts +16 -0
- package/dist/packs/heroes/respawn.d.ts +42 -0
- package/dist/packs/moba/index.d.ts +34 -0
- package/dist/packs/pack.d.ts +84 -0
- package/dist/packs-g5thvmGn.js +3199 -0
- package/dist/packs-g5thvmGn.js.map +1 -0
- package/dist/packs.d.ts +84 -0
- package/dist/paths.d.ts +51 -0
- package/dist/plain.d.ts +17 -0
- package/dist/player.d.ts +117 -0
- package/dist/portals.d.ts +66 -0
- package/dist/prefabs.d.ts +139 -0
- package/dist/presetBuildings.d.ts +52 -0
- package/dist/presetGround.d.ts +22 -0
- package/dist/profiles-B3NS9jwk.js +335 -0
- package/dist/profiles-B3NS9jwk.js.map +1 -0
- package/dist/races.d.ts +136 -0
- package/dist/randomGroups.d.ts +2 -0
- package/dist/registry.d.ts +464 -0
- package/dist/remains.d.ts +119 -0
- package/dist/replication.d.ts +103 -0
- package/dist/rng.d.ts +17 -0
- package/dist/rules.d.ts +395 -0
- package/dist/rulesCheck.d.ts +37 -0
- package/dist/runes.d.ts +41 -0
- package/dist/save.d.ts +277 -0
- package/dist/scenario.d.ts +56 -0
- package/dist/scheduler.d.ts +67 -0
- package/dist/score.d.ts +306 -0
- package/dist/sequences.d.ts +132 -0
- package/dist/server/doorman.d.ts +21 -0
- package/dist/server/gameServer.d.ts +346 -0
- package/dist/server/index.d.ts +24 -0
- package/dist/server/lobby.d.ts +1 -0
- package/dist/server/log.d.ts +13 -0
- package/dist/server/match.d.ts +24 -0
- package/dist/server/mode.d.ts +168 -0
- package/dist/server/navigation-worker.d.ts +1 -0
- package/dist/server/navigation.d.ts +11 -0
- package/dist/server/ops.d.ts +78 -0
- package/dist/server/packs.d.ts +15 -0
- package/dist/server/ratings.d.ts +62 -0
- package/dist/server/relay.d.ts +34 -0
- package/dist/server/rooms.d.ts +162 -0
- package/dist/server/seat.d.ts +2 -0
- package/dist/server/seatSettings.d.ts +15 -0
- package/dist/server/secret.d.ts +5 -0
- package/dist/server/start.d.ts +54 -0
- package/dist/server/websocket.d.ts +74 -0
- package/dist/server.js +2861 -0
- package/dist/server.js.map +1 -0
- package/dist/session/can.d.ts +20 -0
- package/dist/session/commandReplay.d.ts +92 -0
- package/dist/session/debug.d.ts +65 -0
- package/dist/session/delay.d.ts +15 -0
- package/dist/session/delta.d.ts +98 -0
- package/dist/session/entityState.d.ts +1 -0
- package/dist/session/local.d.ts +214 -0
- package/dist/session/memory.d.ts +27 -0
- package/dist/session/protocol.d.ts +1155 -0
- package/dist/session/remote.d.ts +530 -0
- package/dist/session/replay.d.ts +114 -0
- package/dist/session/seed.d.ts +7 -0
- package/dist/session/share.d.ts +78 -0
- package/dist/session/socket.d.ts +8 -0
- package/dist/session/wire.d.ts +153 -0
- package/dist/session/worker.d.ts +227 -0
- package/dist/shared.d.ts +171 -0
- package/dist/sides.d.ts +75 -0
- package/dist/sight.d.ts +27 -0
- package/dist/simulate-oXBiw1Ff.js +167 -0
- package/dist/simulate-oXBiw1Ff.js.map +1 -0
- package/dist/simulate-worker.d.ts +1 -0
- package/dist/simulate-worker.js +28 -0
- package/dist/simulate-worker.js.map +1 -0
- package/dist/simulate.d.ts +154 -0
- package/dist/smart.d.ts +9 -0
- package/dist/spatial.d.ts +62 -0
- package/dist/spawning.d.ts +33 -0
- package/dist/stances.d.ts +76 -0
- package/dist/start.d.ts +71 -0
- package/dist/stats.d.ts +122 -0
- package/dist/summons.d.ts +63 -0
- package/dist/systems/abilities.d.ts +3 -0
- package/dist/systems/combat.d.ts +71 -0
- package/dist/systems/combatTold.d.ts +14 -0
- package/dist/systems/construction.d.ts +34 -0
- package/dist/systems/economy.d.ts +21 -0
- package/dist/systems/fog.d.ts +19 -0
- package/dist/systems/life.d.ts +3 -0
- package/dist/systems/movement.d.ts +105 -0
- package/dist/systems/orders.d.ts +7 -0
- package/dist/systems/production.d.ts +49 -0
- package/dist/systems/productionQueue.d.ts +40 -0
- package/dist/systems/victory.d.ts +14 -0
- package/dist/talk.d.ts +65 -0
- package/dist/tech.d.ts +62 -0
- package/dist/techTree.d.ts +38 -0
- package/dist/terrain.d.ts +173 -0
- package/dist/terrainSave.d.ts +29 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +822 -0
- package/dist/testing.js.map +1 -0
- package/dist/tiles.d.ts +34 -0
- package/dist/timers.d.ts +146 -0
- package/dist/tomes.d.ts +48 -0
- package/dist/trade.d.ts +28 -0
- package/dist/transport.d.ts +76 -0
- package/dist/tunables.d.ts +45 -0
- package/dist/upkeep.d.ts +16 -0
- package/dist/veterancy.d.ts +80 -0
- package/dist/walls.d.ts +86 -0
- package/dist/world.d.ts +1118 -0
- package/package.json +80 -5
- package/README.md +0 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { PlayerId } from '#engine/entity';
|
|
2
|
+
import { type PlayerCommand } from '#engine/session/protocol';
|
|
3
|
+
import type { Brain, BrainWatcher } from './brain';
|
|
4
|
+
/**
|
|
5
|
+
* The name of a rule every computer player keeps (`checkBrain`): see the table in `ai/checks.ts`
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export type AiInvariant = 'squads' | 'purse' | 'finite' | 'commands' | 'churn' | 'ends';
|
|
10
|
+
/**
|
|
11
|
+
* Every invariant, in the order they are checked
|
|
12
|
+
*
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export declare const AI_INVARIANTS: readonly AiInvariant[];
|
|
16
|
+
/**
|
|
17
|
+
* A rule a computer player broke, at a think: which, whose, when, and what exactly, in words
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export interface AiViolation {
|
|
22
|
+
invariant: AiInvariant;
|
|
23
|
+
player: PlayerId;
|
|
24
|
+
/** The tick of the think's picture of the game */
|
|
25
|
+
tick: number;
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Seconds a thing may go on before the `ends` invariant says it is stuck (`AiCheckOptions.limits`)
|
|
30
|
+
*
|
|
31
|
+
* @beta
|
|
32
|
+
*/
|
|
33
|
+
export interface AiEndLimits {
|
|
34
|
+
/** A worker on its way to build, not yet begun: 120 when left out (the build plan gives up on a site after 60) */
|
|
35
|
+
builder?: number;
|
|
36
|
+
/** A squad's task in one phase (going, gathering, fighting): 300 when left out. A squad holding a place or going with a unit never times out */
|
|
37
|
+
task?: number;
|
|
38
|
+
/** Money held under one name, think after think: 600 when left out */
|
|
39
|
+
reservation?: number;
|
|
40
|
+
/**
|
|
41
|
+
* A want of the build plan that cannot be got to (a requirement out of reach), or one that does not stand finding no
|
|
42
|
+
* spot or builder: 600 when left out. A standing want waiting for room is no fault
|
|
43
|
+
*/
|
|
44
|
+
want?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How a brain is checked (`checkBrain`, `watchComputer`)
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
51
|
+
export interface AiCheckOptions {
|
|
52
|
+
/** The invariants to check: all of them when left out */
|
|
53
|
+
invariants?: readonly AiInvariant[];
|
|
54
|
+
/** How long a thing may go on before it counts as stuck (`ends`) */
|
|
55
|
+
limits?: AiEndLimits;
|
|
56
|
+
/** Told of each broken rule as it is found. Where none is given, `checkBrain` throws at the first */
|
|
57
|
+
onViolation?: (violation: AiViolation) => void;
|
|
58
|
+
}
|
|
59
|
+
/** Seconds within which an order sent again for the same thing is churn: what `AiStats.churn` counts by too */
|
|
60
|
+
export declare const CHURN_WINDOW = 5;
|
|
61
|
+
/**
|
|
62
|
+
* What an order to a unit is for, as a key: its kind, its target, its place to the cell. Two orders with the same key
|
|
63
|
+
* are the same order. None for a command that is not an order to units (a train, a ping, a game's own)
|
|
64
|
+
*/
|
|
65
|
+
export declare function orderKey(command: PlayerCommand): string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Checks a brain against the invariants after each of its thinks, through what it is watched by (`Brain.watch`): what
|
|
68
|
+
* `checkBrain` makes, and keeps the broken rules in `violations`
|
|
69
|
+
*
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
export declare class BrainChecks implements BrainWatcher {
|
|
73
|
+
readonly brain: Brain;
|
|
74
|
+
private readonly options;
|
|
75
|
+
/** Every rule found broken, in the order found */
|
|
76
|
+
readonly violations: AiViolation[];
|
|
77
|
+
private readonly invariants;
|
|
78
|
+
private readonly limits;
|
|
79
|
+
/** What it sent since its last think ended */
|
|
80
|
+
private commands;
|
|
81
|
+
/** The last order each unit was sent, with the tick of the think */
|
|
82
|
+
private readonly orders;
|
|
83
|
+
/** Since when each thing that has to end has been going on, by a key of what it is */
|
|
84
|
+
private readonly since;
|
|
85
|
+
/** What was said stuck already: once a time it is stuck, not every think after */
|
|
86
|
+
private readonly said;
|
|
87
|
+
constructor(brain: Brain, options?: AiCheckOptions);
|
|
88
|
+
sent(command: PlayerCommand): void;
|
|
89
|
+
thought(): void;
|
|
90
|
+
/** A unit in at most one squad and one hold: two would give it two orders a think */
|
|
91
|
+
private squads;
|
|
92
|
+
/** What the think spent and what its builders will pay never more than what it had: else the same gold went twice */
|
|
93
|
+
private purse;
|
|
94
|
+
/** Every number a decision is made of is a number: a `NaN` compares false with everything and picks silently */
|
|
95
|
+
private finite;
|
|
96
|
+
/** A command about what its picture of the game has: its own units by theirs, anyone else's as seen, places on the map */
|
|
97
|
+
private command;
|
|
98
|
+
/** No order sent again for the same thing to a unit still at it: a unit told the same every think stops and starts */
|
|
99
|
+
private churn;
|
|
100
|
+
/** Builders, tasks, holds of money and blocked wants each end in time */
|
|
101
|
+
private ends;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Checks a brain against the invariants after each of its thinks from now on: throws at the first broken rule, or tells
|
|
105
|
+
* `onViolation` of each. Returns the checks (their `violations`) and the way to stop: what `watchComputer` does for a
|
|
106
|
+
* seat, and every brain does by itself while `debugChecks.ai` is on
|
|
107
|
+
*
|
|
108
|
+
* const checks = checkBrain(brain, { onViolation: (each) => found.push(each) })
|
|
109
|
+
*
|
|
110
|
+
* @beta
|
|
111
|
+
*/
|
|
112
|
+
export declare function checkBrain(brain: Brain, options?: AiCheckOptions): {
|
|
113
|
+
checks: BrainChecks;
|
|
114
|
+
stop: () => void;
|
|
115
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { PlayerId } from '#engine/entity';
|
|
2
|
+
import type { System } from '#engine/registry';
|
|
3
|
+
import { LocalSession } from '#engine/session/local';
|
|
4
|
+
import type { World } from '#engine/world';
|
|
5
|
+
import type { AiOptions } from './options';
|
|
6
|
+
import { Brain, type BrainContext, type BrainDef } from './brain';
|
|
7
|
+
import type { ThinkBudgetOptions } from './budget';
|
|
8
|
+
import { type TeamBoard } from './team';
|
|
9
|
+
import { type AiProfile } from './profiles';
|
|
10
|
+
import { type AiSettings } from './settings';
|
|
11
|
+
/**
|
|
12
|
+
* A computer player: whatever plays a seat of a world from what it sees, through commands as a player does. The
|
|
13
|
+
* engine's own is a `Brain` of modules (`defineBrain`), the melee player among them; a game gives its own in code
|
|
14
|
+
* (`defineComputer`, listed in `GameModule.brains`). `think` is asked about once a second (`createComputerSystem`); `save` and `restore` keep what
|
|
15
|
+
* it remembers through a save
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface ComputerPlayer {
|
|
20
|
+
think(): void;
|
|
21
|
+
save?(): unknown;
|
|
22
|
+
restore?(memory: unknown): void;
|
|
23
|
+
/** What it is thinking, as plain data: what the debug tools show of the player it plays (its goal, its scores) */
|
|
24
|
+
inspect?(): unknown;
|
|
25
|
+
/** Whether a think is under way across ticks (a brain's budget): it is asked to think on at the next tick */
|
|
26
|
+
readonly busy?: boolean;
|
|
27
|
+
/** Whether it sits still (`world.computers.pause`). A player without the field cannot be paused */
|
|
28
|
+
paused?: boolean;
|
|
29
|
+
/** Takes in a word from the game (`world.computers.tell`), with the tick it is told at */
|
|
30
|
+
tell?(word: string, data: unknown, tick: number): void;
|
|
31
|
+
/** Lets go of what it holds outside its seat, once unseated */
|
|
32
|
+
dispose?(): void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Milliseconds a computer player's thinks took: for the report and the stats panel, never for a decision
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export interface ComputerTiming {
|
|
40
|
+
/** The last think, all its ticks where it was sliced */
|
|
41
|
+
last: number;
|
|
42
|
+
/** Averaged over its thinks */
|
|
43
|
+
average: number;
|
|
44
|
+
/** The longest think there was */
|
|
45
|
+
longest: number;
|
|
46
|
+
/** Ticks the last think took: 1, unless the brain's budget sliced it over ticks */
|
|
47
|
+
ticks?: number;
|
|
48
|
+
/** By module, averaged, while the world profiles (`Scheduler.profiling`): a brain's */
|
|
49
|
+
modules?: Record<string, number>;
|
|
50
|
+
/** By module, the most one pass of it took, always: a brain's. What `ThinkBudgetOptions.warnAfterMs` is measured against */
|
|
51
|
+
longestByModule?: Record<string, number>;
|
|
52
|
+
/** Of a think, what taking the picture of the game took (the seat's `snapshot()`), averaged, while the world profiles: a brain's */
|
|
53
|
+
snapshot?: number;
|
|
54
|
+
/** Of a think, what reading the picture into the view took (`AiView`), averaged, while the world profiles: a brain's */
|
|
55
|
+
view?: number;
|
|
56
|
+
/** Of a think, what bringing the brain's knowledge up to date took, averaged, while the world profiles: a brain's */
|
|
57
|
+
knowledge?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The system a computer player plays from: it is asked to think about once a second (`every`, in seconds), each seat
|
|
61
|
+
* at another tick of it, to spread the work; it is named for its seat (`ai-<player>`), which a save keeps what it
|
|
62
|
+
* remembers by
|
|
63
|
+
*
|
|
64
|
+
* @beta
|
|
65
|
+
*/
|
|
66
|
+
export interface ComputerSystem<C extends ComputerPlayer = ComputerPlayer> extends System {
|
|
67
|
+
readonly computer: C;
|
|
68
|
+
/** The player it plays */
|
|
69
|
+
readonly player: PlayerId;
|
|
70
|
+
/** The seat it plays through */
|
|
71
|
+
readonly session: LocalSession;
|
|
72
|
+
/** Milliseconds its thinks took: the last, an average, the longest, and by module while the world profiles */
|
|
73
|
+
timing(): ComputerTiming;
|
|
74
|
+
/** Lets go of its seat: the session's listeners, what the computer player holds. The world stays */
|
|
75
|
+
dispose(): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* How a seat asks its computer player to think (`createComputerSystem`)
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
export interface ComputerSeatOptions {
|
|
83
|
+
/** Seconds between thinks: 1 when left out */
|
|
84
|
+
every?: number;
|
|
85
|
+
/**
|
|
86
|
+
* How much of a think one tick may do (`ThinkBudgetOptions`: modules a tick, units looked at a tick as the modules say,
|
|
87
|
+
* the milliseconds a module is warned over), or the modules a tick as a number: a think with more goes on at the next
|
|
88
|
+
* tick, over the same picture. Everything in one tick when left out
|
|
89
|
+
*/
|
|
90
|
+
budget?: number | ThinkBudgetOptions;
|
|
91
|
+
/** The tick in each round the seat thinks at: seven times the player's id when left out, so that seats think at different moments */
|
|
92
|
+
offset?: number;
|
|
93
|
+
/**
|
|
94
|
+
* What the seat's picture of the game carries: `lean`, what a computer reads (the entities, the players, the items, the
|
|
95
|
+
* deaths, damage, pings, chat and the game's own events) and none of what a screen needs (projectiles, missiles,
|
|
96
|
+
* corpses, reveals, the effects and the rest of the events), which is cheaper to take and to hear; `full`, everything a
|
|
97
|
+
* player's seat gets. `full` when left out here; a brain's seat is `lean` unless its definition says otherwise
|
|
98
|
+
* (`BrainDef.snapshot`)
|
|
99
|
+
*/
|
|
100
|
+
snapshot?: 'lean' | 'full';
|
|
101
|
+
/**
|
|
102
|
+
* Whether the seat sees everything, as an observer does (`LocalSession`'s `observer`): the one way a computer sees
|
|
103
|
+
* through the fog, for a profile with `vision: 'all'` (insane). Its own seat's sight when left out
|
|
104
|
+
*/
|
|
105
|
+
observer?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* How well the seat plays (`AiProfile`): its `handicap` (what its workers bring in, the health of what it has, the
|
|
108
|
+
* damage it deals, how long what it makes takes, made more or less through hooks that go with the seat) and `vision: 'all'` (it sees everything, as `observer`). A brain's seat and a game's
|
|
109
|
+
* own computer (`defineComputer`) are both given the profile of their difficulty
|
|
110
|
+
*/
|
|
111
|
+
profile?: AiProfile;
|
|
112
|
+
/** Called as the seat is taken away (`dispose`): to undo what seating did outside the computer (a hook added) */
|
|
113
|
+
onDispose?: () => void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Seats a computer player at a world: made of a session of its own (it sees what that player sees, and plays through
|
|
117
|
+
* commands, so it cannot cheat), asked to think about once a second. `make` is handed the session and what a brain
|
|
118
|
+
* takes besides (`BrainContext`: a seed of its own, the budget, whether the world profiles). Add the result to the
|
|
119
|
+
* world (`world.addSystem`), or seat through `world.computers.seat`, which remembers it for a save
|
|
120
|
+
*
|
|
121
|
+
* @beta
|
|
122
|
+
*/
|
|
123
|
+
export declare function createComputerSystem<C extends ComputerPlayer>(world: World, playerId: PlayerId, make: (session: LocalSession, context: BrainContext) => C, options?: ComputerSeatOptions): ComputerSystem<C>;
|
|
124
|
+
/**
|
|
125
|
+
* The boards of the teams' computers (`TeamBoard`, AI plan C5), by team: in the world, so that a save keeps the
|
|
126
|
+
* requests and the plan of an attack together, and never replicated, so that no player gets it in a snapshot
|
|
127
|
+
*
|
|
128
|
+
* @beta
|
|
129
|
+
*/
|
|
130
|
+
export declare const aiTeams: import("#engine/components").Component<Record<string, TeamBoard>, Record<string, TeamBoard>>;
|
|
131
|
+
/**
|
|
132
|
+
* Seats a brain at a world as one of its players, asked to think as its definition or the options say (`every`), with
|
|
133
|
+
* the budget the options give. Add the result to the world, or go through `world.computers.seat`
|
|
134
|
+
*
|
|
135
|
+
* @beta
|
|
136
|
+
*/
|
|
137
|
+
export declare function createBrainSystem(world: World, playerId: PlayerId, brain: BrainDef, options?: AiOptions): ComputerSystem<Brain>;
|
|
138
|
+
/**
|
|
139
|
+
* A computer player of the game's own that is not made of modules (a `ComputerPlayer`: anything that thinks), as a brain
|
|
140
|
+
* the game lists (`GameModule.brains`) and seats as it does any (`world.computers.seat(player, { brain })`): found again
|
|
141
|
+
* by its id when a save is loaded. `make` is handed the seat's session, its context and what it was seated with, the
|
|
142
|
+
* map's under the seat's; it thinks as often as those say (`every`, 1 second when left out)
|
|
143
|
+
*
|
|
144
|
+
* @beta
|
|
145
|
+
*/
|
|
146
|
+
export declare function defineComputer<C extends ComputerPlayer>(id: string, make: (session: LocalSession, context: BrainContext, options: AiOptions) => C): BrainDef;
|
|
147
|
+
/**
|
|
148
|
+
* What a map says of how its computer player plays (`MapPlayer.data.ai`, decision 6 of the AI plan), for a player the map
|
|
149
|
+
* gives the computer (`controller: 'computer'`): a difficulty and a personality by name, and settings (`AiSettings`:
|
|
150
|
+
* its flags, its build order as `plans.order`, its waves as `waves.waves`, any area's numbers). Plain data, as the map's
|
|
151
|
+
* file holds it
|
|
152
|
+
*
|
|
153
|
+
* @beta
|
|
154
|
+
*/
|
|
155
|
+
export interface MapAi {
|
|
156
|
+
/** The brain the player is seated with, by id (`GameModule.brains`): over its race's (`GameAi.races`), under the seat's */
|
|
157
|
+
brain?: string;
|
|
158
|
+
difficulty?: string;
|
|
159
|
+
personality?: string;
|
|
160
|
+
settings?: AiSettings;
|
|
161
|
+
/**
|
|
162
|
+
* Settings by the race the player plays (`GameModule.races`), over `settings`: for a player whose race the lobby
|
|
163
|
+
* chooses or draws (`random`), a build order or waves for each
|
|
164
|
+
*/
|
|
165
|
+
races?: Record<string, AiSettings>;
|
|
166
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { type Vec2 } from '#engine/math';
|
|
2
|
+
import { type AiModuleDef } from './module';
|
|
3
|
+
import type { Base, UnitSet } from './view';
|
|
4
|
+
/**
|
|
5
|
+
* How a brain defends its bases (`BrainDef.defence`, the seat's `AiOptions.defence` over it, the `defence()` module's
|
|
6
|
+
* own under both). Data, kept in a save
|
|
7
|
+
*
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export interface DefenceOptions {
|
|
11
|
+
/** How near one of its buildings a rival's unit is an intruder: the seat's `defendRadius`, else 16 */
|
|
12
|
+
radius?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The odds of the fight (`Strength.odds`) the defenders sent against a raid are to have: two in three when left out
|
|
15
|
+
* (about four tenths stronger than the raid)
|
|
16
|
+
*/
|
|
17
|
+
odds?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Whether a raid more than what is at home can meet brings the army home (the goal is urgent: it takes squads out,
|
|
20
|
+
* whole, once it scores past what they are on): yes when left out
|
|
21
|
+
*/
|
|
22
|
+
recall?: boolean;
|
|
23
|
+
/** Towers a base wants once raided `towerAfter` times: 1 when left out. 0 for none */
|
|
24
|
+
towers?: number;
|
|
25
|
+
/** Raids at one base before it wants towers: 2 when left out */
|
|
26
|
+
towerAfter?: number;
|
|
27
|
+
/** The tower to build, by type id: the cheapest of the `tower` role its workers build when left out */
|
|
28
|
+
tower?: string;
|
|
29
|
+
/** Seconds a base stands clear before a raid on it is over: 15 when left out */
|
|
30
|
+
quiet?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What the defence remembers between thinks, as a save keeps it: each base's raids
|
|
34
|
+
*
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
37
|
+
export interface DefenceMemory {
|
|
38
|
+
v: 1;
|
|
39
|
+
/** By base (the id of what it is around): where, how many raids, the one on now (since when), when last seen, the strongest */
|
|
40
|
+
raids: Record<string, {
|
|
41
|
+
at: Vec2;
|
|
42
|
+
count: number;
|
|
43
|
+
since?: number;
|
|
44
|
+
last: number;
|
|
45
|
+
most: number;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The intruders at one base, as the defence sees them this think (`ai.defence.raids()`)
|
|
50
|
+
*
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
export interface Raid {
|
|
54
|
+
/** The base raided */
|
|
55
|
+
base: Base;
|
|
56
|
+
/** What the defence remembers it by: the id of what the base is around */
|
|
57
|
+
key: string;
|
|
58
|
+
/** The rivals' units there */
|
|
59
|
+
intruders: UnitSet;
|
|
60
|
+
/** Their strength together (`Strength.of`) */
|
|
61
|
+
strength: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The defence as the report shows it (`AiReport.defence`): the raids on now with what answers each, every base's raids
|
|
65
|
+
* so far, the towers it wants
|
|
66
|
+
*
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
export interface DefenceReport {
|
|
70
|
+
raids: {
|
|
71
|
+
at: [number, number];
|
|
72
|
+
intruders: number[];
|
|
73
|
+
strength: number;
|
|
74
|
+
squad?: string;
|
|
75
|
+
defenders: number;
|
|
76
|
+
since: number;
|
|
77
|
+
count: number;
|
|
78
|
+
}[];
|
|
79
|
+
bases: {
|
|
80
|
+
at: [number, number];
|
|
81
|
+
raids: number;
|
|
82
|
+
last: number;
|
|
83
|
+
}[];
|
|
84
|
+
towers: {
|
|
85
|
+
at: [number, number];
|
|
86
|
+
want: string;
|
|
87
|
+
status: string;
|
|
88
|
+
}[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The id of the defence's goal: what a game weighs it by (`AiOptions.weigh`)
|
|
92
|
+
*
|
|
93
|
+
* @beta
|
|
94
|
+
*/
|
|
95
|
+
export declare const DEFEND = "defend";
|
|
96
|
+
/**
|
|
97
|
+
* The defence module: the raids on the bases counted each think, the towers a raided base wants (`ai.defence.think`),
|
|
98
|
+
* and the `defend` goal put on the brain's picker, which answers each raid with a squad of its own. With how it defends
|
|
99
|
+
* where the brain's definition and the seat's options say nothing (`DefenceOptions`)
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
export declare const defence: (options?: DefenceOptions) => AiModuleDef;
|
|
104
|
+
declare module './area' {
|
|
105
|
+
interface AreaMemories {
|
|
106
|
+
defence?: DefenceMemory;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A brain defined (`defineBrain`): checked, given its `with` for variants, and its seat (`BrainDef.seat`), which is the
|
|
3
|
+
* kit's (`createBrainSystem`). Apart from the brain itself (`brain.ts`), which the seat is made of
|
|
4
|
+
*/
|
|
5
|
+
import type { BrainDef, BrainExtension } from './brain';
|
|
6
|
+
/**
|
|
7
|
+
* A brain as `defineBrain` gives it: with its `with`, for variants of it
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export interface DefinedBrain extends BrainDef {
|
|
12
|
+
with(more: BrainExtension): DefinedBrain;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Defines a brain: what a computer player is made of, to seat at a world (`world.computers.seat(player, { ...options, brain })`,
|
|
16
|
+
* `world.computers.seat`) and to list in `GameModule.brains`, for a save to find it by its id. Modules that keep state
|
|
17
|
+
* are given as functions of the brain, as systems are of the world
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export declare function defineBrain(def: BrainDef): DefinedBrain;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type ResourceKind } from '#engine/defs';
|
|
2
|
+
import { type Vec2 } from '#engine/math';
|
|
3
|
+
import type { EntityState } from '#engine/session/protocol';
|
|
4
|
+
import { type Brain } from './brain';
|
|
5
|
+
import { type AiModuleDef } from './module';
|
|
6
|
+
import { type AiCondition } from './rules';
|
|
7
|
+
import type { Base } from './view';
|
|
8
|
+
/**
|
|
9
|
+
* How many workers a base wants on each resource (`EconomyOptions.workersPer`): as numbers by resource id, or a
|
|
10
|
+
* function of the base (`index` 0 is home)
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export type WorkersPer = Partial<Record<ResourceKind, number>> | ((ai: Brain, base: Base, index: number) => Partial<Record<ResourceKind, number>>);
|
|
15
|
+
/**
|
|
16
|
+
* How a brain runs its economy (`BrainDef.economy`, the seat's `AiOptions.economy` over it, the `economy()` module's
|
|
17
|
+
* own under both). Every field has a data form a save keeps; the function forms are the brain's to give again
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export interface EconomyOptions {
|
|
22
|
+
/** Workers on the game's money at each base, where `workersPer` says nothing of it: 8 when left out */
|
|
23
|
+
workers?: number;
|
|
24
|
+
/** Workers on the other resource, at home only, where `workersPer` says nothing of it: 3 when left out */
|
|
25
|
+
lumberjacks?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Workers on each resource at each base (`WorkersPer`): `{ gold: 5, lumber: 3 }` at every base, or a function of the
|
|
28
|
+
* base for one that differs (home, an expansion). What it leaves out is `workers` and `lumberjacks`
|
|
29
|
+
*/
|
|
30
|
+
workersPer?: WorkersPer;
|
|
31
|
+
/** Whether a base wants no more workers on a deposit than it serves (see the file's comment): yes when left out */
|
|
32
|
+
saturate?: boolean;
|
|
33
|
+
/** Whether its halls train workers up to what the bases want: yes when left out */
|
|
34
|
+
trainWorkers?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Workers trained past what the bases want, to build with: a worker sent to build is off the mine meanwhile, and a
|
|
37
|
+
* mine with only as many as it serves would gather less. 1 when left out
|
|
38
|
+
*/
|
|
39
|
+
builders?: number;
|
|
40
|
+
/** Halls to have past the first, each by a mine nobody has a hall at: the seat's `expansions`, else none */
|
|
41
|
+
expansions?: number;
|
|
42
|
+
/**
|
|
43
|
+
* When it may expand: a condition (`AiCondition`, as data or a function). Four minutes in and with a building that
|
|
44
|
+
* trains soldiers, when left out
|
|
45
|
+
*/
|
|
46
|
+
expandWhen?: AiCondition;
|
|
47
|
+
/** Whether workers a raid is on walk to a base no enemy is at, and back once theirs is clear: yes when left out */
|
|
48
|
+
workersFlee?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What the economy remembers between thinks, as a save keeps it: the workers that fled a raid
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
export interface EconomyMemory {
|
|
56
|
+
v: 1;
|
|
57
|
+
/** Each worker that fled, by id: the base it fled (its middle), where to, since when, and since when its base stood clear */
|
|
58
|
+
fled: Record<string, {
|
|
59
|
+
from: Vec2;
|
|
60
|
+
to: Vec2;
|
|
61
|
+
since: number;
|
|
62
|
+
clear?: number;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Workers more on the other resource at home, while it runs short with the money piling up (AI2): one more each
|
|
66
|
+
* `BLOCKED` seconds it stays so, at most `MORE_AT_MOST`, one fewer each twice that once it is not. Since when it has
|
|
67
|
+
* been short (`since`) or not (`easy`), and who was sent to it lately (`moved`)
|
|
68
|
+
*/
|
|
69
|
+
material?: {
|
|
70
|
+
more: number;
|
|
71
|
+
since?: number;
|
|
72
|
+
easy?: number;
|
|
73
|
+
moved?: Record<string, number>;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One base as the economy sees it (`ai.economy.bases()`, the report): its deposits, what they serve, the workers it
|
|
78
|
+
* wants and has on each resource
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
export interface EconomyBase {
|
|
83
|
+
/** The view's base */
|
|
84
|
+
base: Base;
|
|
85
|
+
/** Its deposits it gathers from, by resource: those of the money with a hall by them (or something of its own on them), the rest near it */
|
|
86
|
+
deposits: Partial<Record<ResourceKind, EntityState[]>>;
|
|
87
|
+
/** How many workers its deposits of each resource serve at once */
|
|
88
|
+
serves: Partial<Record<ResourceKind, number>>;
|
|
89
|
+
/** How many it wants on each resource: what it is to have, no more than what is served where it saturates */
|
|
90
|
+
wants: Partial<Record<ResourceKind, number>>;
|
|
91
|
+
/** The workers at work on each resource at it, by id */
|
|
92
|
+
working: Partial<Record<ResourceKind, number[]>>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The economy as the report shows it (`AiReport.economy.bases`, `fled`): each base with what it wants and has, the
|
|
96
|
+
* workers that fled, how many it trains, what the next expansion waits for
|
|
97
|
+
*
|
|
98
|
+
* @beta
|
|
99
|
+
*/
|
|
100
|
+
export interface EconomyReport {
|
|
101
|
+
bases: {
|
|
102
|
+
at: [number, number];
|
|
103
|
+
hall: number;
|
|
104
|
+
workers: Record<ResourceKind, [working: number, wants: number, serves: number]>;
|
|
105
|
+
}[];
|
|
106
|
+
fled: {
|
|
107
|
+
unit: number;
|
|
108
|
+
from: [number, number];
|
|
109
|
+
since: number;
|
|
110
|
+
}[];
|
|
111
|
+
/** Workers it has, those queued counted, and what its bases want together */
|
|
112
|
+
workers: [have: number, want: number];
|
|
113
|
+
/** Where the next hall goes, and what it waits for: the build plan's status of the want */
|
|
114
|
+
expansion?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The economy module: the workers base by base each think (`ai.economy.think`): builders to sites, workers off a raid and
|
|
118
|
+
* back, the idle where they are missing, the spare moved, the other resource's gatherers, what the money is gathered at,
|
|
119
|
+
* workers trained, another hall wanted. With how it runs where the brain's definition and the seat's options say nothing
|
|
120
|
+
* (`EconomyOptions`)
|
|
121
|
+
*
|
|
122
|
+
* @beta
|
|
123
|
+
*/
|
|
124
|
+
export declare const economy: (options?: EconomyOptions) => AiModuleDef;
|
|
125
|
+
declare module './area' {
|
|
126
|
+
interface AreaMemories {
|
|
127
|
+
economy?: EconomyMemory;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The small words of the AI kit (design review B13): a point as plain data, as a pair for a report, as a decision
|
|
3
|
+
* writes it, and the counts and articles of a decision's line. One copy, for every module and area
|
|
4
|
+
*/
|
|
5
|
+
import type { Vec2 } from '#engine/math';
|
|
6
|
+
/**
|
|
7
|
+
* A point as plain data, for a save or a task's data: `{ x, z }` and nothing else
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export declare const point: (at: Vec2) => Vec2;
|
|
12
|
+
/**
|
|
13
|
+
* A point as a report has it: `[x, z]`, rounded
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export declare const pair: (at: Vec2) => [number, number];
|
|
18
|
+
/**
|
|
19
|
+
* A point as a decision writes it: `(40, 60)`
|
|
20
|
+
*
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export declare const where: (at: Vec2) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Units counted as a decision writes them: `1 unit`, `3 units`
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export declare const plural: (n: number) => string;
|
|
30
|
+
/**
|
|
31
|
+
* A thing as a decision writes it, with its article: `a farm`, `an altar`
|
|
32
|
+
*
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export declare const an: (thing: string) => string;
|