This thread's objective is to explain what is currently coded in the demos in terms of military model.
Replies to this thread should concern precisions on the model, equations used etc., and updates of the code. Questions on code details are welcome. More general discussions, like unit values or their links with tech, should stay in the Military Model thread.
The armies are divided in units and elements, each of them having several stats, mainly attack, defense, distance strength, health and cost. Each element is also capable of certain actions, like Scouting (none yet), Skirmishing (Skirmishers, Cavalry Skirmishers), Building (Engineers), Support fire (archers).
Fights take place when armies of opposing civs meet in a square.
Phase 1: Scouting
Defenders get a 15% bonus to this phase. Scout elements give a bonus too, and higher numbers give a bonus.
The result of this phase is an input to phase 2.
Phase 2: Manoeuvre
Each element with Skirmish or Scout ability participate in limited fights. At the end of these fights (1 round, 30% to end, then 40% to end after round 2, +10% per round), the manoeuvre value is computed: 2 * total number of elements + 1/2 * mobility of skirmishers, modified by scout output. To this, the square root of scout output is added.
For example, if there are 10 elements (1 healthy unit) on each side, the defender has 20 * 1.15 (scout bonus) = 23, and attacker has 20 * (0.85) = 17, for a final result of 6 in favor of defender. To this, add square root of 15, it gives a 10% bonus to defender in the phase 3.
The army which gets the best manoeuvre value, if they have units who can build (engineers), build fortifications. These fortifications add a bonus of 1 to defense to each element per builder element. Note in Krenske's model, the bonus depends on the number of rounds of fights during this phase but I skipped that part.
Phase 3: Assault
Phase 3.1- Matching:
Units are matched as described in the Military Model V thread:
Elements are dispatched in their preferred position: Front line (most), Support (archers), Reserve (engineers). The front lines must be at least as numerous as support, which must be more or equal than the reserves. If an army has inferior numbers, the support elements are brought to front line and reserve to support. If that is not enough, the elements will be outflanked.
Phase 3.2- Rounds of fight:
Fights start at long range. (Fights are fought each round as described here, then each army which wants to progress advances.)
Elements in first line fight each other. If outflanked, an element may be attacked twice. Attack strength is computed as follows: attack value divided by a factor depending on terrain (always >= 1): For foot units, it is e.g. 1.25 in rolling hills, for non foot units, the malus is doubled (1.5 in the example). To this is added fire support from archers, and the result is multiplied by the output of manoeuvre phase.
The fire support bonus is: sum of support element distance attack stength divided by number of front line elements. This means fire support is an even division of distance attack strength considered as a bonus to attack strength of attacker element.
Thus: Attack = (attack / terrain modifier + fire support) * manoeuvre mod
For example, 5 chargers with attack 80 supported by 2 archers of distance strength 60 in rolling hills against 5 heavy spears (attack 75), where the spears have a manoeuvre bonus of 10%:
Chargers: Attack = (80/1.5 + 60*2/5) * 0.9 = 77.3 * 0.9 = 69.6
Spears: Attack = (75/1.25) * 1.1 = 66
The attack scores are then divided by the respective defense, which is:
(Defense + training + fortifications + order bonus) * armor
Armor is modified by armor penetration of attacker.
Order bonus allows for fortification order to give a bonus to defense. It could be a multiplier.
Chance to hit is 10% + 4% * training. If a hit is scored, damage equal to (attack/defense)/10 is dealt to defender.
The chargers and spears have defense 20, armor 2. If the heavyspears benefitted from one enginer element, the result would be 40 and 42 defense, thus damage on successful hits of:
Chargers deal 69.6/42/10 = 0.1658 damage.
Spears deal 66/40/10 = 0.165 damage.
In this example, spears will probably lose because when elements are dispatched, the chargers will have better bonus from the archer and deal more damage, even though the damage here are roughly equal.
Actaully, attack strength may be even more divided if the element is outnumbered, typically outflanked, but also if it has a large frontage, e.g. rifles vs. impis.
Phase 3.3- Morale.
Each element computes its morale: Morale + training + mobility/2, multiplied by the ratio of army strengths (i.e. if outnumbered 10 to 1, morale is divided by 10), then divided by 20 (an average morale+ mobility/2 will be 10+). Added to 0.5, this gives the chance to keep ground. Thus an average element keeps ground 100% of the time unless outnumbered, but only 55% per round if outnumbered 10 to 1. This means he will probably try to flee while the army is still fighting at long range.
The chance to flee is 0.1 + 0.5 * ratio of strengths, which means an outnumbered element will have trouble finding its way out. I realise this is meaningful only in melee, so it will be 1 at any range longer than melee within a few minutes when I code it.
Fleeing armies are removed from the fight but remained in the square. This should change soon, as they should move out of the square if their army is beaten.
Phase 3.4- Advance.
The 3.2 phase is a round. It first takes place at long range, with distance attack strength for all. This means archers are those who deal most damage at these ranges. Currently, there is only one distance attack strength, but there will be more. Distances are long, medium, short range and melee. Attackers and defenders want to close if they will have a better attack strength at shorter range. The range advances were automatic in Krenske's model, which led to lots of fights at melee range. I changed this: To advance in range, 20 points must be totalled. If attacker wants to advance, they add their average front line mobility points. The same for defender with a bonus of 1 (considering they have a better knowlege of terrain and such). Each time 20 is reached, the range changes, remaining points being used for next range change.
Miscellaneous
There is a maximum of 30 rounds of fight per encounter, so that fights are not fought to the death. However, there are 10 ticks per turn, so 2 armies which started the turn in the same square and don't move will probably fight 10 times 30 rounds.
That is all for now.
Replies to this thread should concern precisions on the model, equations used etc., and updates of the code. Questions on code details are welcome. More general discussions, like unit values or their links with tech, should stay in the Military Model thread.
The armies are divided in units and elements, each of them having several stats, mainly attack, defense, distance strength, health and cost. Each element is also capable of certain actions, like Scouting (none yet), Skirmishing (Skirmishers, Cavalry Skirmishers), Building (Engineers), Support fire (archers).
Fights take place when armies of opposing civs meet in a square.
Phase 1: Scouting
Defenders get a 15% bonus to this phase. Scout elements give a bonus too, and higher numbers give a bonus.
The result of this phase is an input to phase 2.
Phase 2: Manoeuvre
Each element with Skirmish or Scout ability participate in limited fights. At the end of these fights (1 round, 30% to end, then 40% to end after round 2, +10% per round), the manoeuvre value is computed: 2 * total number of elements + 1/2 * mobility of skirmishers, modified by scout output. To this, the square root of scout output is added.
For example, if there are 10 elements (1 healthy unit) on each side, the defender has 20 * 1.15 (scout bonus) = 23, and attacker has 20 * (0.85) = 17, for a final result of 6 in favor of defender. To this, add square root of 15, it gives a 10% bonus to defender in the phase 3.
The army which gets the best manoeuvre value, if they have units who can build (engineers), build fortifications. These fortifications add a bonus of 1 to defense to each element per builder element. Note in Krenske's model, the bonus depends on the number of rounds of fights during this phase but I skipped that part.
Phase 3: Assault
Phase 3.1- Matching:
Units are matched as described in the Military Model V thread:
Elements are dispatched in their preferred position: Front line (most), Support (archers), Reserve (engineers). The front lines must be at least as numerous as support, which must be more or equal than the reserves. If an army has inferior numbers, the support elements are brought to front line and reserve to support. If that is not enough, the elements will be outflanked.
Phase 3.2- Rounds of fight:
Fights start at long range. (Fights are fought each round as described here, then each army which wants to progress advances.)
Elements in first line fight each other. If outflanked, an element may be attacked twice. Attack strength is computed as follows: attack value divided by a factor depending on terrain (always >= 1): For foot units, it is e.g. 1.25 in rolling hills, for non foot units, the malus is doubled (1.5 in the example). To this is added fire support from archers, and the result is multiplied by the output of manoeuvre phase.
The fire support bonus is: sum of support element distance attack stength divided by number of front line elements. This means fire support is an even division of distance attack strength considered as a bonus to attack strength of attacker element.
Thus: Attack = (attack / terrain modifier + fire support) * manoeuvre mod
For example, 5 chargers with attack 80 supported by 2 archers of distance strength 60 in rolling hills against 5 heavy spears (attack 75), where the spears have a manoeuvre bonus of 10%:
Chargers: Attack = (80/1.5 + 60*2/5) * 0.9 = 77.3 * 0.9 = 69.6
Spears: Attack = (75/1.25) * 1.1 = 66
The attack scores are then divided by the respective defense, which is:
(Defense + training + fortifications + order bonus) * armor
Armor is modified by armor penetration of attacker.
Order bonus allows for fortification order to give a bonus to defense. It could be a multiplier.
Chance to hit is 10% + 4% * training. If a hit is scored, damage equal to (attack/defense)/10 is dealt to defender.
The chargers and spears have defense 20, armor 2. If the heavyspears benefitted from one enginer element, the result would be 40 and 42 defense, thus damage on successful hits of:
Chargers deal 69.6/42/10 = 0.1658 damage.
Spears deal 66/40/10 = 0.165 damage.
In this example, spears will probably lose because when elements are dispatched, the chargers will have better bonus from the archer and deal more damage, even though the damage here are roughly equal.
Actaully, attack strength may be even more divided if the element is outnumbered, typically outflanked, but also if it has a large frontage, e.g. rifles vs. impis.
Phase 3.3- Morale.
Each element computes its morale: Morale + training + mobility/2, multiplied by the ratio of army strengths (i.e. if outnumbered 10 to 1, morale is divided by 10), then divided by 20 (an average morale+ mobility/2 will be 10+). Added to 0.5, this gives the chance to keep ground. Thus an average element keeps ground 100% of the time unless outnumbered, but only 55% per round if outnumbered 10 to 1. This means he will probably try to flee while the army is still fighting at long range.
The chance to flee is 0.1 + 0.5 * ratio of strengths, which means an outnumbered element will have trouble finding its way out. I realise this is meaningful only in melee, so it will be 1 at any range longer than melee within a few minutes when I code it.
Fleeing armies are removed from the fight but remained in the square. This should change soon, as they should move out of the square if their army is beaten.
Phase 3.4- Advance.
The 3.2 phase is a round. It first takes place at long range, with distance attack strength for all. This means archers are those who deal most damage at these ranges. Currently, there is only one distance attack strength, but there will be more. Distances are long, medium, short range and melee. Attackers and defenders want to close if they will have a better attack strength at shorter range. The range advances were automatic in Krenske's model, which led to lots of fights at melee range. I changed this: To advance in range, 20 points must be totalled. If attacker wants to advance, they add their average front line mobility points. The same for defender with a bonus of 1 (considering they have a better knowlege of terrain and such). Each time 20 is reached, the range changes, remaining points being used for next range change.
Miscellaneous
There is a maximum of 30 rounds of fight per encounter, so that fights are not fought to the death. However, there are 10 ticks per turn, so 2 armies which started the turn in the same square and don't move will probably fight 10 times 30 rounds.
That is all for now.
Comment