There’s been a lot of debate around the issue of applying Attack and Defense between unit that are single troops vs. units that are composed of multiple troops. I’d like to take a fairly straightforward, mathematically sound approach to show what the equations “should” look like. I’m going to add two new stats I think are necessary to model the situation. In the next few sections, I'm basically just going to "show my work" for this equation:
Expected Damage = Expected number of hits * Expected damage per hit
Modelling the concepts of "Attack" and "Defense"
Pretend that we host a crazy tournament where everyone fights everyone else in 1-on-1 combat, and we keep records. Not great records, mind you – all we’re recording is, over the course of all of your exchanges, how many times did you launch a successful attack (whether or not it did damage or was deflected), and how many times did you deflect incoming attacks (that would have been successful).
At this point, anyone who never landed a single attack would have Attack = 0, right? The worst attacker who wasn’t useless (who scored a single hit only), would have Attack = 1, and so on. We could think about everyone’s Attack score as being a factor of how much better they are than the guy with the 1. So if my Attack is 10, I’m launching successful attacks 10x more often than the worst guy during my exchanges. Do the same thing with Defense.
Now take two opponents: Pair them together in some large number of exchanges. If one dies, replace him and continue the experiment. The attacker will launch attacks at a rate of “Attack” and the defender will parry those attacks at rate “Defense.” Over a long period, the attacker would successfully land Attack / (Attack + Defense) strikes. [Math Alert: This is based on the equilibrium equation for a two state system that enters the “hit” state with rate Attack*c and returns to the “not hit” state with rate Defense*c. The c cancels out, so we can ignore it]
Neat. What if I have two attackers (and still one defender)? Well, there will be twice as many attacks, but the defender is still only able to defend against them at the same rate. What about 1 attacker and 2 defenders? Without some concept of “teamwork,” each attack the attacker launches is only defended at the rate of the single unit he attacked. What about 2 attackers and 2 defenders? In that case, let’s say they’d pair off, so it would be like having 1-on-1 combat. That means we need to incorporate how many atackers are attacking each defender. We'll define it like this: Overwhelm Factor = Max(1, Num Attackers / Num Defenders). This lets a large number of attackers gang up on a smaller number of defenders, but doesn’t give them fewer attacks when there are more defenders*. The final “Hit Percent” looks like this:
Overwhelm = Max(1, Num Attackers / Num Defenders)
Hit Percent = Overwhelm * Attack / (Overwhelm * Attack + Defense)
*Defenders' number advantage comes into play when calculating hit points.
Incorporating the idea of damage per attack
What this doesn’t talk about yet is damage. To avoid getting too long winded, pretend I did the same thing as above to justify the following definitions:
Armor = The number of times your armor protected you from 1 Hit point of damage.
Damage = The number of Hit points of damage you offered.
From similar logic, we see that the percent of offered damage that gets through the unit's armor is Damage / (Damage + Armor). The actual damage per hit is Damage^2 / (Damage + Armor). Damage and Armor are all about 1 hit, 1 target. Attacker/Defender numbers don’t factor in at all (without additional assumptions).
Adding in bonuses from Morale
Last, let’s look at morale. I’m going to pretend that units with higher morale attack/defend with a higher rate. That would let me define Attacker Morale Factor = Attacker Current Morale / Average Morale and the same for the defender. I could then multiply the Attack and Defense values by the appropriate morale factor. The nice thing is, this clearly means that the balance of power remains the same between two unit that have the same current morale, no matter what the value is.
The unified formula(s)
So here’s the final equation for the average damage inflicted on the defender by the attacker:
Overwhelm = Max(1, Num Attackers / Num Defenders)
Effective Attack = Max(1, Overwhelm * Attack * Attacker Morale / Average Morale)
Effective Defense = Max(0, Defense * Defender Morale / Average Morale)
Hit Percent = Effective Attack / (Effective Attack + Effective Defense)
Successful Attacks = Effective Attacks * Hit Percent
Damage Per Hit = Damage * Damage / (Damage + Armor)
Total damage = Successful Attacks * Damage Per Hit
If I were going to implement this, per attack pass I’d randomly generate an effective value for both Attack and Defense pretending that the base scores were the rates of Poisson distributed random variables. I wouldn’t do that with armor/defense. Then I’d plug and chug and report the final damage.
Obvious extensions
Swarming. These guys get a bonus to attack when they outnumber the defenders. Increase the Overwhelm factor when it’s > 1.
Coordinated Defense. These guys fight as a unit, watching each other’s backs. Reduces overwhelm factor (toward 1) when they’re defending.
Armor piercing. Reduces the Armor value of the target (min 0) in the calculation above.
Frenzy (Special Attack) This unit makes 2 attacks per model, but each attack is at 50% Damage. This would be tactically awesome against large numbers of weaker foes.
Cowards. These guys' have -X morale when they're outnumbered.
Berserkers. These guys' have +X morale when outnumbered.
Dodge. Really it’s just Defense now – no need to specify if you parried/blocked/dodged.
And many, many more.
Gnilbert