Skip to content

Goals beta ​

Class of @v12-engine/engine/ai

ts
export declare class Goals implements AiArea

The brain's goals and their picker (ai.goals): what the computer could do, scored each think, the best given what they claim (think, once a think: run by the goals() module, or by a module of the brain's own in its place among the others). What each holds is read here (held, holds, holder, pool), taken by a rule or a module (take), and reported (report)

Members ​

constructor ​

ts
constructor(
    ai: Brain, options?: PickingOptions);

Constructs a new instance of the Goals class

add ​

ts
add(...defs: GoalDef[]): void;

Adds goals to pick among: a brain's own (BrainDef.goals), the seat's (AiOptions.goals), a module's

afresh ​

ts
readonly afresh = "the save remembers what the computer player\u2019s goals held in a shape this brain does not read: they start afresh";

What the log says where a save's memory of it is of a shape it does not read

ai ​

ts
readonly ai: Brain;

The brain they are the goals of

all ​

ts
all(): Readonly<Record<string, Hold>>;

What every goal holds, by goal id

best ​

ts
best: string | undefined;

The goal that scored highest above the minimum this think: what the army is on. None when nothing is worth doing

drop ​

ts
drop(id: string, units: Iterable<number>, why?: StopReason): number[];

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, told why (done when left out). Those let go of, by id

get ​

ts
get(id: string): GoalDef | undefined;

A goal by id

give ​

ts
give(id: string, units: Iterable<number>): number[];

Adds units from the pool (what nothing holds) to what a goal, a rule or a module holds: a squad's reinforcements (Squad.reinforce). What another holds is passed over: take is for that. Those given, by id

held ​

ts
held(id: string): Hold | undefined;

What a goal holds, while it does

holder ​

ts
holder(unit: number): string | undefined;

The goal that holds a unit, by the unit's id: none for a unit in the pool

id ​

ts
readonly id = "goals";

Its id among the brain's areas: what its memory and its report are kept under

inspect ​

ts
inspect(): Record<string, unknown>;

What the debug tools show: the report, the best, and the picker's numbers

list ​

ts
list(): GoalDef[];

The goals, as added

pool ​

ts
pool(): UnitSet;

The player's units no goal holds, as of the think's picture: what a goal picked next may claim

release ​

ts
release(id: string, why?: StopReason): boolean;

Takes a goal's claim away, telling it why (told when left out): its units go back to the pool. Whether it held one

remembers ​

ts
remembers(): boolean;

Whether it has anything to remember now: one that does not is left out of a save

remove ​

ts
remove(id: string): boolean;

Takes a goal out: what it held goes back to the pool, and it is told removed. Whether there was one

report ​

ts
report(): GoalReport[];

Every goal as the picker last saw it: score, considerations, what it holds, why it did not run

reserved ​

ts
reserved(): Cost;

The money the goals hold together (GoalClaims.money): held in the purse (ai.purse), which takes it off what is free

restore ​

ts
restore(memory: unknown): boolean;

Takes back what save gave: whether it was read

ruled ​

ts
ruled(unit: number): boolean;

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

save ​

ts
save(): GoalsMemory;

Gives what the goals remember, the holds and the rest, as plain data for a save of the brain

scores ​

ts
scores: Record<string, number>;

How much each goal scored this think, by id: what the debug tools showed before the report

take ​

ts
take(units: Iterable<number>, why?: StopReason, by?: {
        id: string;
        seconds?: number;
    }): number[];

Takes units from whatever goals hold them, for a rule (B2) or a module (the defence, C4) that wants them: a goal left with none is told why (told when left out). Those of them that were held, by id.

With by, the units are then held by that rule or module itself (by.id, which names no goal: rule:attack), for by.seconds (30 when left out) or until release(by.id): no goal may claim them meanwhile, for a rule goes before the goals (the one order of who may move a unit: goals, then rules take, then the defence; micro never retasks). Units taken again by the same id are added to what it holds, and its time starts again. seconds: Infinity holds them until let go of (release, drop): what a squad that is no goal's holds its units by

taken ​

ts
taken(): Record<string, Hold>;

What rules and modules hold (take with by), by their id: not goals'

think ​

ts
think(): void;

The think: every goal scored (its considerations read, curved, multiplied, weighed), the goals that hold a claim kept to it or beaten, the rest picked best first with what they claim, and each picked one run. Once a think: a second call in the same think does nothing