@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.
- 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,73 @@
|
|
|
1
|
+
import type { Cost, ResourceKind } from '#engine/defs';
|
|
2
|
+
import type { Registry } from '#engine/registry';
|
|
3
|
+
import type { AiView } from '#engine/ai/view';
|
|
4
|
+
/**
|
|
5
|
+
* What a computer player has to spend this think (`ai.purse`): its resources less what is promised and held, spent
|
|
6
|
+
* through `spend`. Rebuilt from the picture each think
|
|
7
|
+
*
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export declare class Purse {
|
|
11
|
+
/** What is free to spend now, by resource: less with every `spend` and `reserve` of the think. `view.me.purse` is this */
|
|
12
|
+
free: Cost;
|
|
13
|
+
/** What builders on their way to a site will pay as they get there, by resource */
|
|
14
|
+
promised: Cost;
|
|
15
|
+
/** What was paid this think (`spend`), by resource: with `promised`, never more than the picture's resources (`ai/checks.ts`) */
|
|
16
|
+
spent: Cost;
|
|
17
|
+
/** The resource most things cost (`Registry.currency`): what `affords` keeps `spare` of */
|
|
18
|
+
readonly money: ResourceKind;
|
|
19
|
+
private holds;
|
|
20
|
+
constructor(registry: Registry);
|
|
21
|
+
/**
|
|
22
|
+
* Starts the think's ledger from the picture: the player's resources, less what its builders on their way will pay
|
|
23
|
+
* (`promised`). Every hold of the think before is dropped: whoever still wants one makes it again
|
|
24
|
+
*/
|
|
25
|
+
begin(view: AiView): void;
|
|
26
|
+
/** What someone this important may spend: what is free, and what is held by anyone less important */
|
|
27
|
+
available(priority?: number): Cost;
|
|
28
|
+
/** The resource a cost is short of, out of what someone this important may spend: none when it can be paid */
|
|
29
|
+
shortOf(cost: Cost | undefined, priority?: number): ResourceKind | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a cost can be paid by someone this important, with `spare` of the money left over after it (a luxury
|
|
32
|
+
* waits for gold to spare): out of what is free, and what is held by anyone less important
|
|
33
|
+
*/
|
|
34
|
+
affords(cost: Cost | undefined, spare?: number, priority?: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Pays a cost, for a command sent this think: out of what is free first, then out of what is held by anyone less
|
|
37
|
+
* important (the least important first), whose holds are less by that much. False, and nothing paid, when it cannot be
|
|
38
|
+
*/
|
|
39
|
+
spend(cost: Cost | undefined, priority?: number): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Holds a cost aside under a name (a goal's id, a want's) for the rest of the think, with how important the holder
|
|
42
|
+
* is (0 when left out): what is free is less by it, so that nothing less important spends what is saved up. Made
|
|
43
|
+
* again each think by whoever still saves; a second hold under the same name replaces the first
|
|
44
|
+
*/
|
|
45
|
+
reserve(id: string, cost: Cost, priority?: number): void;
|
|
46
|
+
/** Lets a hold go: what it held is free again this think */
|
|
47
|
+
release(id: string): void;
|
|
48
|
+
/** What is held under a name */
|
|
49
|
+
reservation(id: string): Readonly<Cost> | undefined;
|
|
50
|
+
/** What is held altogether, by resource */
|
|
51
|
+
reserved(): Cost;
|
|
52
|
+
/** Every hold, by name: what and how important */
|
|
53
|
+
holdings(): Readonly<Record<string, {
|
|
54
|
+
cost: Readonly<Cost>;
|
|
55
|
+
priority: number;
|
|
56
|
+
}>>;
|
|
57
|
+
/** The ledger for the report: what is free, what is promised, what is held and by whom */
|
|
58
|
+
inspect(): PurseReport;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The purse as the report shows it: what is free, what builders on their way will pay, what is held and by whom, with
|
|
62
|
+
* how important each holder is
|
|
63
|
+
*
|
|
64
|
+
* @beta
|
|
65
|
+
*/
|
|
66
|
+
export interface PurseReport {
|
|
67
|
+
free: Cost;
|
|
68
|
+
promised: Cost;
|
|
69
|
+
held: Record<string, {
|
|
70
|
+
cost: Cost;
|
|
71
|
+
priority: number;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AiView } from '#engine/ai/view';
|
|
2
|
+
/**
|
|
3
|
+
* One step towards a type: a building to build (by a worker), a building to turn another into (`morph`, from the
|
|
4
|
+
* type that turns into it), or a unit to train (at the type that trains it). `for` is what the step is on the way to
|
|
5
|
+
*
|
|
6
|
+
* @beta
|
|
7
|
+
*/
|
|
8
|
+
export interface TechStep {
|
|
9
|
+
type: string;
|
|
10
|
+
how: 'build' | 'morph' | 'train';
|
|
11
|
+
/** For a `morph`, the type that turns into it; for a `train`, the type that trains it; for a `build`, the type that builds it */
|
|
12
|
+
from: string;
|
|
13
|
+
for: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The steps from what the player has to being able to make a type (`techPath`): the prerequisites, the producer, in
|
|
17
|
+
* the order they can be taken; the type itself is not among them. `cycle` names the definitions that go round in a
|
|
18
|
+
* circle where they do, `impossible` the type nothing of the player's can make, and the steps are then as far as the
|
|
19
|
+
* walk got
|
|
20
|
+
*
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export interface TechPath {
|
|
24
|
+
steps: TechStep[];
|
|
25
|
+
cycle?: string[];
|
|
26
|
+
impossible?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The steps from what the player has to being able to make a type: what it requires that it lacks, each of those in
|
|
30
|
+
* turn, and the type's maker where it has none (the hall that trains the worker, the worker that builds the barracks,
|
|
31
|
+
* the hall that turns into the keep). What stands finished (`view.me.tech`, with what it counts as) or is on its way
|
|
32
|
+
* (`onItsWay`: under construction, a builder sent, a morph queued) is had already. A requirement no type has as its
|
|
33
|
+
* id is met by a type that provides it
|
|
34
|
+
*
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
37
|
+
export declare function techPath(view: AiView, target: string, onItsWay?: (type: string) => boolean): TechPath;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { Registry } from '#engine/registry';
|
|
2
|
+
import type { AiConditionTest } from './rules';
|
|
3
|
+
import type { ThinkBudgetOptions } from './budget';
|
|
4
|
+
import type { AiOptions } from './options';
|
|
5
|
+
import type { Brain } from './brain';
|
|
6
|
+
import { type AiSettings } from './settings';
|
|
7
|
+
/**
|
|
8
|
+
* A flag's value: as data, or worked out by the brain as it is asked (code, not kept in a save)
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export type AiFlag<T> = T | ((ai: Brain) => T);
|
|
13
|
+
/**
|
|
14
|
+
* The classic RTS behaviour flags, where the meaning holds, and the kit's own beside them: each a yes or no, a number where
|
|
15
|
+
* one says how much, or a function of the brain
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface AiFlags {
|
|
20
|
+
/** Helps its allies, people and computers, where asked (the team's `help` goal) */
|
|
21
|
+
defendUsers?: AiFlag<boolean>;
|
|
22
|
+
/** Hits heroes first among those alike (the micro's targets) */
|
|
23
|
+
targetHeroes?: AiFlag<boolean>;
|
|
24
|
+
/** Mends damaged buildings when no enemy reaches them (the build plan's `repair`) */
|
|
25
|
+
repairStructures?: AiFlag<boolean>;
|
|
26
|
+
/** A hero leaves a fight under this share of its health: `true` at the share under it, `false` never (`micro.heroesFlee`) */
|
|
27
|
+
heroesFlee?: AiFlag<boolean | number>;
|
|
28
|
+
/** A unit leaves a fight under this share of its health: `true` at the share under it, `false` never (`micro.unitsFlee`) */
|
|
29
|
+
unitsFlee?: AiFlag<boolean | number>;
|
|
30
|
+
/** A squad falls back from a fight away from home under these odds: `true` at the odds under it, `false` never (`squads.retreatAt`) */
|
|
31
|
+
groupsFlee?: AiFlag<boolean | number>;
|
|
32
|
+
/** Attacks before its time when the enemy's army as last seen is weak against its own: at these odds (`true`: 0.75) */
|
|
33
|
+
noMercy?: AiFlag<boolean | number>;
|
|
34
|
+
/** A unit that fled stays out until healed */
|
|
35
|
+
ignoreInjured?: AiFlag<boolean>;
|
|
36
|
+
/** The hurt go home to heal between fights */
|
|
37
|
+
removeInjuries?: AiFlag<boolean>;
|
|
38
|
+
/** Picks up what lies about */
|
|
39
|
+
takeItems?: AiFlag<boolean>;
|
|
40
|
+
/** Its heroes buy from shops in reach */
|
|
41
|
+
buyItems?: AiFlag<boolean>;
|
|
42
|
+
/** Builds its hall again where it can, once its home falls, rather than where it first stood: yes when left out */
|
|
43
|
+
allowHomeChanges?: AiFlag<boolean>;
|
|
44
|
+
/** Siege units shoot buildings and stay behind their squad */
|
|
45
|
+
smartArtillery?: AiFlag<boolean>;
|
|
46
|
+
/** Each wave takes a way of its own to the target, by the brain's numbers: straight, or round one side or the other */
|
|
47
|
+
randomPaths?: AiFlag<boolean>;
|
|
48
|
+
/** Builds again what it lost */
|
|
49
|
+
rebuild?: AiFlag<boolean>;
|
|
50
|
+
/** Ranged units step back from melee they outrun */
|
|
51
|
+
kite?: AiFlag<boolean>;
|
|
52
|
+
/** Workers a raid is on walk to a safe base */
|
|
53
|
+
workersFlee?: AiFlag<boolean>;
|
|
54
|
+
/** Says its lines to its side (the team's `say`) */
|
|
55
|
+
say?: AiFlag<boolean>;
|
|
56
|
+
/** Sends a unit to look at the enemy (the scouting's goal) */
|
|
57
|
+
scout?: AiFlag<boolean>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* How a computer player plays, as plain data: the settings of its areas (`AiSettings`) and how well it plays, every field
|
|
61
|
+
* optional, layered (see the file's comment). What a difficulty, a personality and a game's defaults give
|
|
62
|
+
*
|
|
63
|
+
* @beta
|
|
64
|
+
*/
|
|
65
|
+
export interface AiProfile extends AiSettings {
|
|
66
|
+
/**
|
|
67
|
+
* The brain it plays with, by id (one the game lists in `GameModule.brains`): what a race's profile says
|
|
68
|
+
* (`GameAi.races`, campaign plan AR3), for a seat that names none and a map that says none. The game's first brain
|
|
69
|
+
* where nothing says
|
|
70
|
+
*/
|
|
71
|
+
brain?: string;
|
|
72
|
+
/** The difficulty by name: `easy`, `normal`, `hard`, `insane`, or a game's own (`GameModule.ai.difficulties`). `normal` when left out */
|
|
73
|
+
difficulty?: string;
|
|
74
|
+
/** The personality by name: `balanced`, `rusher`, `turtle`, `expander`, `harasser`, or a game's own. `balanced` when left out */
|
|
75
|
+
personality?: string;
|
|
76
|
+
/** Seconds between thinks: its reactions */
|
|
77
|
+
every?: number;
|
|
78
|
+
/** Commands a think may send at the most, like a person's hands: no limit when left out */
|
|
79
|
+
commandsPerThink?: number;
|
|
80
|
+
/** How often it slips, 0 to 1: a think's fights left alone, a wave sent early. Drawn with the brain's own numbers */
|
|
81
|
+
mistakes?: number;
|
|
82
|
+
/** `fair`: it sees what its seat does. `all`: it sees through the fog (an observer's session), for insane only */
|
|
83
|
+
vision?: 'fair' | 'all';
|
|
84
|
+
/**
|
|
85
|
+
* How much of a think one tick may do (`ThinkBudgetOptions`): modules a tick, units looked at a tick, the milliseconds
|
|
86
|
+
* a module is warned over (4). Nothing sliced when left out: a game sets it where its numbers ask, at many computers
|
|
87
|
+
*/
|
|
88
|
+
budget?: ThinkBudgetOptions;
|
|
89
|
+
/**
|
|
90
|
+
* What it is given beyond the rules, each a factor (1 is none), through the game's hooks while it is seated:
|
|
91
|
+
* `income`, what its workers bring in (1.5: half again; `beforeDeposit`); `health`, the most health of everything
|
|
92
|
+
* it has (`stats`); `damage`, the damage it deals (`beforeDamage`, before armour); `buildTime`, how long what it
|
|
93
|
+
* trains, builds and researches takes (0.8: a fifth sooner; `beforeProduce`). The classic handicap is `health`
|
|
94
|
+
*/
|
|
95
|
+
handicap?: AiHandicap;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* What a computer is given beyond the rules (`AiProfile.handicap`): each a factor, 1 (or left out) for none
|
|
99
|
+
*
|
|
100
|
+
* @beta
|
|
101
|
+
*/
|
|
102
|
+
export interface AiHandicap {
|
|
103
|
+
/** What its workers bring in, through the game's `beforeDeposit` hook */
|
|
104
|
+
income?: number;
|
|
105
|
+
/** The most health of everything it has, through a `stats` hook: the classic handicap */
|
|
106
|
+
health?: number;
|
|
107
|
+
/** The damage it deals, before armour, through a `beforeDamage` hook */
|
|
108
|
+
damage?: number;
|
|
109
|
+
/** How long what it trains, builds and researches takes, through a `beforeProduce` hook: under 1 is sooner */
|
|
110
|
+
buildTime?: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A difficulty's or a personality's profile, the engine's or a game's
|
|
114
|
+
*
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
export type AiProfileTable = Record<string, AiProfile>;
|
|
118
|
+
/**
|
|
119
|
+
* The engine's defaults of how well it plays: the bottom layer. The areas' numbers are each area's own where no layer
|
|
120
|
+
* says them (`Economy`'s 8 workers)
|
|
121
|
+
*
|
|
122
|
+
* @beta
|
|
123
|
+
*/
|
|
124
|
+
export declare const DEFAULT_PROFILE: Readonly<AiProfile>;
|
|
125
|
+
/**
|
|
126
|
+
* The engine's difficulties: how well it plays. `normal` is the areas' own numbers. `insane` sees through the fog and
|
|
127
|
+
* gets half again of what its workers bring in, as the classic insane computer does
|
|
128
|
+
*
|
|
129
|
+
* @beta
|
|
130
|
+
*/
|
|
131
|
+
export declare const DIFFICULTIES: Readonly<AiProfileTable>;
|
|
132
|
+
/**
|
|
133
|
+
* The engine's personalities: how it likes to play. Over the difficulty, so a rusher rushes on any of them
|
|
134
|
+
*
|
|
135
|
+
* @beta
|
|
136
|
+
*/
|
|
137
|
+
export declare const PERSONALITIES: Readonly<AiProfileTable>;
|
|
138
|
+
/**
|
|
139
|
+
* What a game says of its computer players' profiles (`GameModule.ai`): difficulties and personalities of its own, and
|
|
140
|
+
* defaults over the engine's
|
|
141
|
+
*
|
|
142
|
+
* @beta
|
|
143
|
+
*/
|
|
144
|
+
export interface GameAi {
|
|
145
|
+
/** Difficulties of its own, by name, beside (or over) the engine's */
|
|
146
|
+
difficulties?: AiProfileTable;
|
|
147
|
+
/** Personalities of its own, by name */
|
|
148
|
+
personalities?: AiProfileTable;
|
|
149
|
+
/** Conditions of its own, by id, for the data form (`{ is: 'mygame.bridgeDown', args }`), a map's file among them */
|
|
150
|
+
conditions?: Record<string, AiConditionTest>;
|
|
151
|
+
/** Defaults over the engine's, under the difficulty */
|
|
152
|
+
defaults?: AiProfile;
|
|
153
|
+
/**
|
|
154
|
+
* How its computers play each of its races (`GameModule.races`), by race id: a layer over `defaults` and under the
|
|
155
|
+
* difficulty, for a seat of that race (its build order, heroes, composition, flags; how often it thinks). Its
|
|
156
|
+
* `difficulty` and `personality` are the seat's where the lobby and the map say none
|
|
157
|
+
*/
|
|
158
|
+
races?: AiProfileTable;
|
|
159
|
+
/** Whether a lobby offers its seats a difficulty and a personality (`seatSettingsOf`): yes when left out */
|
|
160
|
+
lobby?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The difficulties a game's computers may play at, by name: the engine's, the game's over them
|
|
164
|
+
*
|
|
165
|
+
* @beta
|
|
166
|
+
*/
|
|
167
|
+
export declare function difficultiesOf(registry?: Pick<Registry, 'module'>): AiProfileTable;
|
|
168
|
+
/**
|
|
169
|
+
* The personalities a game's computers may have, by name: the engine's, the game's over them
|
|
170
|
+
*
|
|
171
|
+
* @beta
|
|
172
|
+
*/
|
|
173
|
+
export declare function personalitiesOf(registry?: Pick<Registry, 'module'>): AiProfileTable;
|
|
174
|
+
/**
|
|
175
|
+
* A profile resolved (`resolveProfile`): what it plays by, and its settings' layers as given, lowest first, for the brain
|
|
176
|
+
* to work out each think (a flag may be a function of it)
|
|
177
|
+
*
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
export interface ResolvedProfile {
|
|
181
|
+
/** The profile, its settings layered (a flag's function left out) */
|
|
182
|
+
profile: AiProfile;
|
|
183
|
+
/** Its settings' layers, lowest first: the brain's, the game's, the race's, the difficulty's, the personality's, the seat's (the map's under it) */
|
|
184
|
+
layers: readonly AiSettings[];
|
|
185
|
+
/** A difficulty or a personality the game does not have, passed over */
|
|
186
|
+
unknown: string[];
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* The profile a seat plays by (`Brain.profile`): the brain's settings (`BrainDef.settings`), the game's defaults, the
|
|
190
|
+
* race's (`GameAi.races`, for the `race` the seat plays), the difficulty, the personality, the seat's own
|
|
191
|
+
* (`AiOptions.settings`, the map's under it), each over the one before; how well it plays from the engine's defaults,
|
|
192
|
+
* the game's, the race's, the difficulty, the personality and the seat's `every` and `budget`. A name the game does not
|
|
193
|
+
* have is passed over, and `unknown` names it
|
|
194
|
+
*
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
export declare function resolveProfile(options: AiOptions, registry?: Pick<Registry, 'module'>, brain?: AiSettings, race?: string): ResolvedProfile;
|
|
198
|
+
/**
|
|
199
|
+
* A flag's value as asked now: a function of the brain worked out, data as it is. For a flag no area has a name for
|
|
200
|
+
* (No Mercy, Random Paths, Allow Home Changes): the rest are the areas' (`ai.settings`)
|
|
201
|
+
*
|
|
202
|
+
* @beta
|
|
203
|
+
*/
|
|
204
|
+
export declare function flagOf<K extends keyof AiFlags>(ai: Brain, name: K): Exclude<AiFlags[K], (ai: Brain) => unknown> | undefined;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { PlayerId } from '#engine/entity';
|
|
2
|
+
import type { ComputerTiming } from './computer';
|
|
3
|
+
import type { ThinkBudgetOptions } from './budget';
|
|
4
|
+
import type { GoalReport } from './goals';
|
|
5
|
+
import type { PlansReport } from './plans/plans';
|
|
6
|
+
import type { SquadReport } from './squads';
|
|
7
|
+
import type { MicroReport } from './micro';
|
|
8
|
+
import type { DefenceReport } from './defence';
|
|
9
|
+
import type { EconomyReport } from './economy';
|
|
10
|
+
import type { ScoutingReport } from './scouting';
|
|
11
|
+
import type { TeamReport } from './team';
|
|
12
|
+
import type { AiProfile } from './profiles';
|
|
13
|
+
import type { WavesReport } from './waves';
|
|
14
|
+
/**
|
|
15
|
+
* One thing a computer player decided, as a line of text: what it did and the reason that weighed most
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export interface AiDecision {
|
|
20
|
+
/** The tick of the think it was decided at */
|
|
21
|
+
tick: number;
|
|
22
|
+
/** What it is about: `goal` for the goals' picker, or the module's word (`army`, `build`, `research`, `hero`) */
|
|
23
|
+
kind: string;
|
|
24
|
+
/** What was decided, in words: "attack picked at 0.80 (8 units): its time has come 1.00 · the wave is ready 1.00" */
|
|
25
|
+
line: string;
|
|
26
|
+
/** The goal it is about, where it is about one */
|
|
27
|
+
goal?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* What a computer player remembers of what it saw, in short, for the report: its rivals' bases and their army as last
|
|
31
|
+
* seen, with how many seconds ago, and the tech seen
|
|
32
|
+
*
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export interface KnowledgeReport {
|
|
36
|
+
bases: {
|
|
37
|
+
owner: PlayerId;
|
|
38
|
+
at: [number, number];
|
|
39
|
+
structures: number;
|
|
40
|
+
seen: number;
|
|
41
|
+
gone?: true;
|
|
42
|
+
}[];
|
|
43
|
+
army: {
|
|
44
|
+
at: [number, number];
|
|
45
|
+
count: number;
|
|
46
|
+
seen: number;
|
|
47
|
+
}[];
|
|
48
|
+
tech: string[];
|
|
49
|
+
lost: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What a computer player's play adds up to since it was seated (`Brain.stats`, `AiReport.stats`): the numbers
|
|
53
|
+
* `simulate` reports beside who won, and a test reads to see that the squads send an order once and watch it. Counted,
|
|
54
|
+
* never decided on
|
|
55
|
+
*
|
|
56
|
+
* @beta
|
|
57
|
+
*/
|
|
58
|
+
export interface AiStats {
|
|
59
|
+
/** Commands sent */
|
|
60
|
+
commands: number;
|
|
61
|
+
/** Commands held back past what a think may send (`AiProfile.commandsPerThink`) */
|
|
62
|
+
held: number;
|
|
63
|
+
/** Commands the game refused (a unit that could not do it, a place it could not build at) */
|
|
64
|
+
refused: number;
|
|
65
|
+
/** Seconds its fighters stood idle, summed over the fighters: ten footmen idle for a minute are six hundred */
|
|
66
|
+
idleArmySeconds: number;
|
|
67
|
+
/** Orders sent to a unit again for the same thing within a few seconds: a unit told the same every think stops and starts */
|
|
68
|
+
churn: number;
|
|
69
|
+
/** Seconds its building waited on money: a want saving up */
|
|
70
|
+
blockedOnMoney: number;
|
|
71
|
+
/** Thinks counted */
|
|
72
|
+
thinks: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The threat map as a computer player read it last think (`ThreatMap.cells`, on the ground, the enemy structures it
|
|
76
|
+
* remembers counted): what the game view's AI overlay draws as heat over the ground. The size of a cell, the grid's
|
|
77
|
+
* cells across and down, and each cell with something in it as `[col, row, friendly, enemy]`
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export interface ThreatReport {
|
|
82
|
+
cell: number;
|
|
83
|
+
cols: number;
|
|
84
|
+
rows: number;
|
|
85
|
+
cells: [col: number, row: number, friendly: number, enemy: number][];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* What a computer player is thinking, as plain data (`Brain.report`, `Brain.inspect`): what the debug panel's AI tab
|
|
89
|
+
* draws, and what a test reads. Each module adds its section (`AiModule.report`, `AiModule.inspect`)
|
|
90
|
+
*
|
|
91
|
+
* @beta
|
|
92
|
+
*/
|
|
93
|
+
export interface AiReport {
|
|
94
|
+
/** The version of this shape */
|
|
95
|
+
v: 1;
|
|
96
|
+
/** The brain's id (`core.melee`) */
|
|
97
|
+
brain: string;
|
|
98
|
+
/** The player it plays */
|
|
99
|
+
player: PlayerId;
|
|
100
|
+
/** The tick of its last picture of the game */
|
|
101
|
+
tick: number;
|
|
102
|
+
/** Seconds into the game, as of its last picture */
|
|
103
|
+
time: number;
|
|
104
|
+
/** Ticks a second: what turns a decision's tick into the game's time */
|
|
105
|
+
tickRate: number;
|
|
106
|
+
/** How many times it has thought */
|
|
107
|
+
thinks: number;
|
|
108
|
+
/** Whether it sits still (`world.computers.pause`) */
|
|
109
|
+
paused?: true;
|
|
110
|
+
/** What it was seated with: the data of its options (`AiOptions`: the difficulty, the numbers); code left out */
|
|
111
|
+
profile: Record<string, unknown>;
|
|
112
|
+
/** What it plays by (`Brain.profile`): the profile resolved, layer over layer; code (a flag's function) left out */
|
|
113
|
+
playing?: AiProfile;
|
|
114
|
+
/** The goal that scored highest above the minimum this think: what the army is on. None when nothing is worth doing */
|
|
115
|
+
goal?: string;
|
|
116
|
+
/** Every goal as the picker last saw it: its score, each consideration's raw and curved value, what it holds, why not */
|
|
117
|
+
goals: GoalReport[];
|
|
118
|
+
/** What it remembers of the enemy: left out by a brain that keeps no knowledge */
|
|
119
|
+
knowledge?: KnowledgeReport;
|
|
120
|
+
/** The roles it found among the types it can make: `{ worker: ['peasant'] }` */
|
|
121
|
+
roles: Record<string, string[]>;
|
|
122
|
+
/**
|
|
123
|
+
* What it has to spend and how it comes in: its resources, its income a minute, its supply; and its economy's say
|
|
124
|
+
* (`EconomyReport`): each base with its workers on each resource against what it wants and what is served, the
|
|
125
|
+
* workers that fled a raid, the workers had against wanted, where the next hall stands
|
|
126
|
+
*/
|
|
127
|
+
economy: {
|
|
128
|
+
resources: Record<string, number>;
|
|
129
|
+
income: Record<string, number>;
|
|
130
|
+
supply: [used: number, cap: number];
|
|
131
|
+
} & Partial<EconomyReport>;
|
|
132
|
+
/** The raids on its bases with what answers each, every base's raids so far, the towers it wants (`DefenceReport`) */
|
|
133
|
+
defence?: DefenceReport;
|
|
134
|
+
/** Its plan of looks with how long since each was in sight and whether it is due, its scout and where it goes (`ScoutingReport`) */
|
|
135
|
+
scouting?: ScoutingReport;
|
|
136
|
+
/** Its team: the computers of it, the requests on its board, the plan of an attack together (`TeamReport`) */
|
|
137
|
+
team?: TeamReport;
|
|
138
|
+
/** Its waves: the one whose turn it is, its group as it stands and when it may go, the waves sent (`WavesReport`) */
|
|
139
|
+
waves?: WavesReport;
|
|
140
|
+
/** Its plans: the purse (what is free, promised, held), and every want of the build plan with what it waits for */
|
|
141
|
+
plans: PlansReport;
|
|
142
|
+
/** Its squads: whose each is, its units and their strength, where it is, its task and how it goes, its last change */
|
|
143
|
+
squads: SquadReport[];
|
|
144
|
+
/** Where the strength is, as its threat map read it last think (`ThreatReport`): what the AI overlay draws as heat */
|
|
145
|
+
threat?: ThreatReport;
|
|
146
|
+
/** Its fights: each squad in one and whom it hits, the units that fled, its heroes and what each learns next, who shops for what */
|
|
147
|
+
micro?: MicroReport;
|
|
148
|
+
/** The words the game told it that no module has taken yet */
|
|
149
|
+
told: {
|
|
150
|
+
word: string;
|
|
151
|
+
tick: number;
|
|
152
|
+
}[];
|
|
153
|
+
/** Commands it sent its last think */
|
|
154
|
+
sent: number;
|
|
155
|
+
/** Commands it would have sent its last think past what its profile lets a think send (`commandsPerThink`) */
|
|
156
|
+
held?: number;
|
|
157
|
+
/** How much of a think one tick may do, where its budget slices it (`ThinkBudget`), and the ticks its last think took. Left out where a think is one tick */
|
|
158
|
+
budget?: ThinkBudgetOptions & {
|
|
159
|
+
ticks: number;
|
|
160
|
+
};
|
|
161
|
+
/** What its play adds up to since it was seated (`AiStats`): commands, idle army seconds, churn, seconds blocked on money */
|
|
162
|
+
stats: AiStats;
|
|
163
|
+
/**
|
|
164
|
+
* Milliseconds its thinks take, for reading only: the last, an average, the longest, and by module while the world
|
|
165
|
+
* profiles. Given by the seat (`inspect` of the player), which times the thinks
|
|
166
|
+
*/
|
|
167
|
+
timing?: ComputerTiming;
|
|
168
|
+
/** What it decided, the last fifty, oldest first */
|
|
169
|
+
decisions: AiDecision[];
|
|
170
|
+
/** What each module says of itself that the report has no part for (`AiModule.inspect`), under the module's id */
|
|
171
|
+
sections: Record<string, unknown>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The last fifty things a computer player decided (`Brain.decisions`, written by `ai.decide`), oldest first: kept in a
|
|
175
|
+
* save, plain data
|
|
176
|
+
*
|
|
177
|
+
* @beta
|
|
178
|
+
*/
|
|
179
|
+
export declare class Decisions {
|
|
180
|
+
private readonly limit;
|
|
181
|
+
private lines;
|
|
182
|
+
constructor(limit?: number);
|
|
183
|
+
/** Writes one down: the oldest goes once there are more than the log keeps */
|
|
184
|
+
add(decision: AiDecision): void;
|
|
185
|
+
/** What it decided, oldest first */
|
|
186
|
+
list(): readonly AiDecision[];
|
|
187
|
+
/** The last decision about a goal, or of a kind */
|
|
188
|
+
last(about: {
|
|
189
|
+
goal?: string;
|
|
190
|
+
kind?: string;
|
|
191
|
+
}): AiDecision | undefined;
|
|
192
|
+
/** For a save: a copy */
|
|
193
|
+
save(): AiDecision[];
|
|
194
|
+
/** Takes back what `save` gave: what is not a decision is passed over */
|
|
195
|
+
restore(lines: unknown): void;
|
|
196
|
+
}
|
|
197
|
+
/** A goal's considerations in one line: "its time has come 1.00 · the wave is ready 0.50", what was not asked left out */
|
|
198
|
+
export declare function considerationsLine(goal: Pick<GoalReport, 'considerations'>): string;
|
|
199
|
+
/**
|
|
200
|
+
* The consideration that held a goal back most: the one with the least curved value of those asked (a score is their
|
|
201
|
+
* product, so the least is what kept it low), and none for a goal with no considerations
|
|
202
|
+
*/
|
|
203
|
+
export declare function weakest(goal: GoalReport): GoalReport['considerations'][number] | undefined;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { type UnitTypeDef } from '#engine/defs';
|
|
2
|
+
import type { PlayerId } from '#engine/entity';
|
|
3
|
+
import type { Registry } from '#engine/registry';
|
|
4
|
+
import type { PlacementName } from './plans/placement';
|
|
5
|
+
import type { CounterHint } from './strength';
|
|
6
|
+
/**
|
|
7
|
+
* What a unit type is for, to a computer player: the engine's roles, or a word of the game's own. A type can have
|
|
8
|
+
* several (a ghoul is a `gatherer` and a `soldier`)
|
|
9
|
+
*
|
|
10
|
+
* - `worker`: gathers and builds; `gatherer`: gathers (a worker is one too); `topper`: what is put up on a deposit of
|
|
11
|
+
* the money to gather it there (`builtOn`)
|
|
12
|
+
* - `hall`: takes deposits and trains workers; `supply`: provides supply and trains nothing; `barracks`: trains
|
|
13
|
+
* soldiers; `altar`: trains or revives heroes; `workshop`: researches; `tower`: a building that attacks; `shop`:
|
|
14
|
+
* sells or hires
|
|
15
|
+
* - `soldier`: a unit that fights and is no hero; `hero`; `caster`: fights with mana; `healer`: has an ability that
|
|
16
|
+
* heals; `siege`: attacks that splash, fell or are aimed at the ground; `air`: flies; `scout`: the fastest of the
|
|
17
|
+
* soldiers; `detector`: finds the invisible
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export type AiRole = 'worker' | 'gatherer' | 'topper' | 'hall' | 'supply' | 'barracks' | 'altar' | 'workshop' | 'tower' | 'shop' | 'soldier' | 'hero' | 'caster' | 'healer' | 'siege' | 'air' | 'scout' | 'detector' | (string & {});
|
|
22
|
+
/**
|
|
23
|
+
* What a game declares of a unit type for the computer player (`UnitTypeDef.ai`), where what the kit infers from the
|
|
24
|
+
* definition is wrong or cannot be known: its roles, words of the game's own about it, what it answers, how much it
|
|
25
|
+
* is worth hitting. A declared role is in place of the inferred ones, not beside them
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export interface AiHints {
|
|
30
|
+
/** What it is for (`AiRole`), one or several: in place of what the kit would infer */
|
|
31
|
+
role?: AiRole | AiRole[];
|
|
32
|
+
/** Words of the game's own about it (`'ranged'`, `'cavalry'`), for a brain's queries (`UnitSet.withTag`). Beside the inferred ones */
|
|
33
|
+
tags?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* What it is good against: tags, roles or type ids (`['air', 'siege']`), each with a weight where a word is not enough
|
|
36
|
+
* (`{ target: 'air', weight: 1 }`). Read by the matchups (`Strength.matchup`, `odds`, `counterFor`)
|
|
37
|
+
*/
|
|
38
|
+
counters?: CounterHint[];
|
|
39
|
+
/**
|
|
40
|
+
* How strong it is at full health, in place of the kit's formula (`defaultStrength`) and of any formula the brain was
|
|
41
|
+
* given: for a type whose numbers mislead (a unit that is all spells). Scaled by the health a unit has left
|
|
42
|
+
*/
|
|
43
|
+
strength?: number;
|
|
44
|
+
/** How much it is worth hitting first, in a fight: 1 when left out. Read by the micro of C2 */
|
|
45
|
+
priority?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Where the build plan puts it (`PlacementName`): `atEdge` for a tower, `behind` for supply, `cluster` beside its
|
|
48
|
+
* own kind. Over the brain's table; the role's default when left out
|
|
49
|
+
*/
|
|
50
|
+
placement?: PlacementName;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The roles and tags of one unit type, with why (`why`: a line per inferred role, for the report; none for a declared
|
|
54
|
+
* one)
|
|
55
|
+
*
|
|
56
|
+
* @beta
|
|
57
|
+
*/
|
|
58
|
+
export interface RoleEntry {
|
|
59
|
+
roles: AiRole[];
|
|
60
|
+
tags: string[];
|
|
61
|
+
why?: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The roles and tags of every unit type of a game, by type id: what `inferRoles` gives, and what a game's own
|
|
65
|
+
* `AiOptions.roles` gives in its place
|
|
66
|
+
*
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
export type RoleTable = Record<string, RoleEntry>;
|
|
70
|
+
/**
|
|
71
|
+
* The player the roles are found for, where finding them depends on who asks (`AiOptions.roles`)
|
|
72
|
+
*
|
|
73
|
+
* @beta
|
|
74
|
+
*/
|
|
75
|
+
export interface RolesPlayer {
|
|
76
|
+
id: PlayerId;
|
|
77
|
+
/** The race it plays, where the game has races */
|
|
78
|
+
race?: string;
|
|
79
|
+
/** What the game's `available` hook decided for it, by type (`PlayerState.own.availability`) */
|
|
80
|
+
availability?: Record<string, boolean>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A game's own way of saying what unit types are for, in place of the kit's inference (`AiOptions.roles`): every type
|
|
84
|
+
* it has a role for, with its roles and tags. What is declared on a type (`UnitTypeDef.ai`) still goes over it
|
|
85
|
+
*
|
|
86
|
+
* @beta
|
|
87
|
+
*/
|
|
88
|
+
export type RolesFinder = (registry: Registry, player: RolesPlayer) => RoleTable;
|
|
89
|
+
/**
|
|
90
|
+
* Infers what every unit type of the game is for, from its definition: the rules, written down once, each with its
|
|
91
|
+
* reason (`RoleEntry.why`). What a game declares (`UnitTypeDef.ai.role`) is not looked at here: `findRoles` puts it
|
|
92
|
+
* over what is inferred
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export declare function inferRoles(registry: Registry): RoleTable;
|
|
97
|
+
/**
|
|
98
|
+
* What the unit types of a game are for (`AiView.roles`): the inferred roles (`inferRoles`, or a game's own finder
|
|
99
|
+
* in its place) with what the game declares on a type over them (`UnitTypeDef.ai`), and the queries over them
|
|
100
|
+
*
|
|
101
|
+
* @beta
|
|
102
|
+
*/
|
|
103
|
+
export declare class Roles {
|
|
104
|
+
/** Every unit type's roles and tags, by id */
|
|
105
|
+
readonly table: RoleTable;
|
|
106
|
+
private readonly registry;
|
|
107
|
+
private readonly byRole;
|
|
108
|
+
private readonly byTag;
|
|
109
|
+
constructor(
|
|
110
|
+
/** Every unit type's roles and tags, by id */
|
|
111
|
+
table: RoleTable, registry: Registry);
|
|
112
|
+
/** The roles of a unit type: none for one that has none, or is not a unit type at all */
|
|
113
|
+
of(type: string): readonly AiRole[];
|
|
114
|
+
/** Whether a unit type has a role */
|
|
115
|
+
has(type: string, role: AiRole): boolean;
|
|
116
|
+
/** The tags of a unit type: the kit's (`ranged`, `melee`, `hitsAir`) and the game's (`UnitTypeDef.ai.tags`) */
|
|
117
|
+
tags(type: string): readonly string[];
|
|
118
|
+
/** Whether a unit type has a tag */
|
|
119
|
+
hasTag(type: string, tag: string): boolean;
|
|
120
|
+
/** The unit types with a role, in the game's order (the first of a kind is the one meant first) */
|
|
121
|
+
types(role: AiRole): readonly UnitTypeDef[];
|
|
122
|
+
/** The unit types with a tag, in the game's order */
|
|
123
|
+
tagged(tag: string): readonly UnitTypeDef[];
|
|
124
|
+
/** What a game declared of a type (`UnitTypeDef.ai`): nothing where it declared nothing */
|
|
125
|
+
hints(type: string): AiHints | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Why a type has the roles it has, in words, for the report: `declared: worker` for what the game said, a line per
|
|
128
|
+
* inferred role otherwise
|
|
129
|
+
*/
|
|
130
|
+
explain(type: string): string;
|
|
131
|
+
/** Every role and the types that have it, for the report (the debug tools) */
|
|
132
|
+
report(): Record<string, string[]>;
|
|
133
|
+
}
|