Announcement

Collapse
No announcement yet.

Complete combat rules needed

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Complete combat rules needed

    I am currently working on a combat calculator that will calculate the odds for each outcome of a given combat. To do so I need to know all the combat rules precisely.

    Here is what I know:

    The combat is divided into rounds. These round continue until one of the following outcomes happens:

    -Attacker hp reduced to zero
    -Defender hp reduced to zero
    -Attacker retreats
    -Defender retreats

    For each round, the following results are possible:

    -Attacker damages defender by one hp
    -Defender damages attacker by one hp
    -Attacker retreats (if possible)
    -Defender reatreats (if possible)

    Known: Attacker has a chance to retreat if it has a movement rating > 1 and the defender has a movement rating = 1. The chance of retreating is dependent only on the attackers rank.

    Question: I am pretty sure that the attacker can never retreat on the opening round. Also, I am pretty sure that the attacker must have one hp left, and the defender must have more than one. Is this right?

    Question: how does defender retreat work? I know that you have to have the defender movement >1 and attacker movement = 1. Does the defender have to have a movement point left? A full movement point? In other words, suppose the defender, a cavalry, had used 2 full movement points plus two road movements the previous turn. Can it retreat into mountains when attacked on the next turn?

    Known: Assuming that a retreat did not occur, either the attacker or the defender takes one hp of damage. The chance of the attacker taking damage is:

    D/(A+D)

    where A=modified attacker attack rating, and D=modified defender defend rating.

    Similarly, the chance of a defender taking damage is

    A/(A+D).

    Let chance of attacker retreat be AR, and chance of defender retreat be DR. If I am right about the rules of defender retreat, then only one of these is not zero. So the chance of retreat is AR+DR.

    Now we have all the odds for each round:

    Attacker damages defender: A/(A+D)*(1-(AR+DR))
    Defender damages attacker: D/(A+D)*(1-(AR+DR))
    Attacker retreats: AR
    Defender retreats: DR

    The modified attack and defense ratings are pretty straightforward. I am aware of that the bonuses are added linearly, not geometrically. I have included things like advantages vs. barbarians based on playing level.

    Another question: how does rank effect the combat. Here is what I think I know:

    -Higher rank = higher potential hp
    -Higher rank = better chance of retreat

    Anything else?

    I know that this is a bit disjointed, so sorry in advance. Any clarifications and additions are welcome.

    By the way, I am only doing it for land battles without armies. Armies seriously complicate things, and are not used as much anyway. I also am not taking into account the artillery shot at this time. I realize that is a shortcoming. Anyone know the rules for it?
    Got my new computer!!!!

  • #2
    I like your initiative, so I hate to inform you that most of that has already been done. At least without the retreat odds. As for Armies, I once wrote one, but it doesn't deal with armies versus armies.

    I'm attaching both in a zip file.

    Answers to your questions:
    Question: I am pretty sure that the attacker can never retreat on the opening round. Also, I am pretty sure that the attacker must have one hp left, and the defender must have more than one. Is this right?
    The mobile unit (which can be the attacker or the defender) cannot retreat if the other unit has 1HP left, or if the combat started with the mobile unit already at only 1 HP.

    Question: how does defender retreat work?
    Exactly like the attacker retreat. The MP left don't matter. The defender can't be fortified to retreat though.

    Another question: how does rank effect the combat. Here is what I think I know:

    -Higher rank = higher potential hp
    -Higher rank = better chance of retreat

    Anything else?
    Nothing else, except that elites give leaders.
    Attached Files

    Comment


    • #3
      a-man:

      Thanks!

      I was quite sure it had been done before. I am doing it for my own edification. I'm doing an Excel VBA program, with all of the tables in worksheets so that the data can be easily modified for patches and mods, and so that all the source code can be viewed and modified. Also, Excel is ubiquitous and stable.

      I will post it here when I am done for comments on, and ridicule of, my spaghetti code.

      Haven't looked at your calculators yet, will do so now.
      Got my new computer!!!!

      Comment


      • #4
        You're welcome.

        BTW, the HTML single-unit calculator is not mine (I got if from CivFanatics I think), just the Army one.

        Comment


        • #5
          The HTML one seems to be missing several things:

          -Artillery shot (still need to dig up the rules for this one!)
          -Retreat
          -Sub-optimal hit points (previously damaged units)

          One of the problems with artillery shot is that you might not know the artillery is there. Since the whole point is to predict the odds of the outcome BEFORE the battle...

          It also needs to be updated for PTW.
          Got my new computer!!!!

          Comment


          • #6
            For previously damaged units, you just use a lower rank unit. Since it doesn't deal with retreat anyway, it's the same.

            That calculator doesn't attempt to deal with combined units, so of course there's nothing for artillery...

            Also, check CFS to see if they have anything more recent.

            Comment


            • #7
              Brizey:

              PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE....

              include Mixed-Unit Armies!!
              The greatest delight for man is to inflict defeat on his enemies, to drive them before him, to see those dear to them with their faces bathed in tears, to bestride their horses, to crush in his arms their daughters and wives.

              Duas uncias in puncta mortalis est.

              Comment


              • #8
                Yes, mixed unit armies. This will be so useful.

                Comment


                • #9
                  Originally posted by GhengisFarb
                  Yes, mixed unit armies. This will be so useful.
                  ArmyCombat.exe in the zip file above.

                  Comment


                  • #10
                    I have attached my calculator. It is an Excel VBA, which hopefully makes it portable and easy to modify. I plan to clean it up a bit, but it should be functional in its current form. All of the data is stored in worksheets, so it can be modified when playing mods, or if a patch changes standard attributes.

                    The only tricky Excel stuff is adaptive named ranges using the OFFSET function. (If you are an Excel geek, check out how I did it. It's cool.) Everything else is simple Excel functions and VBA.

                    Please test this for accuracy. For example, the PTW editor had values for the barbarian bonuses that I thought looked too high.

                    And please, I am not a pro code slinger, so bear with my poor coding skills. It is not very well commented, but the "AddStatus" function calls tell you what is going on.

                    It does not yet include artillery shots or armies. Also, it is ground combat only. Give me some time, and I hope ot at least include artillery shots and armies.


                    EDIT: I HAVE DELETED THIS ATTACHMENT...LOOK DOWN A FEW POSTS FOR THE CORRECT FILE!
                    Got my new computer!!!!

                    Comment


                    • #11
                      Some more comments:

                      The "Results by Round" tab shows every possible result of every possible round. Each column of results is every result that could have occured in that round. The "pred" field is the predecessor result to the result in question. In other words, it is a probability tree.

                      The "Results to Final" tab shows every possible path from the root to an end node through the probability tree.

                      The "Status" tab tells you what the code was doing as it went about its business. It is mostly for troubleshooting purposes.

                      This whole thing is intentionally open source. Have at it.
                      Got my new computer!!!!

                      Comment


                      • #12
                        Oops! I posted a bad version. Give me a few more hours. This is the one without a fortified bonus!
                        Got my new computer!!!!

                        Comment


                        • #13
                          ...or a few minutes.

                          USE THIS ONE!
                          Attached Files
                          Got my new computer!!!!

                          Comment

                          Working...
                          X