# Chance for attacker to destroy a defender?

- Created Tuesday, December 16th 2014 @ 15:05:14
Based off what i read is it effectivly a 30% chance for an attacker to kill a defender?

The rules say a 70% chance for each defending army to destroy one attacking army. Which effectivly means that 30% chance for attacking army to kill defending army?

It also states amnt of defending armies destroy is 60% of number of attackers

how do these two values add up? i dont understand as the number of defending armies destroyed is 60% of the number of attackers

yet the number of attacking armies destroyed is 30% of the defending armies? (as defending armies have 70% chance to destroy attacking armie)

sorry to be so confusing, just need some clarification of the rules

- Created Tuesday, December 16th 2014 @ 15:16:01
I re-read the page as best i could. Is it something along the line of 10 Defenders are gaurentee'd to destroy 7 attackers + a 70% chance for each one to kill an additional attacker, so 10 Defenders will kill 7-14 attackers?

And 10 attackers will kill 6 Defenders + a 60% chance for each attacker 6-12 Defenders dead?

Any clarity on the matter is greatly appreciated :)

- Created Tuesday, December 16th 2014 @ 15:16:34
You need to look at them as separate values. For example if a region with 10 armies attacks a region with again 10 armies we have 10 attackers and 10 defenders.

First we calculate how much defenders are destroyed. Two values are used. The first value is 60% of the attacking armies, which is 6. So if we'd only use this value (a.k.a. 0% luck), 6 defenders would be destroyed. But we have a second value, which is a randomized value. Each attacker has a 60% chance do destroy one defending army, so on average 10 attackers will destroy 6 defending armies, but it could also be 5, 7, or even another value. This value is the value used when luck is 100%, as in the original Warlight AI Challenge. Then it is combined with 16% luck:

`finalValue = (value1 * (1 - 0.16)) + (value2 * 0.16)`

For the amount of attackers destroyed the same calculation is used, except it is based on the amount of defenders and 70% is used instead of 60%.

Hope this helps

- Created Tuesday, December 16th 2014 @ 18:01:14
Straight round, just rounds to the nearest whole number

- Updated Tuesday, December 16th 2014 @ 19:02:14
Thanks for the clarification, jim

Those are very nice settings now:

- If you attack 3v2 then the worst attack outcome is that you kill 1,512 = 2 armies so 3v2 expansion always works
- If you attack 1vX (attack a big stack with 1 army) then you always kill at least 0,504 = 1 army (and you also only lose 1 army)

- Created Wednesday, December 17th 2014 @ 06:49:38
Thanks for that norman, just wrote a small function to get the max attacking armies to destroy X defending armies :), ur insight and jims helped heaps! thank you

- Updated Wednesday, December 17th 2014 @ 23:55:10
I thought I would have figured it out, but am confused now.

Take a look at this game.

In Round 3 there is a move from region 22 to region 28 where 2 attacking armies are killed. In Round 15 from region 2 to 12 as well.

The killed army value is computed as

`finalValue = (value1 * (1 - 0.16)) + (value2 * 0.16)`

In this case for the defender the following should hold for the best case

`armiesKilledByDefender = ( 2 * 0.7 * ( 1 - 0.16 ) ) + ( 2 * 0.16 ) armiesKilledByDefender = 1.496 armiesKilledByDefender = 1`

So either the rounding is off or my calculation is wrong.

- Created Thursday, December 18th 2014 @ 10:27:19
I don't really get it either. Jim, what exactly do you mean with "a randomized value" for value2? A random number from 0.0 to 1.0 multiplied by the number of attackers? So let's do an example: Say I attack with 10 units. Then the worst case would be:

finalValue = (10 * 0.6 * (1 - 0.16)) + 0 = 5.04

So, that means I would kill at least 5 defenders. And for the best case, I assume this is what happens (please, correct me if I'm wrong):finalValue = (10 * 0.6 * (1 - 0.16)) + (1.0 * 10 * 0.16) = 5.04 + 1.6 = 6.64

That means the attackers would kill 7 defenders in the best case. Is that what happens?Also, when calculating the number of attackers that are killed, do the attackers kill defenders before the defenders strike back - so that the number of defenders is reduced before the defenders kill any attackers -, or does this just use the original number of defenders at the start of the attack?

- Created Thursday, December 18th 2014 @ 10:49:33
@Cabbage ok so I actually found a little mistake in my code, which caused the amount of attackers destroyed to be slightly off. I guess that's why we still call it Beta :) It's fixed now though

@Kn0ch3n Your calculations are correct, but value2 is not a total random value. Each attacker has a 60% chance to destroy one defending army. So here's the code to make it more clear:

`for(int t=1; t<=attackingArmies; t++) //calculate how much defending armies are destroyed with 100% luck { double rand = Math.random(); if(rand < 0.6) //60% chance to destroy one defending army defendersDestroyed++; }`

If it's still not clear, check out the Warlight wiki page.

For your second question: it is calculated with the original number of defenders and attackers.

- Updated Friday, December 19th 2014 @ 04:32:38
Just make sure I'm clear on this, assume we have an attack with A attackers and D defenders. A x 0.60 * 0.86 = 0.504 x A Defenders are guaranteed to be destroyed. Then 0.16 x r x A additional defenders are destroyed. The value r comes from a binomial distribution with A trials and a 60% probability of success. So on average, 9.6 x A additional defenders will be destroyed. In total, 0.60 x A defenders will be destroyed on average , and will vary from at least 0.504 x A to at most .0.664 x A. The same holds for defenders but with a 70% chance, so 70% x D on average and from 58.8% x D to 74.8% x D attackers destroyed.

- Created Sunday, December 21st 2014 @ 19:21:40
Is the number of dead attackers calculated after the defenders have been killed?

- Created Sunday, December 21st 2014 @ 19:55:35
No. Killed armies are calculated independently.

- Updated Saturday, December 27th 2014 @ 14:43:37
Lets take the 1 vs 1 outcome:

`attackersDestroyed = 1*.0.16 + 0.7*0.84 = 0.748 defendersDestroyed = 0*.16 + 0.6*.084 = 0.504`

If the amount destroyed is rounded first => they are both 1,0 and therefore the attacker wins (always). Otherwise, the attack will always fail. So when is the rounding applied?