BuildPlan beta
Class of @v12-engine/engine/ai
export declare class BuildPlanThe brain's build plan (ai.plans.build): its wants, the steps to each, the spots, the builders, the purse. Add a want with want, read where each stands with report, and let think act on them once a think
Members
constructor
constructor(
ai: Brain, options?: BuildPlanOptions);Constructs a new instance of the BuildPlan class
ai
readonly ai: Brain;The brain it plans for
build
build(type: UnitTypeDef | string, options?: {
near?: Vec2;
within?: number;
placement?: PlacementName | PlacementStrategy;
spare?: number;
by?: string;
}): boolean;Builds a type now, outside any want: a spot near a place (home when left out), a builder, the purse. What a module does for a one-off (the melee player's building on a mine). Whether it was sent
builderFor
builderFor(type: UnitTypeDef, site: Vec2): EntityState | undefined;Who builds a type at a spot: of the player's units that build it, those not hidden, not building, not sent this think, not off to look at ground and not in a squad or held by a rule; idle first, then whoever carries the least, then the nearest
configure
configure(options: BuildPlanOptions): void;Takes options in, over what it had: the standing wants added, the table of placements merged, the flags replaced
drop
drop(id: string): boolean;Takes a want out, and what a save remembered of it: whether there was one
get
get(id: string): Want | undefined;A want by id
have
have(type: string): number;How many of a type the player has, those under construction and those that count as it included
list
list(): Want[];The wants, in the order added
next
next(type: string): TechStep | undefined;The first step towards a type not had yet, the type's own last: none when nothing is to be done, or the path is blocked
onItsWay
onItsWay(type: string): number;How many of a type are on their way beyond those that stand: builders sent to build one, buildings turning into one, units queued
path
path(type: string): TechPath;The steps to being able to make a type (techPath), worked out once a think
report
report(): BuildPlanReport;Every want as the last think left it, in the order added, the one saving up named
restore
restore(memory: unknown): boolean;Takes back what save gave: whether it was read. The data wants are had again; memory waits for the wants code adds
save
save(): BuildPlanMemory;What it remembers, for a save: each standing want's memory (its code gives the want again), and the wants added as the game went that are plain data, whole. A want that does not stand and has code in it is not kept: the game loaded from the save would not know when the game saved from would have dropped it
savingFor
get savingFor(): string | undefined;The want saving up, as of the last think: the most important one it could not pay for
settings
get settings(): Readonly<BuildPlanOptions>;The plan's options as they stand
site
site(type: UnitTypeDef, request: Omit<SiteRequest, 'ordinal'> & {
ordinal?: number;
}, placement?: PlacementName | PlacementStrategy): Vec2 | undefined;A spot for a type near a place, by a strategy: the one given, else what the type declares (UnitTypeDef.ai.placement), the plan's table by type then by role, the role's default, the rings around the place. What is built on a deposit goes on one whatever the name
status
status(id: string): string | undefined;Where a want stands, in words, as of the last think: building a barracks at (40, 60), saving for a town hall
think
think(): void;The think, once a think: every want measured against what stands and is on its way (met ones dropped, or kept standing), those whose condition holds taken most important first, each advanced by the first step it can take: built, turned into, or saved for. Then the mending, where the plan is to
want
want(def: Want): string;Adds a want, or replaces one of the same id (its memory kept): what the plan works towards from now. Gives back its id. A want with no keep is dropped once met