@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,280 @@
|
|
|
1
|
+
import { type Cost, type UnitTypeDef } from '#engine/defs';
|
|
2
|
+
import { type Vec2 } from '#engine/math';
|
|
3
|
+
import type { EntityState } from '#engine/session/protocol';
|
|
4
|
+
import { type Brain } from '#engine/ai/brain';
|
|
5
|
+
import { type AiModuleDef } from '#engine/ai/module';
|
|
6
|
+
import { type AiCondition, type AiConditionData } from '#engine/ai/rules';
|
|
7
|
+
import { type PlacementName, type PlacementStrategy, type PlacementTable, type SiteRequest } from './placement';
|
|
8
|
+
import { type TechPath, type TechStep } from './tech';
|
|
9
|
+
/**
|
|
10
|
+
* Something a computer player wants built or trained, as plain data (a map's file, a rule's action, a seat's
|
|
11
|
+
* options): a type, how many, under what condition, where, how important. `WantData` is what a save keeps; `Want`
|
|
12
|
+
* is the same with the function forms
|
|
13
|
+
*
|
|
14
|
+
* @beta
|
|
15
|
+
*/
|
|
16
|
+
export interface WantData {
|
|
17
|
+
/** Its name: what the memory, the report and `drop` know it by. Made up when left out */
|
|
18
|
+
id?: string;
|
|
19
|
+
/** The unit type wanted: a building, or a unit (whose buildings the plan puts up; the production plan trains it) */
|
|
20
|
+
type: string;
|
|
21
|
+
/** How many of it to have, those on their way counted: 1 when left out */
|
|
22
|
+
count?: number;
|
|
23
|
+
/** Only while this holds (`AiConditionData`, as a rule's): a tower after the first attack, a second hall past five minutes */
|
|
24
|
+
when?: AiConditionData;
|
|
25
|
+
/** Where: a point, or the name of an entity the map or rules named. Home when left out */
|
|
26
|
+
near?: Vec2 | string;
|
|
27
|
+
/** How far from there at the most: 22 when left out */
|
|
28
|
+
within?: number;
|
|
29
|
+
/** How its spot is chosen (`PlacementName`): what the type declares, the brain's table, or the role's default when left out */
|
|
30
|
+
placement?: PlacementName;
|
|
31
|
+
/** Wants are taken most important first, and the most important one that cannot be paid for saves up: 0 when left out */
|
|
32
|
+
priority?: number;
|
|
33
|
+
/** Money to have left over after paying for it: a luxury that waits for gold to spare. 0 when left out */
|
|
34
|
+
spare?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the want stands: kept once met, and short again when what it made is lost, so that it is built anew.
|
|
37
|
+
* Wants of a brain's or a seat's options stand; one added as the game goes is dropped once met, unless it says so
|
|
38
|
+
*/
|
|
39
|
+
keep?: boolean;
|
|
40
|
+
/** For a standing want: whether a building lost is built again (the plan's `rebuild` when left out) */
|
|
41
|
+
rebuild?: boolean;
|
|
42
|
+
/** Seconds without a spot for it before a want that does not stand is given up: the plan's `siteTimeout` when left out */
|
|
43
|
+
siteTimeout?: number;
|
|
44
|
+
/** Who wants it, for the report: `order`, `production`, `economy`, a goal's or a rule's id */
|
|
45
|
+
by?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A want with the function forms: how many as a function of the brain, a condition as code, a place found each think,
|
|
49
|
+
* a placement strategy of the game's own (`ai.plans.want`, `BuildPlanOptions.wants`)
|
|
50
|
+
*
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
export interface Want extends Omit<WantData, 'count' | 'when' | 'near' | 'placement'> {
|
|
54
|
+
count?: number | ((ai: Brain) => number);
|
|
55
|
+
when?: AiCondition;
|
|
56
|
+
near?: Vec2 | string | ((ai: Brain) => Vec2 | undefined);
|
|
57
|
+
placement?: PlacementName | PlacementStrategy;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* How the build plan goes about it (`BrainDef.plans.build`, the `build()` module; the data of it in `AiOptions`)
|
|
61
|
+
*
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export interface BuildPlanOptions {
|
|
65
|
+
/** Standing wants: what the brain always has, built anew when lost */
|
|
66
|
+
wants?: Want[];
|
|
67
|
+
/** How each type's spot is chosen, by type id or by role: a name or a function. What a type declares (`UnitTypeDef.ai.placement`) goes over it */
|
|
68
|
+
placement?: PlacementTable;
|
|
69
|
+
/** Whether a building lost is built again, for standing wants that do not say: yes when left out */
|
|
70
|
+
rebuild?: boolean;
|
|
71
|
+
/** Whether a worker is sent to mend a damaged building when no enemy reaches it: yes when left out */
|
|
72
|
+
repair?: boolean;
|
|
73
|
+
/** Seconds without a spot before a want that does not stand is given up: 60 when left out */
|
|
74
|
+
siteTimeout?: number;
|
|
75
|
+
/** How far from home a building goes at the most, where a want does not say: 22 when left out */
|
|
76
|
+
within?: number;
|
|
77
|
+
}
|
|
78
|
+
/** What the plan remembers of a want between thinks */
|
|
79
|
+
interface WantMemory {
|
|
80
|
+
/** The tick it was added at */
|
|
81
|
+
since: number;
|
|
82
|
+
/** Its place among the wants: among equals in priority, the first added goes first. Kept, so a loaded game ranks alike */
|
|
83
|
+
order: number;
|
|
84
|
+
/** How many of its type the plan started for it */
|
|
85
|
+
made: number;
|
|
86
|
+
/** A standing want met once and not to be built anew */
|
|
87
|
+
satisfied?: true;
|
|
88
|
+
/** The tick since which no spot was found for it */
|
|
89
|
+
noSite?: number;
|
|
90
|
+
/** The worker sent to look at the ground where it goes */
|
|
91
|
+
settler?: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What the build plan remembers between thinks, for a save: each want's memory, and the wants added as the game went
|
|
95
|
+
* that are plain data (a rule's), to have them again
|
|
96
|
+
*
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
export interface BuildPlanMemory {
|
|
100
|
+
v: 1;
|
|
101
|
+
wants: {
|
|
102
|
+
id: string;
|
|
103
|
+
memory: WantMemory;
|
|
104
|
+
data?: WantData;
|
|
105
|
+
}[];
|
|
106
|
+
/** The order the next want added gets: kept, so that a loaded game ranks the wants it adds as the game saved did */
|
|
107
|
+
added?: number;
|
|
108
|
+
/** The want saving up as of the last think (`savingFor`): what a loaded game reads until it thinks again */
|
|
109
|
+
saving?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* One want as the report shows it: what it is, how far along, what it waits for (`status`), the steps to it, what it
|
|
113
|
+
* holds in the purse
|
|
114
|
+
*
|
|
115
|
+
* @beta
|
|
116
|
+
*/
|
|
117
|
+
export interface WantReport {
|
|
118
|
+
id: string;
|
|
119
|
+
type: string;
|
|
120
|
+
count: number;
|
|
121
|
+
have: number;
|
|
122
|
+
onItsWay: number;
|
|
123
|
+
priority: number;
|
|
124
|
+
by?: string;
|
|
125
|
+
keep?: true;
|
|
126
|
+
status: string;
|
|
127
|
+
steps: string[];
|
|
128
|
+
holds?: Cost;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The build plan as the report shows it: its wants, and which one saves up
|
|
132
|
+
*
|
|
133
|
+
* @beta
|
|
134
|
+
*/
|
|
135
|
+
export interface BuildPlanReport {
|
|
136
|
+
wants: WantReport[];
|
|
137
|
+
saving?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The brain's build plan (`ai.plans.build`): its wants, the steps to each, the spots, the builders, the purse. Add a
|
|
141
|
+
* want with `want`, read where each stands with `report`, and let `think` act on them once a think
|
|
142
|
+
*
|
|
143
|
+
* @beta
|
|
144
|
+
*/
|
|
145
|
+
export declare class BuildPlan {
|
|
146
|
+
/** The brain it plans for */
|
|
147
|
+
readonly ai: Brain;
|
|
148
|
+
private options;
|
|
149
|
+
private readonly wants;
|
|
150
|
+
/** Memory of wants a save remembers that no module has asked for yet: given to them as they come */
|
|
151
|
+
private pending;
|
|
152
|
+
private added;
|
|
153
|
+
private thoughtAt;
|
|
154
|
+
private paths;
|
|
155
|
+
/** What is on its way, by type, worked out once a think: asked for every want and every step */
|
|
156
|
+
private onWay;
|
|
157
|
+
/** The builders sent this think: not sent twice */
|
|
158
|
+
private sent;
|
|
159
|
+
/** The want saving up this think, if one is */
|
|
160
|
+
private saving;
|
|
161
|
+
private warned;
|
|
162
|
+
constructor(
|
|
163
|
+
/** The brain it plans for */
|
|
164
|
+
ai: Brain, options?: BuildPlanOptions);
|
|
165
|
+
/** Takes options in, over what it had: the standing wants added, the table of placements merged, the flags replaced */
|
|
166
|
+
configure(options: BuildPlanOptions): void;
|
|
167
|
+
/** The plan's options as they stand */
|
|
168
|
+
get settings(): Readonly<BuildPlanOptions>;
|
|
169
|
+
/**
|
|
170
|
+
* Adds a want, or replaces one of the same id (its memory kept): what the plan works towards from now. Gives back
|
|
171
|
+
* its id. A want with no `keep` is dropped once met
|
|
172
|
+
*/
|
|
173
|
+
want(def: Want): string;
|
|
174
|
+
/** Takes a want out, and what a save remembered of it: whether there was one */
|
|
175
|
+
drop(id: string): boolean;
|
|
176
|
+
/** A want by id */
|
|
177
|
+
get(id: string): Want | undefined;
|
|
178
|
+
/** The wants, in the order added */
|
|
179
|
+
list(): Want[];
|
|
180
|
+
/** Where a want stands, in words, as of the last think: `building a barracks at (40, 60)`, `saving for a town hall` */
|
|
181
|
+
status(id: string): string | undefined;
|
|
182
|
+
/** The want saving up, as of the last think: the most important one it could not pay for */
|
|
183
|
+
get savingFor(): string | undefined;
|
|
184
|
+
/** How many of a type the player has, those under construction and those that count as it included */
|
|
185
|
+
have(type: string): number;
|
|
186
|
+
/** How many of a type are on their way beyond those that stand: builders sent to build one, buildings turning into one, units queued */
|
|
187
|
+
onItsWay(type: string): number;
|
|
188
|
+
/** Whether a type is had or on its way: standing (finished or not), or a builder or a morph on the way to it */
|
|
189
|
+
private had;
|
|
190
|
+
/** The steps to being able to make a type (`techPath`), worked out once a think */
|
|
191
|
+
path(type: string): TechPath;
|
|
192
|
+
/** The first step towards a type not had yet, the type's own last: none when nothing is to be done, or the path is blocked */
|
|
193
|
+
next(type: string): TechStep | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* The think, once a think: every want measured against what stands and is on its way (met ones dropped, or kept
|
|
196
|
+
* standing), those whose condition holds taken most important first, each advanced by the first step it can take:
|
|
197
|
+
* built, turned into, or saved for. Then the mending, where the plan is to
|
|
198
|
+
*/
|
|
199
|
+
think(): void;
|
|
200
|
+
/** One want, one think: the steps to it, and the first one it can take */
|
|
201
|
+
private advance;
|
|
202
|
+
/** Takes a step for a want, where it can: what came of it, in words, for the status */
|
|
203
|
+
private act;
|
|
204
|
+
/**
|
|
205
|
+
* Pays for a step out of the purse, with the want's `spare` left over, as important as the want is (what less
|
|
206
|
+
* important wants and modules hold is its to spend); where it cannot, the most important want that could not pay
|
|
207
|
+
* holds the money (one at a time), and what is less important waits
|
|
208
|
+
*/
|
|
209
|
+
private pay;
|
|
210
|
+
/** Whether a want can pay for a step now (nothing spent); where it cannot, it may hold the money (`pay`) */
|
|
211
|
+
private canPay;
|
|
212
|
+
/** A step not paid for, in words: the want holds the money (saving), waits for money to spare (a luxury), or waits for the money */
|
|
213
|
+
private short;
|
|
214
|
+
/** No spot found this think: for a want that does not stand, given up after `siteTimeout` seconds, and said */
|
|
215
|
+
private noSite;
|
|
216
|
+
/** Where a want says it goes, as a point: a point, a named entity it knows of, or what its function gives. Nothing for home */
|
|
217
|
+
private placeOf;
|
|
218
|
+
/** A spot for a type: where the want says, no further than it says, by its strategy; near home for a step on the way */
|
|
219
|
+
private siteFor;
|
|
220
|
+
/**
|
|
221
|
+
* A spot for a type near a place, by a strategy: the one given, else what the type declares (`UnitTypeDef.ai.placement`),
|
|
222
|
+
* the plan's table by type then by role, the role's default, the rings around the place. What is built on a
|
|
223
|
+
* deposit goes on one whatever the name
|
|
224
|
+
*/
|
|
225
|
+
site(type: UnitTypeDef, request: Omit<SiteRequest, 'ordinal'> & {
|
|
226
|
+
ordinal?: number;
|
|
227
|
+
}, placement?: PlacementName | PlacementStrategy): Vec2 | undefined;
|
|
228
|
+
private strategyFor;
|
|
229
|
+
/** The workers sent to look at the ground somewhere, by any want: not builders while they go */
|
|
230
|
+
private settlers;
|
|
231
|
+
/**
|
|
232
|
+
* Who builds a type at a spot: of the player's units that build it, those not hidden, not building, not sent this
|
|
233
|
+
* think, not off to look at ground and not in a squad or held by a rule; idle first, then whoever carries the least,
|
|
234
|
+
* then the nearest
|
|
235
|
+
*/
|
|
236
|
+
builderFor(type: UnitTypeDef, site: Vec2): EntityState | undefined;
|
|
237
|
+
/** Where a settler stands to see a place: on its near side, towards home, so that it sees where the building would stand and not the mine alone */
|
|
238
|
+
private settlePoint;
|
|
239
|
+
/**
|
|
240
|
+
* A worker sent to where a want goes, to see the ground: one at a time for the want, sent again if it was taken off
|
|
241
|
+
* it. To the near side of the place, towards home (`settlePoint`)
|
|
242
|
+
*/
|
|
243
|
+
private sendSettler;
|
|
244
|
+
/**
|
|
245
|
+
* Builds a type now, outside any want: a spot near a place (home when left out), a builder, the purse. What a
|
|
246
|
+
* module does for a one-off (the melee player's building on a mine). Whether it was sent
|
|
247
|
+
*/
|
|
248
|
+
build(type: UnitTypeDef | string, options?: {
|
|
249
|
+
near?: Vec2;
|
|
250
|
+
within?: number;
|
|
251
|
+
placement?: PlacementName | PlacementStrategy;
|
|
252
|
+
spare?: number;
|
|
253
|
+
by?: string;
|
|
254
|
+
}): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Mends: a worker sent to a damaged building of the player's that no enemy strength reaches, one a think, when
|
|
257
|
+
* the purse has what the mending will cost (`GameRules.economy.repairCost` of what is missing). Not one being mended already
|
|
258
|
+
*/
|
|
259
|
+
private mend;
|
|
260
|
+
/** The wants in the order they were added: what the report and a save list them in, the same in a loaded game */
|
|
261
|
+
private ordered;
|
|
262
|
+
/** Every want as the last think left it, in the order added, the one saving up named */
|
|
263
|
+
report(): BuildPlanReport;
|
|
264
|
+
/**
|
|
265
|
+
* What it remembers, for a save: each standing want's memory (its code gives the want again), and the wants added
|
|
266
|
+
* as the game went that are plain data, whole. A want that does not stand and has code in it is not kept: the
|
|
267
|
+
* game loaded from the save would not know when the game saved from would have dropped it
|
|
268
|
+
*/
|
|
269
|
+
save(): BuildPlanMemory;
|
|
270
|
+
/** Takes back what `save` gave: whether it was read. The data wants are had again; memory waits for the wants code adds */
|
|
271
|
+
restore(memory: unknown): boolean;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The build module: runs the brain's build plan (`ai.plans.build.think()`) in its place among a brain's modules, after
|
|
275
|
+
* what adds wants (rules, goals) and before what gives idle workers something else to do. With options for the plan
|
|
276
|
+
*
|
|
277
|
+
* @beta
|
|
278
|
+
*/
|
|
279
|
+
export declare const build: (options?: BuildPlanOptions) => AiModuleDef;
|
|
280
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type UnitTypeDef } from '#engine/defs';
|
|
2
|
+
import { type Vec2 } from '#engine/math';
|
|
3
|
+
import type { Brain } from '#engine/ai/brain';
|
|
4
|
+
/**
|
|
5
|
+
* Where a type is wanted: near a place, no further than `within`, and which of its kind this is (`ordinal`, so that
|
|
6
|
+
* two farms do not try the same corner first)
|
|
7
|
+
*
|
|
8
|
+
* @beta
|
|
9
|
+
*/
|
|
10
|
+
export interface SiteRequest {
|
|
11
|
+
near: Vec2;
|
|
12
|
+
within: number;
|
|
13
|
+
ordinal: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A way of finding a spot for a building: the kit's by name, or a function of the game's own. Nothing (`undefined`)
|
|
17
|
+
* when there is no spot it likes
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
21
|
+
export type PlacementStrategy = (ai: Brain, type: UnitTypeDef, site: SiteRequest) => Vec2 | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* The kit's placement strategies, by name: `nearHome` (rings around the place, keeping the way to the mine clear),
|
|
24
|
+
* `byResource` (on the nearest deposit it is built on: a mine), `atEdge` (at the edge of the base towards the enemy,
|
|
25
|
+
* for a tower), `behind` (away from the enemy, for supply), `cluster` (beside another of its type, barracks by
|
|
26
|
+
* barracks; `cluster:<type>` beside another type), `onLayer:<layer>` (where the whole footprint is on a layer of cells
|
|
27
|
+
* the game paints: `onLayer:blight` for a race that builds on blight)
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
31
|
+
export type PlacementName = 'nearHome' | 'byResource' | 'atEdge' | 'behind' | 'cluster' | `cluster:${string}` | `onLayer:${string}`;
|
|
32
|
+
/**
|
|
33
|
+
* Which strategy a type goes by (`AiOptions.placement`, `BuildPlanOptions.placement`): by type id or by role, a name
|
|
34
|
+
* or a function
|
|
35
|
+
*
|
|
36
|
+
* @beta
|
|
37
|
+
*/
|
|
38
|
+
export type PlacementTable = Record<string, PlacementName | PlacementStrategy>;
|
|
39
|
+
/**
|
|
40
|
+
* The rings around a place, walked out from `from` to `within` (then in from `from` to the nearest ring where `inward`),
|
|
41
|
+
* each at so many angles; the first point that stands clear and that `accept` likes. Deterministic, but not the same
|
|
42
|
+
* corner for every building: the angles start where `ordinal` says
|
|
43
|
+
*
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
export declare function rings(ai: Brain, type: UnitTypeDef, centre: Vec2, options: {
|
|
47
|
+
from?: number;
|
|
48
|
+
within: number;
|
|
49
|
+
ordinal?: number;
|
|
50
|
+
inward?: boolean;
|
|
51
|
+
accept?: (point: Vec2) => boolean;
|
|
52
|
+
}): Vec2 | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Which way the enemy is from a place, as a unit vector: towards the nearest of their bases it knows of, else the
|
|
55
|
+
* nearest base the seat was told of (`AiOptions.enemyBases`), else towards the strongest enemy reaching its own
|
|
56
|
+
* (`threat.hot`). Nothing where it has no idea
|
|
57
|
+
*
|
|
58
|
+
* @beta
|
|
59
|
+
*/
|
|
60
|
+
export declare function enemyDirection(ai: Brain, from: Vec2): Vec2 | undefined;
|
|
61
|
+
/** Beside another of a type (its own when none is named): barracks by barracks. Rings around home where there is none yet */
|
|
62
|
+
declare const cluster: (type?: string) => PlacementStrategy;
|
|
63
|
+
/**
|
|
64
|
+
* On a layer of cells, the whole footprint (`onLayer:<layer>`): the rings around the place, the way to the mine kept
|
|
65
|
+
* clear, then the layer's painted cells nearest the place where the rings find none (a scan of the layer, only then).
|
|
66
|
+
* Nothing where the layer is painted nowhere near
|
|
67
|
+
*/
|
|
68
|
+
declare const onLayer: (layer: string) => PlacementStrategy;
|
|
69
|
+
/**
|
|
70
|
+
* The kit's placement strategies, by name (`PlacementName`), for a game that wants to call or wrap one
|
|
71
|
+
*
|
|
72
|
+
* @beta
|
|
73
|
+
*/
|
|
74
|
+
export declare const placements: {
|
|
75
|
+
readonly nearHome: PlacementStrategy;
|
|
76
|
+
readonly byResource: PlacementStrategy;
|
|
77
|
+
readonly atEdge: PlacementStrategy;
|
|
78
|
+
readonly behind: PlacementStrategy;
|
|
79
|
+
readonly cluster: typeof cluster;
|
|
80
|
+
readonly onLayer: typeof onLayer;
|
|
81
|
+
};
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Brain } from '#engine/ai/brain';
|
|
2
|
+
import type { AiArea } from '#engine/ai/area';
|
|
3
|
+
import { BuildPlan, type BuildPlanMemory, type BuildPlanOptions, type BuildPlanReport, type Want } from './build';
|
|
4
|
+
import { ProductionPlan, type ProductionPlanMemory, type ProductionPlanOptions, type ProductionPlanReport } from './production';
|
|
5
|
+
import type { PurseReport } from './purse';
|
|
6
|
+
/**
|
|
7
|
+
* One item of a build order: a type to have (one of it), or a type and how many. Counts of a type add up along the order
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export type BuildOrderItem = string | {
|
|
12
|
+
type: string;
|
|
13
|
+
count?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* How a brain plans (`BrainDef.plans`): the build plan's options, the production plan's, the build order
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export interface PlansOptions {
|
|
21
|
+
build?: BuildPlanOptions;
|
|
22
|
+
production?: ProductionPlanOptions;
|
|
23
|
+
/**
|
|
24
|
+
* What to have first, in order (`BuildOrderItem`): each item waits for the one before, and nothing else the
|
|
25
|
+
* computer would make of itself is made meanwhile (`following`); what it works out for itself once done. The
|
|
26
|
+
* seat's `AiOptions.buildOrder`
|
|
27
|
+
*/
|
|
28
|
+
order?: BuildOrderItem[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What the plans remember between thinks, for a save
|
|
32
|
+
*
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export interface PlansMemory {
|
|
36
|
+
v: 1;
|
|
37
|
+
build?: BuildPlanMemory;
|
|
38
|
+
production?: ProductionPlanMemory;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The plans as the report shows them: the purse, and each plan's part
|
|
42
|
+
*
|
|
43
|
+
* @beta
|
|
44
|
+
*/
|
|
45
|
+
export interface PlansReport {
|
|
46
|
+
purse: PurseReport;
|
|
47
|
+
build: BuildPlanReport;
|
|
48
|
+
production: ProductionPlanReport;
|
|
49
|
+
/** The build order's next item, while it is being followed */
|
|
50
|
+
order?: {
|
|
51
|
+
type: string;
|
|
52
|
+
count: number;
|
|
53
|
+
item: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A brain's plans (`ai.plans`): `build` for what is to be built, `production` for what is to be trained and
|
|
58
|
+
* researched, the game's build `order` over both. `want` is the one door: a want of a building goes to the build
|
|
59
|
+
* plan; one of a unit goes to the build plan for its buildings, and the production plan trains it
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
export declare class Plans implements AiArea {
|
|
64
|
+
/** The brain they plan for */
|
|
65
|
+
readonly ai: Brain;
|
|
66
|
+
/** Its id among the brain's areas: what its memory and its report are kept under */
|
|
67
|
+
readonly id = "plans";
|
|
68
|
+
/** What the log says where a save's memory of it is of a shape it does not read */
|
|
69
|
+
readonly afresh = "the save remembers what the computer player planned in a shape this brain does not read: it plans afresh";
|
|
70
|
+
/** What to build, and the steps to it */
|
|
71
|
+
readonly build: BuildPlan;
|
|
72
|
+
/** What to train and research */
|
|
73
|
+
readonly production: ProductionPlan;
|
|
74
|
+
private readonly order;
|
|
75
|
+
private followedAt;
|
|
76
|
+
private next;
|
|
77
|
+
constructor(
|
|
78
|
+
/** The brain they plan for */
|
|
79
|
+
ai: Brain, options?: PlansOptions);
|
|
80
|
+
/** Adds a want: what the brain works towards from now (`BuildPlan.want`). Gives back its id */
|
|
81
|
+
want(def: Want): string;
|
|
82
|
+
/**
|
|
83
|
+
* Works on the game's build order, once a think: the first item not had (what stands, is on its way or is queued
|
|
84
|
+
* counted; counts of a type adding up along the order) is a want before all others (`order`, priority 1000), and
|
|
85
|
+
* `following` is true. Called by the build plan as it thinks; a module may call it sooner
|
|
86
|
+
*/
|
|
87
|
+
follow(): PlansReport['order'] | undefined;
|
|
88
|
+
/** Whether the game's build order is still being followed: what the computer would make of itself waits */
|
|
89
|
+
get following(): boolean;
|
|
90
|
+
/** Takes a want out, by id */
|
|
91
|
+
drop(id: string): boolean;
|
|
92
|
+
/** The purse and each plan's part, for the report */
|
|
93
|
+
report(): PlansReport;
|
|
94
|
+
/** What the plans remember, for a save */
|
|
95
|
+
/** Whether it has anything to remember now: one that does not is left out of a save */
|
|
96
|
+
remembers(): boolean;
|
|
97
|
+
save(): PlansMemory;
|
|
98
|
+
/** Takes back what `save` gave: whether it was read */
|
|
99
|
+
restore(memory: unknown): boolean;
|
|
100
|
+
}
|
|
101
|
+
declare module '#engine/ai/area' {
|
|
102
|
+
interface AreaMemories {
|
|
103
|
+
plans?: PlansMemory;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { UnitTypeDef, UpgradeDef } from '#engine/defs';
|
|
2
|
+
import type { EntityState } from '#engine/session/protocol';
|
|
3
|
+
import { type Brain } from '#engine/ai/brain';
|
|
4
|
+
import { type AiModuleDef } from '#engine/ai/module';
|
|
5
|
+
import type { Want } from './build';
|
|
6
|
+
/**
|
|
7
|
+
* The army a computer player wants, as shares by unit type id or tag (the kit's `ranged`, `melee`, `hitsAir`, a
|
|
8
|
+
* game's own): `{ footman: 2, rifleman: 1 }` is two footmen to a rifleman. A tag's share is split among the types
|
|
9
|
+
* that have it; a type named gets its own beside. Types it cannot train yet are left out until it can
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type Composition = Record<string, number>;
|
|
14
|
+
/**
|
|
15
|
+
* How the production plan goes about it (`BrainDef.plans.production`, the `production()` module; the data of it in
|
|
16
|
+
* `AiOptions.composition` and `research`)
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export interface ProductionPlanOptions {
|
|
21
|
+
/** The army it wants (`Composition`), or a function of the brain giving it. Even shares of every soldier type it can train when left out */
|
|
22
|
+
composition?: Composition | ((ai: Brain) => Composition);
|
|
23
|
+
/**
|
|
24
|
+
* How much what answers the enemy's army seen pulls the shares about: 0 not at all, 1 (left out) as much as a
|
|
25
|
+
* share; a type that cannot hit what they field is not trained while they field it
|
|
26
|
+
*/
|
|
27
|
+
counters?: number;
|
|
28
|
+
/** Whether it trains soldiers at all: yes when left out. Workers and heroes are the economy's and the hero module's */
|
|
29
|
+
train?: boolean;
|
|
30
|
+
/** How many may queue at one building: 2 when left out */
|
|
31
|
+
queue?: number;
|
|
32
|
+
/** Whether to want one more of what provides supply when what it would train next does not fit: yes when left out */
|
|
33
|
+
supplyAhead?: boolean;
|
|
34
|
+
/** Supply to keep free beyond the next unit's, so that the farm is up before it is needed: 4 when left out */
|
|
35
|
+
supplyMargin?: number;
|
|
36
|
+
/** Upgrades to research, in order, by id (the first it can is next), or a function of the brain giving the next; what the army it has uses most when left out */
|
|
37
|
+
research?: string[] | ((ai: Brain) => string | undefined);
|
|
38
|
+
/** Money to have left over before researching: 200 when left out (research is a luxury) */
|
|
39
|
+
researchSpare?: number;
|
|
40
|
+
/** How important training and research are to the purse (`Purse`): 0 when left out, under every want that saves */
|
|
41
|
+
priority?: number;
|
|
42
|
+
/**
|
|
43
|
+
* The tier of the game's upkeep (`GameModule.upkeep`: 0 none, 1 the first) the composition trains no further into:
|
|
44
|
+
* a soldier that would take the supply used past it waits, and no supply is wanted past it, unless the money would
|
|
45
|
+
* lie idle (`upkeepSpare`). What is wanted outright (a wave's, a build order's) is trained all the same. `UPKEEP_TIER`
|
|
46
|
+
* (1) when left out; `false` reads no upkeep
|
|
47
|
+
*/
|
|
48
|
+
upkeepTier?: number | false;
|
|
49
|
+
/** Money free past which upkeep is not read (it would lie idle else): `UPKEEP_SPARE` (600) when left out */
|
|
50
|
+
upkeepSpare?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The tier of upkeep the production plan trains no further into where its options say none (`upkeepTier`)
|
|
54
|
+
*
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
export declare const UPKEEP_TIER = 1;
|
|
58
|
+
/**
|
|
59
|
+
* The money free past which the production plan reads no upkeep: what would lie idle else (`upkeepSpare`)
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
export declare const UPKEEP_SPARE = 600;
|
|
64
|
+
/**
|
|
65
|
+
* One type as the production plan weighs it, for the report: its share of the army wanted (`target`, 0..1), its share
|
|
66
|
+
* now (`share`), how well it answers their army (`counter`: 1 is as good as against anyone), and what the two come
|
|
67
|
+
* to (`urge`: the most urgent is trained next)
|
|
68
|
+
*
|
|
69
|
+
* @beta
|
|
70
|
+
*/
|
|
71
|
+
export interface CompositionReport {
|
|
72
|
+
type: string;
|
|
73
|
+
target: number;
|
|
74
|
+
have: number;
|
|
75
|
+
share: number;
|
|
76
|
+
counter: number;
|
|
77
|
+
urge: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The production plan as the report shows it: the composition as weighed, what it trained and researched this
|
|
81
|
+
* think, the unit wants it trains towards, and why it did not train where it did not
|
|
82
|
+
*
|
|
83
|
+
* @beta
|
|
84
|
+
*/
|
|
85
|
+
export interface ProductionPlanReport {
|
|
86
|
+
composition: CompositionReport[];
|
|
87
|
+
trained: string[];
|
|
88
|
+
researched: string[];
|
|
89
|
+
wants: string[];
|
|
90
|
+
status: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What the production plan remembers between thinks, for a save: what its want of supply was set with
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
96
|
+
*/
|
|
97
|
+
export interface ProductionPlanMemory {
|
|
98
|
+
supply?: {
|
|
99
|
+
type: string;
|
|
100
|
+
need: number;
|
|
101
|
+
most?: number;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The brain's production plan (`ai.plans.production`): what it trains and researches, by the wants of units, the
|
|
106
|
+
* composition and the counters, with supply kept ahead. `train` and `research` are the primitives any module uses
|
|
107
|
+
* to queue something through the purse; `think` runs the plan once a think
|
|
108
|
+
*
|
|
109
|
+
* @beta
|
|
110
|
+
*/
|
|
111
|
+
export declare class ProductionPlan {
|
|
112
|
+
/** The brain it plans for */
|
|
113
|
+
readonly ai: Brain;
|
|
114
|
+
private options;
|
|
115
|
+
private thoughtAt;
|
|
116
|
+
private trained;
|
|
117
|
+
private researched;
|
|
118
|
+
private status;
|
|
119
|
+
private weighed;
|
|
120
|
+
private wantedNow;
|
|
121
|
+
/** What the supply want was last set with (`supplyAhead`): kept in a save, for a loaded game to have it again */
|
|
122
|
+
private supply;
|
|
123
|
+
constructor(
|
|
124
|
+
/** The brain it plans for */
|
|
125
|
+
ai: Brain, options?: ProductionPlanOptions);
|
|
126
|
+
/** Takes options in, over what it had */
|
|
127
|
+
configure(options: ProductionPlanOptions): void;
|
|
128
|
+
/** The plan's options as they stand */
|
|
129
|
+
get settings(): Readonly<ProductionPlanOptions>;
|
|
130
|
+
/** Whether the player may make a type or research an upgrade (`key`: `upgrade:<id>`), as its race and the game's `available` hook say */
|
|
131
|
+
private may;
|
|
132
|
+
/** How many of a unit type the player's buildings are training */
|
|
133
|
+
queued(type: string): number;
|
|
134
|
+
/**
|
|
135
|
+
* Trains a unit at a building, when it fits the supply, the queue has room and the purse allows: whether it was
|
|
136
|
+
* sent. The supply used is bumped on the view's `me` at once, so that the next call this think does not queue past
|
|
137
|
+
* the cap before the command lands. What the economy, the hero module and this plan all train through
|
|
138
|
+
*/
|
|
139
|
+
train(building: EntityState, type: UnitTypeDef, priority?: number): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Researches an upgrade at a building, when it is not researching already, the building's queue has room and the
|
|
142
|
+
* purse allows with `spare` left over: whether it was sent. `me.researching` is bumped at once
|
|
143
|
+
*/
|
|
144
|
+
research(building: EntityState, upgrade: UpgradeDef, spare?: number, priority?: number): boolean;
|
|
145
|
+
/** Whether an upgrade can be researched now: a level left, not under way, the player's to make, what the next level requires standing */
|
|
146
|
+
researchable(upgrade: UpgradeDef): boolean;
|
|
147
|
+
/** The soldier types the player can train now: at a finished building of its own, their requirements standing */
|
|
148
|
+
trainable(): UnitTypeDef[];
|
|
149
|
+
/** The army's composition wanted, as given: the function asked, the data as it is */
|
|
150
|
+
private composition;
|
|
151
|
+
/**
|
|
152
|
+
* The composition as weighed this think, for the types it can train: each type's share wanted (the composition's
|
|
153
|
+
* for its id, or for a tag or role where no type has that id, split among the types that have it; even when there is no composition), its
|
|
154
|
+
* share of the soldiers now, how well it answers the enemy's army seen, and its urge: `target × (1 + counters ×
|
|
155
|
+
* (counter − 1)) − share`. The most urgent is trained first
|
|
156
|
+
*/
|
|
157
|
+
weigh(): CompositionReport[];
|
|
158
|
+
/** How well each type answers the most of each enemy unit type seen at once (`Strength.counterFor`): 1 for each where nothing was seen */
|
|
159
|
+
private counters;
|
|
160
|
+
/** The unit wants the build plan holds that are to be trained now (their buildings up), most important first; the order's alone while it is followed */
|
|
161
|
+
wanted(): Want[];
|
|
162
|
+
/** The finished buildings of the player's that train a type, with room in their queue */
|
|
163
|
+
private trainersOf;
|
|
164
|
+
/**
|
|
165
|
+
* The think, once a think: the unit wants first (each at a building that trains it, as many as wanted), then the
|
|
166
|
+
* composition's most urgent type at every building with room, as the supply, the queue and the purse allow; one
|
|
167
|
+
* more of what provides supply wanted when the next does not fit; then the research
|
|
168
|
+
*/
|
|
169
|
+
think(): void;
|
|
170
|
+
/**
|
|
171
|
+
* The supply used the composition trains no further than for upkeep (`upkeepTier`): where the tier after the one it
|
|
172
|
+
* may be in begins. None in a game without upkeep, past its last tier, or with `upkeepTier: false`
|
|
173
|
+
*/
|
|
174
|
+
upkeepLimit(): number | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Supply kept ahead: when the type to train next does not fit (or the free supply is under the margin), one more of
|
|
177
|
+
* the cheapest building that provides supply is wanted of the build plan, unless the cap is the game's most or one
|
|
178
|
+
* is on its way already
|
|
179
|
+
*/
|
|
180
|
+
private supplyAhead;
|
|
181
|
+
/**
|
|
182
|
+
* One at a time: what stands finished, and one more. A standing want, with what is needed in its condition: set
|
|
183
|
+
* again whenever the need changes
|
|
184
|
+
*/
|
|
185
|
+
private wantSupply;
|
|
186
|
+
/** What it remembers, for a save: what the supply want was set with, while it stands */
|
|
187
|
+
save(): ProductionPlanMemory | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Takes back what `save` gave, after the build plan's: the supply want is had again at once, before the first think,
|
|
190
|
+
* as the game saved from has it (the module sets it again only when supply runs short, after the build plan thinks)
|
|
191
|
+
*/
|
|
192
|
+
restore(memory: ProductionPlanMemory | undefined): void;
|
|
193
|
+
/**
|
|
194
|
+
* The upgrade to research next: the first of the list it can (`research` as a list), what the function gives, or,
|
|
195
|
+
* left to itself, the one the most of its units benefit from (`UpgradeEffect.units`), ties as the game lists them
|
|
196
|
+
*/
|
|
197
|
+
nextResearch(): UpgradeDef | undefined;
|
|
198
|
+
/** Research, with money to spare: the next upgrade at a finished building of the player's that researches it */
|
|
199
|
+
private runResearch;
|
|
200
|
+
/** The composition as weighed, what was trained and researched this think, the wants trained towards, and the status */
|
|
201
|
+
report(): ProductionPlanReport;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The production module: runs the brain's production plan (`ai.plans.production.think()`) in its place among a
|
|
205
|
+
* brain's modules, after the build plan (which puts up what a want needs) where a brain has both. With options for
|
|
206
|
+
* the plan
|
|
207
|
+
*
|
|
208
|
+
* @beta
|
|
209
|
+
*/
|
|
210
|
+
export declare const production: (options?: ProductionPlanOptions) => AiModuleDef;
|