@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,360 @@
|
|
|
1
|
+
import type { Cost } from '#engine/defs';
|
|
2
|
+
import type { AiArea } from './area';
|
|
3
|
+
import type { EntityState } from '#engine/session/protocol';
|
|
4
|
+
import { type Brain } from './brain';
|
|
5
|
+
import { type AiModuleDef } from './module';
|
|
6
|
+
import type { Squad, SquadOptions } from './squads';
|
|
7
|
+
import { UnitSet } from './view';
|
|
8
|
+
/**
|
|
9
|
+
* A response curve: a number (how many, how strong, how long) to how much it matters, 0..1
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type Curve = (x: number) => number;
|
|
14
|
+
/**
|
|
15
|
+
* The usual response curves, each a line (`consider(name, read, curve.saturate(6))`): how a raw number becomes "how
|
|
16
|
+
* much do I care". A curve gives 0..1; what gives nonsense (NaN) counts as 0
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare const curve: {
|
|
21
|
+
/** A straight line from 0 at 0 to 1 at `max` (1 when left out: for a ratio), flat beyond: twice the units, twice the care, up to a point */
|
|
22
|
+
readonly linear: (max?: number) => Curve;
|
|
23
|
+
/** 1 − e^(−x/k): rises fast, then levels off at 1 (0.63 at `k`, 0.86 at `2k`): the sixth worker seen matters less than the first */
|
|
24
|
+
readonly saturate: (k: number) => Curve;
|
|
25
|
+
/** k / (k + x): 1 at 0, falling to a half at `k` and towards 0: the less there is of it, the better (how held their base is) */
|
|
26
|
+
readonly inverse: (k: number) => Curve;
|
|
27
|
+
/** 0 below `at`, 1 from it on: a threshold (a wave is ready at so many units), an on-off (any intruder at all: `step(1)`) */
|
|
28
|
+
readonly step: (at: number) => Curve;
|
|
29
|
+
/** 1 between `low` and `high`, 0 outside: a window (an army of between 4 and 12) */
|
|
30
|
+
readonly band: (low: number, high: number) => Curve;
|
|
31
|
+
/** A shape of the game's own: whatever the function gives, kept to 0..1 */
|
|
32
|
+
readonly custom: (fn: (x: number) => number) => Curve;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* One question a goal asks of what it sees, and how much the answer matters: `read` gives the raw number, `curve`
|
|
36
|
+
* turns it into 0..1. The report keeps both
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export interface Consideration {
|
|
41
|
+
/** What it asks, for the report: "intruders at my buildings" */
|
|
42
|
+
name: string;
|
|
43
|
+
/** The raw number, read from the brain each think: cheap, or cached for the think (`ai.cache`) */
|
|
44
|
+
read: (ai: Brain) => number;
|
|
45
|
+
/** How much the number matters, 0..1 */
|
|
46
|
+
curve: Curve;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A consideration: a question with a name, and the curve that says how much its answer matters (`curve.linear()`
|
|
50
|
+
* when left out: the number is a ratio already)
|
|
51
|
+
*
|
|
52
|
+
* @beta
|
|
53
|
+
*/
|
|
54
|
+
export declare function consider(name: string, read: (ai: Brain) => number, shape?: Curve): Consideration;
|
|
55
|
+
/**
|
|
56
|
+
* What a goal is about, and so what it competes with: `army` goals claim units, `economy` goals money, `squad` and
|
|
57
|
+
* `hero` goals are about one of those (scored once each until squads (C1) and heroes (C2) score them apiece), or a
|
|
58
|
+
* game's own word
|
|
59
|
+
*
|
|
60
|
+
* @beta
|
|
61
|
+
*/
|
|
62
|
+
export type GoalScope = 'army' | 'economy' | 'squad' | 'hero' | (string & {});
|
|
63
|
+
/**
|
|
64
|
+
* Why a goal lost its claim (`GoalDef.stop`): `beaten` by one that scored more by the margin, `urgent` by an urgent
|
|
65
|
+
* one, `done` as its own score fell to nothing, `told` by a rule or a module that took its units, `removed` from the
|
|
66
|
+
* brain
|
|
67
|
+
*
|
|
68
|
+
* @beta
|
|
69
|
+
*/
|
|
70
|
+
export type StopReason = 'beaten' | 'urgent' | 'done' | 'told' | 'removed';
|
|
71
|
+
/**
|
|
72
|
+
* What a goal claims to run: units from the pool and money from the purse. The picker gives each goal what it asks
|
|
73
|
+
* of what is left, best goal first
|
|
74
|
+
*
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
export interface GoalClaims {
|
|
78
|
+
/**
|
|
79
|
+
* The units it takes, chosen from what it may have (`available`: the pool, and what goals it may take from hold):
|
|
80
|
+
* the nearest six fighters, one scout, everything. A goal that asks for units and gets none is not picked
|
|
81
|
+
*/
|
|
82
|
+
units?: (ai: Brain, available: UnitSet) => Iterable<EntityState>;
|
|
83
|
+
/**
|
|
84
|
+
* The money it holds while it runs, in the game's money (`Registry.currency`) as a number, or as a cost by resource;
|
|
85
|
+
* a function for one that depends. Held against the purse (`Goals.reserved`), given back when the goal stops
|
|
86
|
+
*/
|
|
87
|
+
money?: number | Cost | ((ai: Brain) => number | Cost | undefined);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* What a picked goal was given (`GoalDef.run`): the units it holds this think (the dead and the lost dropped), the
|
|
91
|
+
* money, when it was picked, and whether this is the first think it runs
|
|
92
|
+
*
|
|
93
|
+
* @beta
|
|
94
|
+
*/
|
|
95
|
+
export interface Claimed {
|
|
96
|
+
/** The units it holds, as of this think's picture */
|
|
97
|
+
units: UnitSet;
|
|
98
|
+
/** The money it holds, where it asked for any */
|
|
99
|
+
money?: Cost;
|
|
100
|
+
/** The tick it was picked at */
|
|
101
|
+
began: number;
|
|
102
|
+
/** Whether this is the first think it runs: when its orders are to be sent, once */
|
|
103
|
+
first: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Makes a squad the goal owns (`ai.squads.make` with the goal as its `owner`): when the goal stops, its squads go.
|
|
106
|
+
* Called again for a name the goal has a squad of already (a run each think), it is that squad, kept as it is (its
|
|
107
|
+
* task, its `size`), the units given added to it and its options those given now
|
|
108
|
+
*/
|
|
109
|
+
squad(name: string, units: Iterable<EntityState | number>, options?: SquadOptions): Squad;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A goal: something the computer could do, scored by its considerations, run with what it claims (`defineGoal`)
|
|
113
|
+
*
|
|
114
|
+
* @beta
|
|
115
|
+
*/
|
|
116
|
+
export interface GoalDef {
|
|
117
|
+
/** Unique among the brain's goals, prefixed as components are (the engine's `ai.defend`, a game's `mygame.raid`) */
|
|
118
|
+
id: string;
|
|
119
|
+
/** What it is about: `army` when left out */
|
|
120
|
+
scope?: GoalScope;
|
|
121
|
+
/** Its questions: the score is their product (a soft AND: one at 0 vetoes the goal), times the weight */
|
|
122
|
+
considerations: Consideration[];
|
|
123
|
+
/** What it is worth against the other goals at their best: 1 when left out */
|
|
124
|
+
weight?: number;
|
|
125
|
+
/** The score under which it is not picked: the picker's (`PickingOptions.min`) when left out */
|
|
126
|
+
min?: number;
|
|
127
|
+
/** What it takes to run: units, money. None: it runs on its score alone, holding nothing */
|
|
128
|
+
claims?: GoalClaims;
|
|
129
|
+
/**
|
|
130
|
+
* Seconds it keeps its claim once picked, unless another scores more than it by the margin, or an urgent one scores
|
|
131
|
+
* more at all. The picker's default when left out. Hysteresis: without it two close goals swap every think
|
|
132
|
+
*/
|
|
133
|
+
commitment?: number;
|
|
134
|
+
/** How much more another goal must score to take from this one within its commitment: the picker's when left out */
|
|
135
|
+
margin?: number;
|
|
136
|
+
/** Whether it may break another goal's commitment as soon as it scores more: a raid that cannot wait */
|
|
137
|
+
urgent?: boolean | ((ai: Brain) => boolean);
|
|
138
|
+
/** Seconds after it stops before it may be picked again */
|
|
139
|
+
cooldown?: number;
|
|
140
|
+
/** What it does, each think it holds its claim: `claimed.first` on the first, where its orders are sent once and then watched */
|
|
141
|
+
run(ai: Brain, claimed: Claimed): void;
|
|
142
|
+
/** Told when it loses its claim, and why: to let go of what it was doing */
|
|
143
|
+
stop?(ai: Brain, why: StopReason, claimed: Claimed): void;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Defines a goal: checked, and given back as it is, for a brain's `goals`, `meleeBrain.with({ goals })`, or
|
|
147
|
+
* `ai.goals.add`
|
|
148
|
+
*
|
|
149
|
+
* @beta
|
|
150
|
+
*/
|
|
151
|
+
export declare function defineGoal(def: GoalDef): GoalDef;
|
|
152
|
+
/**
|
|
153
|
+
* How a brain picks among its goals, where a goal does not say for itself (`BrainDef.picking`)
|
|
154
|
+
*
|
|
155
|
+
* @beta
|
|
156
|
+
*/
|
|
157
|
+
export interface PickingOptions {
|
|
158
|
+
/** The score under which a goal is not picked: 0.05 when left out */
|
|
159
|
+
min?: number;
|
|
160
|
+
/** How much more a goal must score than a committed one to take from it: 0.15 when left out */
|
|
161
|
+
margin?: number;
|
|
162
|
+
/** Seconds a picked goal keeps its claim: 5 when left out */
|
|
163
|
+
commitment?: number;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* What a goal holds while it runs: its units (ids, of the player's), its money, when it was picked and until when it
|
|
167
|
+
* is committed. Plain data, kept in the brain's memory
|
|
168
|
+
*
|
|
169
|
+
* @beta
|
|
170
|
+
*/
|
|
171
|
+
export interface Hold {
|
|
172
|
+
/** The units it holds, by id, in the picture's order */
|
|
173
|
+
units: number[];
|
|
174
|
+
/** The money it holds (`GoalClaims.money`) */
|
|
175
|
+
money?: Cost;
|
|
176
|
+
/** The tick it was picked at */
|
|
177
|
+
since: number;
|
|
178
|
+
/** The tick its commitment ends at: for a rule's or a module's hold (`take` with `by`), the tick it lets go at */
|
|
179
|
+
until: number;
|
|
180
|
+
/** For a rule's or a module's hold: kept until let go of (`release`), whatever `until` says. A squad of one's own holds so */
|
|
181
|
+
kept?: true;
|
|
182
|
+
/** What it scored when picked */
|
|
183
|
+
score: number;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* What the goals remember between thinks: what each holds, and until when each is on cooldown
|
|
187
|
+
*
|
|
188
|
+
* @beta
|
|
189
|
+
*/
|
|
190
|
+
export interface GoalsMemory {
|
|
191
|
+
/** The version of this shape */
|
|
192
|
+
v: 1;
|
|
193
|
+
/** What each goal holds, by goal id */
|
|
194
|
+
holds: Record<string, Hold>;
|
|
195
|
+
/** The tick each goal on cooldown may be picked again at, by goal id */
|
|
196
|
+
cooldowns: Record<string, number>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* One goal as the picker last saw it: for the debug tools, and for "why did it do that"
|
|
200
|
+
*
|
|
201
|
+
* @beta
|
|
202
|
+
*/
|
|
203
|
+
export interface GoalReport {
|
|
204
|
+
/** The goal */
|
|
205
|
+
id: string;
|
|
206
|
+
/** What it is about */
|
|
207
|
+
scope: GoalScope;
|
|
208
|
+
/** Its score: the considerations' product, weighed */
|
|
209
|
+
score: number;
|
|
210
|
+
/**
|
|
211
|
+
* Each question, its raw answer and how much that mattered. One after a question answered 0 is not asked (the goal
|
|
212
|
+
* is vetoed already): `asked: false`, its numbers 0
|
|
213
|
+
*/
|
|
214
|
+
considerations: {
|
|
215
|
+
name: string;
|
|
216
|
+
value: number;
|
|
217
|
+
curved: number;
|
|
218
|
+
asked?: false;
|
|
219
|
+
}[];
|
|
220
|
+
/** Whether it ran this think */
|
|
221
|
+
picked: boolean;
|
|
222
|
+
/** Whether it may break a commitment now */
|
|
223
|
+
urgent: boolean;
|
|
224
|
+
/** What it holds: how many units (and which, `ids`), how strong together, the money, since when and until when (ticks) */
|
|
225
|
+
held?: {
|
|
226
|
+
units: number;
|
|
227
|
+
ids: number[];
|
|
228
|
+
strength: number;
|
|
229
|
+
money?: Cost;
|
|
230
|
+
since: number;
|
|
231
|
+
until: number;
|
|
232
|
+
};
|
|
233
|
+
/** Why it did not run, where it scored enough: `cooldown`, `nothing to claim`, or what it lost its claim to */
|
|
234
|
+
why?: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The brain's goals and their picker (`ai.goals`): what the computer could do, scored each think, the best given what
|
|
238
|
+
* they claim (`think`, once a think: run by the `goals()` module, or by a module of the brain's own in its place among
|
|
239
|
+
* the others). What each holds is read here (`held`, `holds`, `holder`, `pool`), taken by a rule or a module
|
|
240
|
+
* (`take`), and reported (`report`)
|
|
241
|
+
*
|
|
242
|
+
* @beta
|
|
243
|
+
*/
|
|
244
|
+
export declare class Goals implements AiArea {
|
|
245
|
+
/** The brain they are the goals of */
|
|
246
|
+
readonly ai: Brain;
|
|
247
|
+
/** Its id among the brain's areas: what its memory and its report are kept under */
|
|
248
|
+
readonly id = "goals";
|
|
249
|
+
/** What the log says where a save's memory of it is of a shape it does not read */
|
|
250
|
+
readonly afresh = "the save remembers what the computer player\u2019s goals held in a shape this brain does not read: they start afresh";
|
|
251
|
+
/** How much each goal scored this think, by id: what the debug tools showed before the report */
|
|
252
|
+
scores: Record<string, number>;
|
|
253
|
+
/** The goal that scored highest above the minimum this think: what the army is on. None when nothing is worth doing */
|
|
254
|
+
best: string | undefined;
|
|
255
|
+
private readonly entries;
|
|
256
|
+
private holds;
|
|
257
|
+
private cooldowns;
|
|
258
|
+
private added;
|
|
259
|
+
private thoughtAt;
|
|
260
|
+
private readonly min;
|
|
261
|
+
private readonly margin;
|
|
262
|
+
private readonly commitment;
|
|
263
|
+
constructor(
|
|
264
|
+
/** The brain they are the goals of */
|
|
265
|
+
ai: Brain, options?: PickingOptions);
|
|
266
|
+
/** Adds goals to pick among: a brain's own (`BrainDef.goals`), the seat's (`AiOptions.goals`), a module's */
|
|
267
|
+
add(...defs: GoalDef[]): void;
|
|
268
|
+
/** Takes a goal out: what it held goes back to the pool, and it is told `removed`. Whether there was one */
|
|
269
|
+
remove(id: string): boolean;
|
|
270
|
+
/** The goals, as added */
|
|
271
|
+
list(): GoalDef[];
|
|
272
|
+
/** A goal by id */
|
|
273
|
+
get(id: string): GoalDef | undefined;
|
|
274
|
+
/** What a goal holds, while it does */
|
|
275
|
+
held(id: string): Hold | undefined;
|
|
276
|
+
/** What every goal holds, by goal id */
|
|
277
|
+
all(): Readonly<Record<string, Hold>>;
|
|
278
|
+
/** The goal that holds a unit, by the unit's id: none for a unit in the pool */
|
|
279
|
+
holder(unit: number): string | undefined;
|
|
280
|
+
/** The player's units no goal holds, as of the think's picture: what a goal picked next may claim */
|
|
281
|
+
pool(): UnitSet;
|
|
282
|
+
/** The money the goals hold together (`GoalClaims.money`): held in the purse (`ai.purse`), which takes it off what is free */
|
|
283
|
+
reserved(): Cost;
|
|
284
|
+
/**
|
|
285
|
+
* Takes units from whatever goals hold them, for a rule (B2) or a module (the defence, C4) that wants them: a goal
|
|
286
|
+
* left with none is told why (`told` when left out). Those of them that were held, by id.
|
|
287
|
+
*
|
|
288
|
+
* With `by`, the units are then held by that rule or module itself (`by.id`, which names no goal: `rule:attack`),
|
|
289
|
+
* for `by.seconds` (30 when left out) or until `release(by.id)`: no goal may claim them meanwhile, for a rule goes
|
|
290
|
+
* before the goals (the one order of who may move a unit: goals, then rules take, then the defence; micro never
|
|
291
|
+
* retasks). Units taken again by the same id are added to what it holds, and its time starts again. `seconds:
|
|
292
|
+
* Infinity` holds them until let go of (`release`, `drop`): what a squad that is no goal's holds its units by
|
|
293
|
+
*/
|
|
294
|
+
take(units: Iterable<number>, why?: StopReason, by?: {
|
|
295
|
+
id: string;
|
|
296
|
+
seconds?: number;
|
|
297
|
+
}): number[];
|
|
298
|
+
/**
|
|
299
|
+
* Adds units from the pool (what nothing holds) to what a goal, a rule or a module holds: a squad's reinforcements
|
|
300
|
+
* (`Squad.reinforce`). What another holds is passed over: `take` is for that. Those given, by id
|
|
301
|
+
*/
|
|
302
|
+
give(id: string, units: Iterable<number>): number[];
|
|
303
|
+
/**
|
|
304
|
+
* Lets go of some of what a goal, a rule or a module holds: they go back to the pool. One left with none is released,
|
|
305
|
+
* told why (`done` when left out). Those let go of, by id
|
|
306
|
+
*/
|
|
307
|
+
drop(id: string, units: Iterable<number>, why?: StopReason): number[];
|
|
308
|
+
/** What rules and modules hold (`take` with `by`), by their id: not goals' */
|
|
309
|
+
taken(): Record<string, Hold>;
|
|
310
|
+
/** Whether a unit is held by a rule or a module rather than by a goal (`take` with `by`): what nothing else is to give orders to */
|
|
311
|
+
ruled(unit: number): boolean;
|
|
312
|
+
/** Takes a goal's claim away, telling it why (`told` when left out): its units go back to the pool. Whether it held one */
|
|
313
|
+
release(id: string, why?: StopReason): boolean;
|
|
314
|
+
/**
|
|
315
|
+
* The think: every goal scored (its considerations read, curved, multiplied, weighed), the goals that hold a claim
|
|
316
|
+
* kept to it or beaten, the rest picked best first with what they claim, and each picked one run. Once a think: a
|
|
317
|
+
* second call in the same think does nothing
|
|
318
|
+
*/
|
|
319
|
+
think(): void;
|
|
320
|
+
/**
|
|
321
|
+
* A goal's score this think: each consideration read and curved, their product, the weight, the game's say. Once a
|
|
322
|
+
* consideration answers 0 the goal is vetoed, and the ones after it are not asked: put the cheap questions first
|
|
323
|
+
*/
|
|
324
|
+
private score;
|
|
325
|
+
/** Writes down a goal picked anew, for the decision log: its score, what it holds, its considerations */
|
|
326
|
+
private decided;
|
|
327
|
+
/**
|
|
328
|
+
* What a goal picked anew takes: the units it chooses from the pool and from the holds of goals ranked below it
|
|
329
|
+
* that it may take from (by the margin within their commitment, by any lead after it, and by any lead at all for an
|
|
330
|
+
* urgent goal), and the money it names. Nothing where it asked for units and chose none
|
|
331
|
+
*/
|
|
332
|
+
private claim;
|
|
333
|
+
/** The money a goal names, as a cost: a number is in the game's money */
|
|
334
|
+
private moneyOf;
|
|
335
|
+
/** What a goal holds, as it is handed to it */
|
|
336
|
+
private claimedOf;
|
|
337
|
+
private heldIds;
|
|
338
|
+
/** Every goal as the picker last saw it: score, considerations, what it holds, why it did not run */
|
|
339
|
+
report(): GoalReport[];
|
|
340
|
+
/** What is held and on cooldown, for a save */
|
|
341
|
+
/** Whether it has anything to remember now: one that does not is left out of a save */
|
|
342
|
+
remembers(): boolean;
|
|
343
|
+
save(): GoalsMemory;
|
|
344
|
+
/** Takes back what `save` gave: whether it was read */
|
|
345
|
+
restore(memory: unknown): boolean;
|
|
346
|
+
/** What the debug tools show: the report, the best, and the picker's numbers */
|
|
347
|
+
inspect(): Record<string, unknown>;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The goals module: runs the brain's picker (`ai.goals.think`) in its place among the brain's modules, after what
|
|
351
|
+
* reads the game and before what acts on orders. With goals of its own to add to the brain's
|
|
352
|
+
*
|
|
353
|
+
* @beta
|
|
354
|
+
*/
|
|
355
|
+
export declare const goals: (defs?: GoalDef[]) => AiModuleDef;
|
|
356
|
+
declare module './area' {
|
|
357
|
+
interface AreaMemories {
|
|
358
|
+
goals?: GoalsMemory;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export { Brain, type BrainContext, type BrainDef, type BrainExtension, type BrainMemory, type BrainWatcher, createBrain, type Told } from './brain';
|
|
2
|
+
export { AI_PHASES, type AiModule, type AiModuleDef, type AiPhase, defineModule, type ModuleKey, moduleKey } from './module';
|
|
3
|
+
export { defineBrain, type DefinedBrain } from './define';
|
|
4
|
+
export { an, pair, plural, point, where } from './geometry';
|
|
5
|
+
export { aiTeams, type ComputerPlayer, type ComputerSystem, type ComputerSeatOptions, type ComputerTiming, createBrainSystem, createComputerSystem, defineComputer, type MapAi } from './computer';
|
|
6
|
+
export type { AiOptions } from './options';
|
|
7
|
+
export type { BrainSeat, ComputerSeat, SeatRequest } from '../computers';
|
|
8
|
+
export { ThinkBudget, type ThinkBudgetOptions } from './budget';
|
|
9
|
+
export { AI_INVARIANTS, type AiCheckOptions, type AiEndLimits, type AiInvariant, type AiViolation, BrainChecks, checkBrain } from './checks';
|
|
10
|
+
export { MELEE_LADDER, MeleeArmy, type MeleeArmyMemory, type MeleeArmyModule, MELEE_ARMY, type MeleeArmyOptions, meleeArmy, meleeArmyOf, meleeBrain, meleeBuild, type MeleeBuildOptions, meleeHeroes, type MeleeHeroesOptions, meleeProduction, meleeSurrender, type MeleeSurrenderOptions, type MeleeWant } from './melee';
|
|
11
|
+
export { ambush, type AmbushThen, fleeWhen, guard, holdPosition, missionBrain, type MissionBrainDef, type MissionPartMemory, type MissionPartOptions, type MissionPlace, type MissionTarget, type MissionUnits, type MissionUnitsData, patrol, surrenderWhen, waveFrom } from './mission';
|
|
12
|
+
export { lanesBrain, lanesBrainOf, laneAt, type LaneSide, LANES, type LanesModule, LanesPlay, type LanesPlayMemory, type LanesPlayOptions, type LaneState, lanesPlay, lanesTargets, onLane } from './lanes';
|
|
13
|
+
export { DEFEND, defence, type DefenceMemory, type DefenceOptions, type DefenceReport, type Raid } from './defence';
|
|
14
|
+
export { type Look, SCOUT, scouting, type ScoutingMemory, type ScoutingOptions, type ScoutingReport } from './scouting';
|
|
15
|
+
export { economy, type EconomyBase, type EconomyMemory, type EconomyOptions, type EconomyReport, type WorkersPer } from './economy';
|
|
16
|
+
export { type Claimed, consider, type Consideration, curve, type Curve, defineGoal, type GoalClaims, type GoalDef, type GoalReport, goals, Goals, type GoalScope, type GoalsMemory, type Hold, type PickingOptions, type StopReason } from './goals';
|
|
17
|
+
export { type ArmySighting, type AttackSent, type DamageSeen, type DeathSeen, type EnemyBase, EnemyKnowledge, HeardEvents, Knowledge, type KnowledgeMemory, type KnowledgeOptions, type Loss, MapKnowledge, OwnKnowledge, type PingHeard, type StructureSeen, type TypeSeen, type UnitSeen } from './knowledge';
|
|
18
|
+
export { type AiHints, type AiRole, inferRoles, type RoleEntry, Roles, type RolesFinder, type RolesPlayer, type RoleTable } from './roles';
|
|
19
|
+
export { type Counter, type CounterHint, defaultStrength, type Force, type Matchup, Strength, type StrengthFormula, type StrengthInput } from './strength';
|
|
20
|
+
export { type AiAction, type AiActionData, type AiCondition, type AiConditionData, type AiConditionTest, type AiRange, type AiRule, type AiWhose, evaluate, type RuleBuilder, rules, when, type WordData, words } from './rules';
|
|
21
|
+
export { build, BuildPlan, type BuildPlanMemory, type BuildPlanOptions, type BuildPlanReport, type Want, type WantData, type WantReport } from './plans/build';
|
|
22
|
+
export { enemyDirection, type PlacementName, placements, type PlacementStrategy, type PlacementTable, rings, type SiteRequest } from './plans/placement';
|
|
23
|
+
export { type BuildOrderItem, Plans, type PlansMemory, type PlansOptions, type PlansReport } from './plans/plans';
|
|
24
|
+
export { type Composition, type CompositionReport, production, ProductionPlan, type ProductionPlanMemory, type ProductionPlanOptions, type ProductionPlanReport, UPKEEP_SPARE, UPKEEP_TIER } from './plans/production';
|
|
25
|
+
export { Purse, type PurseReport } from './plans/purse';
|
|
26
|
+
export { techPath, type TechPath, type TechStep } from './plans/tech';
|
|
27
|
+
export { type AiDecision, type AiReport, type AiStats, Decisions, type KnowledgeReport, type ThreatReport } from './report';
|
|
28
|
+
export { type AbilityAiView, type HeroPlan, type HiringItem, micro, type MicroMemory, type MicroOptions, type MicroReport, type ShoppingItem, type SpellAim, type TargetPicker, type TargetRule } from './micro';
|
|
29
|
+
export { Squad, type SquadData, SquadGroup, type SquadOptions, type SquadReport, squads, Squads, type SquadsMemory, type SquadsOptions } from './squads';
|
|
30
|
+
export { defineTask, type TaskCommon, type TaskData, type TaskDef, type TaskDone, type TaskMemory, type TaskOrder, type TaskState } from './task';
|
|
31
|
+
export { ATTACK, CAPTURE, type CaptureData, CREEP, type CreepData, DEFEND_TASK, type DefendData, type DefendMemory, ESCORT, type EscortData, type FightData, type FightMemory, GATHER, type GatherData, HARASS, HOLD, type HoldData, MOVE, type MoveData, PATROL, RETREAT, type RetreatData, type RoundData, type RoundMemory, SCOUT_TASK } from './tasks';
|
|
32
|
+
export { type AiFlag, type AiFlags, type AiHandicap, type AiProfile, type AiProfileTable, DEFAULT_PROFILE, DIFFICULTIES, difficultiesOf, flagOf, type GameAi, PERSONALITIES, personalitiesOf, type ResolvedProfile, resolveProfile } from './profiles';
|
|
33
|
+
export { type AiSettings, resolveSettings } from './settings';
|
|
34
|
+
export { type AttackPlan, HELP, team, type TeamBoard, type TeamOptions, type TeamPlayMemory, type TeamReport, type TeamRequest } from './team';
|
|
35
|
+
export { type AttackGroup, type AttackWave, type WaveTarget, waves, type WavesMemory, type WavesOptions, type WavesReport } from './waves';
|
|
36
|
+
export { type Threat, type ThreatCell, ThreatMap, type ThreatQuery } from './threat';
|
|
37
|
+
export { AiView, type Base, type Me, UnitSet, ViewEvents, type ViewOptions } from './view';
|
|
38
|
+
export { missionRules } from './missionRules';
|