Fight value
Every creature has a hard-coded "fight value," a number summarizing its worth in combat. The fight value is used quite often The fight value of a stack is simply the fight value of the creature times the number of creatures in the stack.
Effects
Heroes II chooses which spell to cast by computing a "heuristic," how many "points" it thinks casting a spell is worth, and picking the spell and target with the best heuristic.
Many spells add or remove stack-modifying effects. There are fifteen such effects in HoMM II -- slow, haste, blind, bless, curse, berserk, paralyze, hypnotize, dragon slayer, blood lust, shield, the Medusa's petrify, anti-magic, stoneskin, and steelskin. The AI will compute a heuristic for how much the effect helps the creature, and use this to help compute its heuristic for casting a spell that will add or remove that effect.
Here's how the heuristic for the various effects are computed:
General: If the target has Berserk or Hypnotize already on it, then the heuristic for all effects except Anti-Magic is 0. Otherwise, the AI computes some number relating to the usefulness of a cast, and obtains the heuristic by multiplying that by the fight value of the stack, and then by a weight. Here are the weights:
Code: Select all
Haste: 0.1
Slow: 0.1
Blind: 0.4
Bless: 0.45
Curse: 0.45
Berserk: 0.55
Paralyze: 0.5
Hypnotize: 0.65
Dragon Slayer: 0.28
Blood lust: 0.14
Shield: 0.45
Petrify: 0.25
Anti-Magic: 0.2
Stoneskin: 0.16
Steelskin: 0.28
Slow and Haste: If the potential target is adjacent an enemy creature, the heuristic is 0. Else, it estimates how many turns the creature will take to cross the battlefield both with and without the effect, and takes the difference. The heuristic is obtained by multiplying that difference by the weight and fight value.
Bless and Curse: First, it computes the difference of the creatures max (Bless) or min (Curse) damage and its average damage. Multiplying that difference by the weight and fight value gives the heuristic.
Dragon Slayer: If the potential target is adjacent a dragon, let x=1. Else, let x be the proportion of hostile creatures which are dragons. The heuristic is then x times the weight and fight value.
Shield: The heuristic is the proportion of hostile creatures which are shooters (with a small bonus for castle combat), times the weight and fight value.
Everything else: The heuristic is the product of weight and fight value.