Skip to content

Squads beta ​

Class of @v12-engine/engine/ai

ts
export declare class Squads implements AiArea

A brain's squads (ai.squads): made by its goals, rules and modules, watched by the squads() module each think (think): the dead dropped, what the owner let go of let go of, each task looked at, regroups, retreats and reinforcements seen to. Kept in the brain's memory (BrainMemory.squads)

Members ​

constructor ​

ts
constructor(
    ai: Brain, 
    tasks?: readonly TaskDef[]);

Constructs a new instance of the Squads class

afresh ​

ts
readonly afresh = "the save remembers the computer player\u2019s squads in a shape this brain does not read: they are let go of";

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 squads of

all ​

ts
all(): SquadGroup;

Every squad, as made

configure ​

ts
configure(options: SquadOptions): void;

Puts the squads() module's options under the brain's settings

defaults ​

ts
get defaults(): SquadOptions;

How a squad behaves where it says nothing: the module's options, the brain's settings over them (ai.settings.squads)

define ​

ts
define(def: TaskDef): void;

Registers a task of the game's own, so that a squad on it is carried on after a load. Given by BrainDef.squads.tasks

disband ​

ts
disband(squad: Squad, why?: string, letGo?: boolean): void;

Disbands a squad: a squad that held its units itself lets them go back to the pool

enlist ​

ts
enlist(squad: Squad, wanted: number[]): number[];

Puts units in a squad: those its owner may have (held by it, or given from the pool for a goal; taken for a rule's or a module's), out of any other squad. Those put in, by id

give ​

ts
give(squad: Squad, kind: string | TaskDef, data: TaskData, goingOn?: boolean): void;

Gives a squad a task: what it was doing is over, and the new one's first orders go at once. What it has now is what reinforcements make up to from then on (SquadData.size), but for a task it goes on to by itself (going on: a task's then, a fall back on the odds), which keeps what the task before was given. The task it is on given again changes nothing, its size kept: what it lost since is what reinforcements make up

id ​

ts
readonly id = "squads";

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

idle ​

ts
idle(): SquadGroup;

The squads with nothing to do: told nothing, or their task over

make ​

ts
make(name: string, units: Iterable<EntityState | number>, options?: SquadOptions & {
        owner?: string;
    }): Squad;

Makes a squad of units under a name (one of that name already is disbanded first), with how it behaves where it is not the brain's way. Whose it is (owner): what options.owner names (a goal makes its own with claimed.squad), else its own (squad:<name>). A goal's squad is made of what the goal holds, and what nothing holds is given to it; a squad of a rule or a module takes its units from whatever holds them (the goal told: stop('told')) and holds them until it is disbanded. A unit in another squad leaves it

named ​

ts
named(name: string): Squad | undefined;

A squad by name: none for one there is not

of ​

ts
of(owner: string): SquadGroup;

The squads a goal, rule or module owns

pool ​

ts
pool(): UnitSet;

The player's units nothing holds (ai.goals.pool, buildings left out): what a squad is made of, or reinforced from

remembers ​

ts
remembers(): boolean;

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

report ​

ts
report(): SquadReport[];

Every squad as the report shows it

restore ​

ts
restore(memory: unknown): boolean;

Takes back what save gave: whether it was read. A squad on a task the brain does not know is kept, and does nothing

route ​

ts
route(from: Vec2, to: Vec2, squad: Squad): {
        waypoints: Vec2[];
        note?: string;
    };

The way to a place round where the enemy is strong (avoid: 'army'): the waypoint to go by, where the straight way crosses their strength (the threat map, with what is remembered of their towers, and their army as last seen) and a way round is less hot, tried on either side and then further out, twice at most. A heuristic, not a safe route: none where the straight way is cool enough, or where there is no way round (note says so)

save ​

ts
save(): SquadsMemory;

Gives the squads' data as plain data for a save of the brain

squadOf ​

ts
squadOf(unit: EntityState | number): Squad | undefined;

The squad a unit is in, by the unit or its id: none for a unit in none

taskDef ​

ts
taskDef(id: string): TaskDef | undefined;

A kind of task by its id: the kit's, or one registered

think ​

ts
think(): void;

Looks at every squad, once a think: its units (the dead, and what its owner let go of, dropped; a squad of a goal that stopped disbanded), then its task (retreat on the odds, the task's own look, regroup, reinforcements). What the squads() module runs; a module may call it sooner

whereOf ​

ts
whereOf(squad: Squad): Vec2 | undefined;

The place a squad's task is about: none for a task about no place