Skip to content

AiModule beta ​

Interface of @v12-engine/engine/ai

ts
export interface AiModule

One named part of a computer player's think (defineBrain's modules). Modules run in their order each think, over the same picture of the game, each reading it through the brain it is handed (ai.snapshot, later ai.view) and acting through ai.send. A module is made for each brain (AiModuleDef: a function of the brain), so that what it keeps in itself is one seat's. What it remembers between thinks goes through save and restore, as plain data

Members ​

after ​

ts
after?: string[];

Ids of modules of the brain this one runs after, within its phase

before ​

ts
before?: string[];

Ids of modules of the brain this one runs ahead of, for what one phase needs within itself. Ids of modules the brain does not have are passed over

dispose ​

ts
dispose?(): void;

Lets go of what it holds outside the brain when the computer is unseated

everyThinks ​

ts
everyThinks?: number;

Runs once in so many thinks, for work that does not need doing every think. Every think when left out

id ​

ts
id: string;

Unique in a brain: what its memory is kept under, what the timing and the debug tools name it by

inspect ​

ts
inspect?(): unknown;

What it is thinking, as plain data, for the debug tools: what the report has no part for, kept under the module's id in its sections (Brain.report)

migrate ​

ts
migrate?(data: unknown, from: number): unknown;

Brings what an earlier version of the module saved (from: its version) up to what this one takes. Nothing (undefined) says it cannot be brought up, and the module starts afresh; so does a module without migrate

offset ​

ts
offset?: number;

With everyThinks, the think in each round it runs at: modules with the same every and other offsets spread the work

phase ​

ts
phase?: AiPhase;

When in a think it runs (AiPhase): the brain runs its modules phase by phase, as listed within each. Left out, in the phase of the module listed before it (the first phase for the first)

report ​

ts
report?(report: AiReport): void;

Writes its part of the report (Brain.report), where the report has a part for it: a kit's module fills the part it names (its squads, its plans). Plain data only

restore ​

ts
restore?(data: unknown): void;

Takes back what save gave, in a game loaded from a save

save ​

ts
save?(): unknown;

What it remembers between thinks, as plain data for a save. Nothing (undefined) for a module that remembers nothing

think ​

ts
think(ai: Brain): void;

Its part of the think

version ​

ts
version?: number;

The version of what it remembers (save): 1 when left out. Raised when the shape of it changes; a load that finds memory of another version gives it to migrate, or starts the module afresh where there is none

wasCalled ​

ts
wasCalled?: string[];

Ids this module's memory was kept under before it was called what it is: a save made then gives it back under the old id, and it is read as this module's (through migrate where the version differs too)