Skip to content

Knowledge beta ​

Class of @v12-engine/engine/ai

ts
export declare class Knowledge implements AiArea

What a computer player remembers of the enemy, the map and itself, with when (Brain.knowledge). Brought up to date once a think from the view; asked through its parts: enemy (structures, bases, army seen, workers, heroes, tech), map (when a place was last looked at), own (losses, attacks sent, income), events (pings, damage, deaths heard). Plain data underneath (data), saved with the brain

Members ​

constructor ​

ts
constructor(options?: KnowledgeOptions, 
    size?: {
        width: number;
        depth: number;
    }, 
    kept?: boolean);

Constructs a new instance of the Knowledge class

afresh ​

ts
readonly afresh = "the save remembers what the computer player knew in a shape this brain does not read: it starts afresh";

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

data ​

ts
data: KnowledgeMemory;

What it remembers, as plain data. Replaced as a whole by restore

enemy ​

ts
readonly enemy: EnemyKnowledge;

The enemy: structures, bases, army, workers, heroes, tech

events ​

ts
readonly events: HeardEvents;

What was heard: pings, damage to friends, deaths

forget ​

ts
forget(olderThan: number): void;

Forgets what is older than so many seconds: sightings, workers, losses, attacks, what was heard, structures long gone

id ​

ts
readonly id = "knowledge";

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

inspect ​

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

What it knows, in short, for the debug tools: bases, the army seen with its age, the tech seen

map ​

ts
readonly map: MapKnowledge;

The map: when each place was last in sight

options ​

ts
readonly options: Required<Omit<KnowledgeOptions, 'army' | 'limits'>> & Pick<KnowledgeOptions, 'army'> & {
        limits: typeof LIMITS;
    };

The options it runs with: those given over the defaults, the limits being the built-in ones

own ​

ts
readonly own: OwnKnowledge;

One's own: losses, attacks sent, income

remembers ​

ts
remembers(): boolean;

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

restore ​

ts
restore(memory: unknown): boolean;

Takes back what save gave. Memory of another shape is dropped: it starts afresh

resume ​

ts
resume(view: AiView): void;

Reads the think's picture through this view without remembering anything of it: for a think a game loaded from a save goes on with (BrainMemory.thinking), whose picture the saved game remembered already, so that what is restored is as it was after that; only what is asked of the map now needs the view it is asked through

save ​

ts
save(): KnowledgeMemory;

Gives a copy of what is known, as plain data for a save of the brain

tick ​

ts
get tick(): number;

The tick it was last brought up to date

update ​

ts
update(view: AiView, before?: AiView): void;

Brings it up to date from a think's view. before is the view of the think before: what the dead of this think were (a death says only an id). What the brain calls as each think begins, after the view is made