Here are some initial comments…
140 inf vs 100 inf
Attacker victory - 100.033%
defender victory - 0.451%
It’s above 100%!
And this is weird since the battle should be 50/50. (14 inf vs 10 inf gives the defender 53/47%)
100 armor vs 100 armor - give a 100% chance of a draw.
I’m impressed that this calculates real odds, instead of simulating them. Ahh the power of the CPU. I once wrote a risk odds calculator that used an iterative function, is that what you’re doing? Risk is a lot easier - as there is only one unit.
You might need to start simulating battles at a certain cutoff point, to avoid freezing the program. Or let the user know what the maximum number of units is.
You might think 100 vs 100 unit battles is an extreme, but they do happen in online play.
…
Can you calculate an average IPC loss for the attacker and defender? Frood’s calculator does this and it is an excellent indicator of whether a battle is profitable.