# How to calculate the outcome of a battle?

My game's war system is pretty straightforward, so I will give you a brief overview. You assign soldiers to commanders, and you also assign equipment. Equipment being weapons (e..g: rifles, pistols, etc ...) and vehicles (e.g.: tanks).

If a commander has 10,000 weapons in their inventory, and they only have 5,000 soldiers, then there will be 5,000 unused weapons in the commanders inventory. These unused weapons will not have any affect on the battle, but are still at risk to be lost during the fight (so it would actually be rather unwise for the player to assign that many weapons).

If a commander has 1,000 tanks - tanks require 3 soldiers - in their inventory, then the commander will need at least 3,000 soldiers to be able to use every single tank in battle.

If there are more soldiers than there are weapons and vehicles, then there will be some soldiers who are not assigned a vehicle or weapon, and so they will fight with their base/default stats.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now for the actual mechanic that I seem to be struggling with:

Every soldier, weapon, and tank only has two variables that are used or considered in battle: attack & power.

Say a tank has 70 attack and 100 defense, and a rifle has 15 attack and 0 defense. These stats will be ADDED to the soldier's base stats.

Assuming that there is only the attacker's commander vs. the defender's commander of a city, no external forces or variables, I could simply calculate one commander's total combined attack & power, and if it's greater than the other commander, then I should declare him the winner.

Whether this is the best method for this I'm not sure yet.

But my current question is, how do I determine losses? How do I determine how many soldiers, weapons, and tanks either commander has lost during the fight?

First, your suggestion that a simple comparison of the forces should determine the outcome of the battle is completely historically accurate. Most battles are determined by the relative strengths of the forces going into the conflict. In the rare event of a weaker side winning, due to good fortune or good generalship, it will be spoken about more often, giving the wrong impression that this is a common event.

It seems to me there are two ways to calculate losses:

"Game world" Frequently in the world of gaming it seems to me that the losers are wiped out entirely. Each battle is thus a fight to the death for the opposing forces.

"Real world" In the real world, a battle might be lost, but (and this really depends on many things) in many cases about 90% of the manpower survives, from ancient to modern times. Some wars have seen 50% of ground troops killed (but far less for artillery and other branches) but this is after they have participated in many battles, or the insane over-the-top policies of World War I trench warfare.

When it comes to taking a city, it really depends on whether or not the city is in a siege situation. This was much more common in the fortified towns of medieval times. Part of the reason why the World War II battles of Stalingrad and Berlin are so famous is their dramatic quality - both involved a siege situation with no escape for the defenders. This, however, is not the normal fare, and retreat from a city is much more common with most of your troops intact.

Before making a suggestion of how to calculate the matter it is important to know how the game play occurs. It sounds like a simple calculation is made and there is no time passing for the players during a battle. If there was time passing (a battle 'in progress' as it were) then one side could pull out as they see how the battle is going. That does not seem to be how your game goes.

How many survive ("real world" now) depends on whether or not the defending troops can get out if they lose, which is normally the case. Also, a general will suffer greater losses if they think the battle is worth more, or they just bloody well want to beat the other guy, so this is a possible user setting you might consider going into the battle ('enthusiasm'?).

Calculate the attacker's total attack force and and the defender's total defense force. If it is a fight to the death (the simplest calculation) the loser ends up with 0, and it is not unreasonable to say that the winner's remaining resources adds up to the original difference between the two. Lets say the winner has 10000 points worth of material left over (whether attacking or defending). You have three choices:

1. Distribute evenly based on the proportions of the forces going in. If half of the winner's points when they went into the battle were tanks, then half of them are left over.
2. Distribute randomly: it does not matter how many were tanks entered the fray, but be careful that no more than this number comes out!
3. Distribute based on opposing forces. If 100,000 tank attack points met 70,000 tank defender points and the defenders lost, then 30,000 points worth of tanks remain to the victor. BUT! The attackers may have lost the overall battle, so this is trickier to implement.

I tend towards the last one, though I frequently make life more difficult for myself! The first is the most straightforward.

Finally, if it is not a fight to the finish, then any of these choice can be applied to a proportionate loss in each sides forces. How about deciding the winner the same way (simply comparing forces, this is presumably fine if each side does not know how many the other is investing). Defenders have a certain advantage (as long as they can run away in the event of a loss) but you already reflect this in the attack/defense point awarded to each element. This is where I would argue with your awarding 0 defense points to a rifle. In fact, if dug in, a rifle has more defense value than attack value. Ask the snipers left behind to help troops evacuate a lost city!

This nod to the real world, where each battle is not a wipe-out, is also easy to calculate. Perhaps 90% survival is too slow for your game (or maybe it means the games are not stupidly short!?!?), but you could experiment with other proportions - winners retain 75% of forces, losers retain 60% (losers would normally retreat before being overrun or surrendering). Then apply one of the three methods listed above to the remaining forces.

The only way to really test the correctness of the proportions you choose is by trying it out by playing the game with those numbers. The wipe-out approach could ruin games with only a few cities, but might simplify games with dozens of cities. In the proportionate approach, retaining 90% of forces each time might be too slow, but too low might as well have a wipe-out. Also, if both sides only lose the same proportion (say 50%) this is really a loss for the greater force which has lost more (though this is frequently the case - see here).

I hope this has been of some use.

i'd take a "decimate" approach. Since you know the exact power and quantity of both sides you could simply get the "succesfull rate" for each point, will explain.

if i had 1000 soldiers in each side but the first side had some weapons (100), then whe would have 2500 pts vs 1000pts. Then, we could know that, for every second side "hit", the first side would hit 2.5 times. so, since our base (soldiers) is 1000 for both sides, at the end og the battle first side would still having 600 units (1000 - (1000 / 2.5)) and second side would be erradicated.

About the riffle/tank lost, i would make kind of "estimation" approach, say we have the situation said above. then we would have 1 riffle for each 10 soldiers, so, when we lose 10 soldiers we have to remove 1 riffle, that means that, in the case above, the would be 40 lost riffles. But this is not "accurate" since soldiers can take up lost's friend's guns and use themselfs or a lucky grenade could put 2 or 3 rifflemen out of combat, so i would randomizate it with an "error", so, if the "average" that we lose 1 riffle for each 10 soldiers, lets say that, in this actual battle will be lost Random( (soldiers / rifles) * 0.8, (soldiers / rifles) * 1.2).

So we would have a random number in a thight enough range.

Hope it helped