Announcement

Collapse
No announcement yet.

Military coding status

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Military coding status

    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.
    Clash of Civilization team member
    (a civ-like game whose goal is low micromanagement and good AI)
    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

  • #2
    Example

    Suppose defender has 1 bowmen unit and one legion unit in rolling hills.
    Attackers are 2 hordes.
    This translates, in terms of element, to:
    Defender = 7 heavy spears, 3 skirmishers, 1 engineer, 9 archers.
    Attacker = 16 warriors, 4 cavalry skirmishers.

    Scout phase: Same number of elements, no scouts so 15% for defender.

    Manoeuvre phase:
    There will be fights between 3 defender skirmishers and 4 attacking cavalry skirmishers. The fight has 30% chance to last 1 round, so let's suppose it is thus. Without detailing, it is probable that there will be some wounded but no destroyed element.
    Skirmishers have mobility 5, cavalry skirmishers 7. We are however in hills, thus these are reduced as attack strength, so: 5/1.25 and 7/1.5
    The manoeuvre values are:
    Scout output * (2*number of elements + half skirmisher mobility):
    Defense: 1.15 * (40 + 12) = 59.8
    Attacker: 0.85 * (40 + 18.67) = 49.87
    Manoeuvre output = 9,93% in favour of defender. Add square root of 15% for a total of 13,08%.

    Since defenders have the best manoeuvre, their engineer manages to build field defenses for 1 bonus.

    Rounds of fight:
    Since the attackers all want to go to front line, all elements will end there,
    even though engineers and archers would have preferred being behind.
    Fights start at long range. Distance attack strength is used here:
    Archers have 60, skirmisher 30, cav skirmishers 20, warriors 5, the rest 0.
    Thus, heavy spears and engineers deal no damage at this range.

    For an archer, the attack value will be at this range: 60/1.25 * 1.1308 = 54.28
    For a cav skirmisher it will be: 20/1.5 * 0.8692 = 11.59.
    Defense for an archer is 30, armor 1 (add 1 to defense because of engineer for 31). For a warrior, defense = 20, armor 2.
    Thus if an archer attacks a warrior, he deals 54.28/400 damage if he hits, i.e. 0.1357. (Elements usually have health of 1).
    The warrior will deal only 11.59/310 = 0.038 (aka peanuts).
    Average frontline mobility is around 5, and both armies want to close, since they all have better attack values than distance values. They will meet in melee after around 6 rounds of fight at long range.

    At melee, spears suddenly become useful with their 80 attack and will crash the warriors (attack 20 - defense 20 armor 2) and cavalry skirmishers (attack 40 - defense 40 armor 1) while the archers are quite pitiful now (attack 15 - defense 30 armor 1).

    Morale checks go after each round, for each element, but all this is already quite complicated so I stop here for the night.
    Clash of Civilization team member
    (a civ-like game whose goal is low micromanagement and good AI)
    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

    Comment


    • #3
      Hi Laurent, thanks for the detailed example, its very helpful for me.

      It seems the engineers don't help much as currently valued. FE you would be better with another heavy spear... We can of course re-balance later, but it looks to me like engineers need to be like 3x as effective to be anywhere near a good deal.

      Thanks again!

      -Mark
      Project Lead for The Clash of Civilizations
      A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
      Check it out at the Clash Web Site and Forum right here at Apolyton!

      Comment


      • #4
        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.
        That is done. I saw an archer with 0.5 health deal damage to a big army and remained unharmed, so I bet he managed to flee. He was kind of killed when I brought a healthy archer to deal with it, though.

        I also changed the xml file so that all land units require (and benefit from) Military Tactics. Maybe warriors shouldn't, but that way even they become better fighters when tactics get better.
        Clash of Civilization team member
        (a civ-like game whose goal is low micromanagement and good AI)
        web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

        Comment


        • #5
          Status update as of pre-Demo 7.
          Odds to attack and defend are now taken into consideration. Each tactical order has a figure which tells whether the element wants to attack or defend given certain odds. Typically, attack is at 1.5 vs. 1 or better, and defense is 1 vs. 2 or better.
          After each round of fight, elements are checked against the odds. If the odds are less than the figure, attackers have 25% chance of fleeing each round. Defenders have 0 for now.
          At the end of the fight, these figures are checked again, and, if the odds are bad, the army is considered to have lost its fight.
          When an army loses a fight, each of its units flees the square to its previous square. Note it flees through orders, which means they don't teleport away, but move at their normal rate. That means they will need some time to leave the square and their opponent will be able to attack them again during the flight.

          All this is subject to tuning based on gameplay. When the Delenda scenario is working, I will test extensively and adjust the 25%/0% figures. These figures are here only to allow non lethal fights but still enable the player to get rid of their opponents' units.
          Clash of Civilization team member
          (a civ-like game whose goal is low micromanagement and good AI)
          web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

          Comment


          • #6
            At present, in the Dawn scenario, all my units retreat every turn, even when I outnumber the enemy 2 to 1. This is frustrating.

            Note it flees through orders, which means they don't teleport away, but move at their normal rate. That means they will need some time to leave the square and their opponent will be able to attack them again during the flight.
            It also means that the owner can cancel the orders and make them fight on.

            Cheers

            Comment


            • #7
              Here is a small update. I will be able to send the files someday (must still sort things out to get an internet connection at home ):

              Militia is coded so that, when a defender is outnumbered but there is sufficient population that it believes its odds are good enough to change the fight outcome, a militia is formed out of the populace, as the best militia-able element available (i.e. warriors). Playtesting showed it could change a fight outcome, but not necessarily, and any damage dealt to the militia reduces the population of the square accordingly. Note I said that it was the defender who was helped, which is a bad thing when you want to reconquer your home cities, but I don't have the necessary ethnic stuff plugged to do better now.

              Walls and sieges are mostly coded. Right now, the attacking party always attacks immediately instead of trying to starve the defender because a starving model is not available. I also think we should wait for cities to have their own in-square square before we do it, because starving a whole square seems wrong. I also lack a way to build walls through econ orders, so walls are created in the scenario file right now (I put wood walls around Rome and Carthage in the Delenda scenario). The effect is not very easy to notice, however it exists, but you have to attack with around 2 vs.1 odds in order to lose the fight instead of winning, so the probability that this happens in a small scenario with two walls is small, and you may not notice that you took a city but suffered more losses than could be expected because of the walls.

              I will try to put details on how this works when I promote the code, just in case I change things in the meantime.
              Clash of Civilization team member
              (a civ-like game whose goal is low micromanagement and good AI)
              web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

              Comment


              • #8
                Thanks for the update Laurent, your approaches sound good to me. Once I get the code with the buildable object for city walls, making it so we can build them with the economy is no biggie. Maybe a step above wooden walls would be good too.

                you may not notice that you took a city but suffered more losses than could be expected because of the walls
                I think that's what the battle descriptions are for. Also with better than wooden walls the difference between walls and no walls should be much more apparent!
                Project Lead for The Clash of Civilizations
                A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                Check it out at the Clash Web Site and Forum right here at Apolyton!

                Comment


                • #9
                  Militia

                  Militia works thus:

                  If a fight occurs in a square (1 unit of 2 different civs at least), then each ethnic group in the square checks the following:
                  Which side do they want to win? They choose the one which oppresses them less (at lest twice less than the other civ).

                  Odds of victory are checked: The ratio allies/enemies is computed roughly. If 1.75 or more, the allies don't need militia. Otherwise:
                  1/5th of the population is militia-able. They can turn instantly into the best <miitia/> unit available to their chosen civ. If they did so, that would change the strength ratio. If the new ratio + (random between 0 and 1) is 1.75 or more, they will fight.
                  This means they may fight lost causes (high die roll), but not desperate ones (never at less than 3/4).

                  Note that each ethnic group does its own computation, and so various ethnic group ignore what the others will do, which can totally foil the odds computations. And I think it is a good thing, too.
                  Clash of Civilization team member
                  (a civ-like game whose goal is low micromanagement and good AI)
                  web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                  Comment


                  • #10
                    Sieges

                    Sieges happen when there are walls in a square.

                    The current model should be refined because it doesn't take starving into consideration.

                    Now, attackers seeing walls won't attack unless they have at least twice as much power as the defender. Defenders will not move out of the walls unless they are twice as powerful as the attackers, too.

                    Walls add a defense bonus to defenders, and prevent attackers from flanking. That is all they do.

                    Walls also have a health value, and can be breached.
                    A wall has hit points and an armor value. Breaching weapons have a breach and armor piercing value.
                    Damage dealt to walls by breachers is proportional to:
                    breach / (max(1,armor - armor piercing)).
                    When walls are breached, they disappear. In the first release, they don't disappear, but they no longer provide defense bonus.

                    So when a siege happens, breacher weapons strike at the walls, while other attackers foolishly attack the guys behind the walls, who in turn defend themselves. Being busy fighting the attackers, they usually don't have time attacking the breachers until most of attackers are gotten rid of.
                    That should change so attackers wait for walls to be breached before charging. Complain in the Military Model or Siege thread.
                    Clash of Civilization team member
                    (a civ-like game whose goal is low micromanagement and good AI)
                    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                    Comment


                    • #11
                      Miscellaneous

                      I updated the code so there is a pyrrhic factor after each tick of fight:
                      A proportion of the casualties is healed at the end of the fight. This proportion is healed only for those who didn't lose (tie or winners). They represent wounded and those who fled and managed to come back on the field feigning to have attacked the enemy's flank in a daring manoeuver. For losers, wounded soldiers disappear and deserters too. No population is added to the square or whatever, but maybe some should? Discuss in the Military Model thread if you have an opinion.

                      Also note I made other figures confiigurable, mainly the amount of damage dealt (a customisable divider replaces the 10 that existed before), the length of a fight (maximum number of rounds in a tick) and the distance to be covered between ranges in order to get nearer.
                      Clash of Civilization team member
                      (a civ-like game whose goal is low micromanagement and good AI)
                      web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                      Comment


                      • #12
                        Thanks for bumping this thread. It is the military model overview I have been looking for. Now I know what the numbers mean. For example, I thought that the Distance value had something to do with how fast the unit moved.

                        Comment


                        • #13
                          -bump-
                          Last edited by alms66; December 28, 2004, 12:01.

                          Comment


                          • #14
                            I'm going to close this thread b/c things that are settled in the most recent Mil VI thread are under active discussion in this thread, and people might get mixed signals unless they pay careful attention to dates of posts.

                            As usual, let me know if there's an overriding need to have it re-opened.

                            -Mark
                            Project Lead for The Clash of Civilizations
                            A Unique civ-like game that will feature low micromanagement, great AI, and a Detailed Government model including internal power struggles. Demo 8 available Now! (go to D8 thread at top of forum).
                            Check it out at the Clash Web Site and Forum right here at Apolyton!

                            Comment

                            Working...
                            X