Strength beta
Class of @v12-engine/engine/ai
export declare class StrengthHow strong things are, to a brain (AiView.strength, Brain.strength): one unit or type (of), a group (sum, what UnitSet.strength() asks), one force against another (matchup, odds), and what to train against what was seen (counterFor). The formula is the kit's (defaultStrength) unless the brain was given one (AiOptions.strength, BrainDef.strength); a type's declared strength (UnitTypeDef.ai.strength) goes before either. What a type's numbers come to is worked out once and kept across thinks; a seen unit's own stats (EntityState.stats: its upgrades, items, levels, buffs) are read each time
Members
constructor
constructor(
registry: Registry,
formula?: StrengthFormula);Constructs a new instance of the Strength class
counterFor
counterFor(enemies: Force, candidates: readonly (UnitTypeDef | string)[]): Counter[];What answers a force best among some types: each with its strength against them over its plain strength (1 is as good as against anyone, 0 cannot hit them, above 1 is the answer), the best first, equals in the order given. Against nothing, every type scores 1
countersOf
countersOf(type: UnitTypeDef | string): readonly {
target: string;
weight: number;
}[];What a game declares a type good against, as { target, weight } each
formula
readonly formula: StrengthFormula;The formula a unit's strength comes from: the kit's unless the brain was given one
matchup
matchup(a: Force, b: Force): Matchup;One force against another: the strength of each of a's units against b (what it cannot hit counts for nothing of its damage; its damage meets their armour, theirs meets its; what it is declared to counter weighs it up), summed. matchup(a, b).strength / matchup(b, a).strength is how a compares; odds turns it into a chance
odds
odds(a: Force, b: Force): number;The chance that a beats b in a fight to the end, 0..1: A² / (A² + B²) of the two matchups (Lanchester's square law: numbers count twice, since each unit both deals and takes). 0.5 for a mirror, and when neither can hit the other. An estimate: it reads stats, layers, armour and declared counters, and knows nothing of spells, terrain, focus fire, who shoots first or who runs; the plan's E3 checks it against fights played out, and a game that knows better gives its own formula (AiOptions.strength)
of
of(what: EntityState | UnitTypeDef | string): number;How strong a unit is, with the health it has left and its own stats as the snapshot shows them; or a type at full health with the stats it starts with. 0 for what does not fight. A finite number always
registry
readonly registry: Registry;The game's definitions
statsOf
statsOf(entity: EntityState, def?: UnitTypeDef): Readonly<Stats>;The stats of a seen unit as they stand: its type's, with its own over them (EntityState.stats: upgrades, items, levels, buffs)
sum
sum(force: Force): number;How strong a group is: the strength of each, summed