BrainDef beta
Interface of @v12-engine/engine/ai
export interface BrainDefWhat a computer player is made of, defined once (defineBrain) and seated as often as wanted (world.computers.seat). A game lists the brains it seats in Rules.brains, so that a save that remembers a seat by its brain's id finds it again when loaded
Members
conditions
conditions?: Record<string, AiConditionTest>;Conditions of its own, by id, for the data form ({ is: id, args }): over the game's of the same id (GameAi.conditions)
every
every?: number | ((options: AiOptions) => number);Seconds between thinks, where the seat's options say none (AiOptions.every): 1 when left out. A function of the seat's options, for a brain that thinks faster on a harder difficulty
goals
goals?: GoalDef[];What it could do, scored each think and run with what each claims (defineGoal, ai.goals): picked by the goals() module in its place among the modules, or by a module of the brain's own. Code, registered again with the brain: there after a load, where a goal in the seat's options is not
id
id: string;Unique among the brains of a game, prefixed as components are (the engine's core.melee, a game's mygame.raiders): what a save remembers a seat by
knowledge
knowledge?: KnowledgeOptions | false;How it remembers what it saw (Brain.knowledge): how long, how much, what counts as the enemy's army. false for a brain that remembers nothing between thinks and would rather not pay for it (a tower defense's waves)
modules
modules: AiModuleDef[];The parts of a think, in the order they run where before and after say nothing
picking
picking?: PickingOptions;How it picks among its goals where a goal does not say for itself: the least score, the margin, the commitment
rules
rules?: AiRule[];Rules of its own (when(…).do(…), B2), checked each think by its rules() module: the melee brain's reads them (meleeBrain.with({ rules: [...] })); a brain of one's own gives them to its rules() module itself. Code, registered again with the brain
seat
seat?: BrainSeat;How it is seated at a player (world.computers.seat): what defineBrain gives it, the seat of the engine's kit (createBrainSystem, with what the map says of the player under the options). The engine's core seats a brain through it, and loads nothing of the kit for it
settings
settings?: AiSettings;Its own settings (AiSettings, keyed by area: how it plans, how its squads go and the tasks they may be on, how it fights, runs its economy, defends, scouts, plays with its team, its waves): the bottom layer, under the game's defaults, the difficulty, the personality, the map's and the seat's (resolveProfile); what its modules were made with under all of them. Code, registered again with the brain
snapshot
snapshot?: 'lean' | 'full';What its picture of the game carries (ComputerSeatOptions.snapshot): lean when left out, what the kit reads (the entities, the players, the items, the deaths, damage, healing, pings, chat and the game's own events) and none of what a screen needs, which is cheaper. full for a brain of a game's own that reads the rest (projectiles, corpses, reveals, the other events)
strength
strength?: StrengthFormula;How strong a unit is, in place of the kit's formula (defaultStrength): what odds, the threat map and UnitSet.strength() are made of. The seat's AiOptions.strength goes over it; this one is code the game registers again, so it is there after a load
with
with?(more: BrainExtension): BrainDef;This brain and more: goals, modules, rules and without added to its own, its settings layered over its own, anything else in place of its own (meleeBrain.with({ goals: [raid] }), meleeBrain.with({ id: 'mygame.camp', rules, without: ['scouting'] })). Given by defineBrain
without
without?: string[];Modules of the list left out, by id (meleeBrain.with({ without: ['scouting', 'melee.heroes'] })): a variant of a brain with a part fewer. A module whose id is not known before it is made (a plain function, not defineModule) cannot be left out by name