1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Af/df & Hp

Discussion in 'Civ3 - Creation & Customization' started by Ozymandias, Mar 28, 2007.

  1. Ozymandias

    Ozymandias I saw the Great Library burn. Supporter

    Joined:
    Nov 5, 2001
    Messages:
    9,838
    Gender:
    Male
    Location:
    The lone and level sands
    I've been puzzling over how to make the AI build more unit types simultaneously.

    Pouring over my notes (and one ancient thread / treatise on the subject) I stumbled across the formula for how the AI valued a unit (I use the past tense because this was so long ago I was using PTW):

    (((3*A+2*D)*HP)+Bombard)

    2 points:

    1. THEORETICALLY (and leaving bombard aside for now) the AI should essentially make a coin-toss choice between any two units where ((3*A+2*D)*HP) = ((3*A+2*D)*HP)

    2. The AI doesn't take MF into account at all.

    Sorry, but I have no time whatsoever to retest this now, although I find it difficult to believe that the AI build algorithm changed when C3C was released.


    Hopefully Helpfully Yours,

    Oz
     
  2. WildWeazel

    WildWeazel hard-coded Supporter

    Joined:
    Jul 14, 2003
    Messages:
    6,967
    Location:
    %CIV3%\Conquests\Scenarios\
    MF?

    If your coin-toss theory is correct, we should be able to get the AI to build a certain type of military (offense/defense/balanced) by intentionally setting the weighted value of contemporary units. Interesting.
     
  3. SWalker

    SWalker Warlord

    Joined:
    Dec 19, 2005
    Messages:
    252
    Location:
    New Zealand
    Be aware - that thread was based on civ's military power ratings. That does not necessarily mean that the AI uses the same basis for desciding which units to build. The formula may be right in some circumstances, but I would suspect that there would be a formula like this for each AI stratergy. In particular I would suspect a different formula especially for offence and defence.
     
  4. Bluemofia

    Bluemofia F=ma

    Joined:
    Dec 8, 2003
    Messages:
    7,976
    Location:
    Dimension called Elsewhere
    Is movement included in it at all?
     
  5. Yoda Power

    Yoda Power ✫✫✫✫✫✫✫

    Joined:
    Sep 24, 2002
    Messages:
    13,869
    How exactly did you get this data?

    And how about the popular theory that the ai builds their units after how big their cost is? As they assume that more expensive units also are better.
     
  6. Ozymandias

    Ozymandias I saw the Great Library burn. Supporter

    Joined:
    Nov 5, 2001
    Messages:
    9,838
    Gender:
    Male
    Location:
    The lone and level sands
    To answer everyone's questions, it was a large effort; the entire thread can be found here.

    The formula and supporting data can be found there.

    "MF" = "Movement Factor" which the AI doesn't take into account at all!

    @SWalker - check the thread; my own testing on AF/DF/HP/MF combinations was fairly extensive. So my formula ((3*A+2*D)*HP) = ((3*A+2*D)*HP) should hold true for those three variables (to be perfectly clear, I did not test/weight various flags and unit abilities - except for "Offense" and "Defense" Strategy flags).

    All The Best,

    Oz
     
  7. SWalker

    SWalker Warlord

    Joined:
    Dec 19, 2005
    Messages:
    252
    Location:
    New Zealand
    I apologise - I mistook the formula for one from another thread (where units 'power' for civ power ratings was calculated). I had not seen the tread with your work, and I'm now reading it.
     
  8. embryodead

    embryodead Caliph

    Joined:
    Jan 1, 2003
    Messages:
    5,179
    Location:
    basement
    I assume that the bombard value is always counted, even if it's "defensive" ?

    E.g. a 4(4).1.1 archer has more value than a 4.2.1 infantry?

    And if the archer is changed to 4(2).1.1 they should be built 50/50 (ignoring other units for now)? That would be quite awesome.

    EDIT: Nevermind, I forgot about HP. Seems the defensive bombard value would have to be quite high to make up for 1 less defense point.
     
  9. Ares de Borg

    Ares de Borg Norman Knight

    Joined:
    Sep 19, 2004
    Messages:
    5,121
    Location:
    Heart Of Europe
    So cost doesn't count?

    I always hated the AI building only BBs instead of cranking out DDs.
     
  10. Yoda Power

    Yoda Power ✫✫✫✫✫✫✫

    Joined:
    Sep 24, 2002
    Messages:
    13,869
    Wow I posted the almost same post in that old thread. :lol:
     
  11. Ozymandias

    Ozymandias I saw the Great Library burn. Supporter

    Joined:
    Nov 5, 2001
    Messages:
    9,838
    Gender:
    Male
    Location:
    The lone and level sands
    Correct. My working hypothesis was and remains that there is no algorithmic logic of the sort a modder would want for choosing units. I believe it's the AI equivalent of a drooling idiot, designed to choose units using very simple rules from a very small force pool (i.e., one Defender, one Attacker, etc.). I'm actually starting to feel glad that the Editor allows us to do as much as it does ... either that or I have heat stroke coming on ...

    -Oz
     
  12. SWalker

    SWalker Warlord

    Joined:
    Dec 19, 2005
    Messages:
    252
    Location:
    New Zealand
    After reading through the thread I would have to disagree with your conclustions.

    1: Some of Neomega's tests did show that the AI values MP (see the third test of this post)

    2: This test by ozymandias suggests that the AI values A over D for Off units, but D over A for Def units. Although givien the large number of possible units for the AI and the total sample size, it would good to do more testing.

    3: You did test some flags, however the results of this test do not give a quatitative weighting for the flags, so it is fair not to include them in the formula.

    The ((3*A+2*D)*HP) for unit value formula was a reasonable hypothesis, but none of your testing actually confirmed it (or seemed to be designed to confirm it), and a number of tests indicated that it was flawed.

    I have my own working hypothesis as to how this works (based mainly on Neomega's work and thoughts), and I am considering doing some statistically valid tests of my own (in a similar vein to Neomega's) to tease out some more of the relationships.

    My hypothesis is roughly:

    There are two major parts to the AI's build algorthm.

    Firstly it descides what type of unit to build based on some set of factors that we dont have a complete grip on yet (defender for empty city, build forces toward some ratio, build forces at some ratio, etc). This descision tells the AI what AI-stratergy-flag to build.

    Then once the descision of what flag to build is made, the AI will choose one of the units with that flag and build it. The algorithm for this descision seems to vary with some circumstances (eg If first build in an empty city is the cheapest defender); but for the standard units builds that make up most of the game, I think that the AI assigns a value to each unit with the right stratergy (based on A/D/M/HP etc), and picks one randomly with the odds weighted towards the units with the highest value.

    Unfortunatly Neomega's work shows that the odds weighting formula is not obvious.
     
  13. Civinator

    Civinator Blue Lion Supporter

    Joined:
    May 5, 2005
    Messages:
    7,035
    Gender:
    Male
    This is a very important thread. With some observations from playtesting of my new mod, I think there is some truth (the last facts are not discovered yet) in SWalker´s statements.

    I did check, if all settings of the tanks for my mod work well and therefore I made these tanks with only an offensive flag available from start with zero building costs. Of course the defense settings of these tanks were much higher as the defense settings of the spearman, which was the unit with the best values for a unit with the defensive AI tactical flag at the start of that test version of my mod. I was very astonished when I did recognize, that the AI tried to build spearman units in the empty cities and not the tanks with the much better defense and attack values.

    It seems, the attack and the defense flag in the AI tactics have a big influence in the AI´s decision what unit to produce.

    I must read all these complete threads that are linked in this thread when I have more time.
     
  14. SWalker

    SWalker Warlord

    Joined:
    Dec 19, 2005
    Messages:
    252
    Location:
    New Zealand
    @Civinator

    Neomega's tests indicated that in situations where only Off and Def flagged units were available (no worker, arty, etc), that in an empty city the computer would first build 2 Def units and then build roughly a 50%/50% mix of Off/Def stratergy units.
     
  15. Civinator

    Civinator Blue Lion Supporter

    Joined:
    May 5, 2005
    Messages:
    7,035
    Gender:
    Male
    Thank you very much. I must read this stuff! :)
     
  16. Ozymandias

    Ozymandias I saw the Great Library burn. Supporter

    Joined:
    Nov 5, 2001
    Messages:
    9,838
    Gender:
    Male
    Location:
    The lone and level sands
    @SWalker - My "serious", heavy-duty testing centered strictly around seeing how the AI would build re: AF/DF/MF/HP. Note that there was some serious and inexplicable weirdness even here: even though I set up all three Civs in the tests identically, Egypt consistently built a different force pool than Greece, and there seems to be little correlation between how the two AI Civs and the Player's Governor built for the human player.

    Within these limitations, my approximation is that the AI builds (with all things being equal) D:A units in the range of 55%:45% to 60%:40%.

    Yes, the equation is an approximation - that entire Heavens-knows-how-many-tests-long series wasn't exhaustive (I came to my "Limited Force Pool Theory" and have proceeded accordingly). PLEASE do try to fine-tune it if you're motivated to do so! (I never mind being proven wrong, unless I've been witless :crazyeye: ).

    Even as an approximation, an interesting question is raised: What is more valuable, A/D strength or hit points? (Consider how much damage an Incan Inti unit can do in that Conquest).

    My Best Regards,

    Oz
     
  17. SWalker

    SWalker Warlord

    Joined:
    Dec 19, 2005
    Messages:
    252
    Location:
    New Zealand
    I'm seriously considering it - but I'm not looking foward to the work. To get sufficiently accurate results the tests would need large numbers of unit builds (Neomega's standard tests were 400+ builds, and without doing statistical calculations thats the sort of test size needed to get reasonable margins of error)

    Just a comment on this...

    In the referenced thread people noted that for example a 4A/2HP unit would win more the 50% of battles vrs a 8D/1HP. What this fails to take into account is that the 4A/2HP unit would often be weakened after the battle, while the 8D/1HP unit would remain at full strength after any battle it won.

    My personal view is that the important numbers are A*HP and D*HP, since these numbers determine the average damage inflicted/lost in a given combat. (Roughly, the higher the HPs the more predictable the combat result is.)
    However for a given D*HP units with high HP are more resistant to bombardment, eg (Lethal)Bombard 4 Rof 2 has a 5/9 chance of killing a 8D/1HP unit (avg dam caused = 5/9 or -4.44 from D*HP), and 1/4 chance of killing a 4D/2HP unit (avg dam caused = 1 or -4 from D*HP); while low HP units get a larger boost from the extra veteran/elite. So for given (A&D)*HP I generally value low HP attackers slightly higher (and plan to get them to elite), and generally I think the same way about defenders unless they are going to be in a situation where they will get bombarded.
     
  18. Ozymandias

    Ozymandias I saw the Great Library burn. Supporter

    Joined:
    Nov 5, 2001
    Messages:
    9,838
    Gender:
    Male
    Location:
    The lone and level sands
    :rockon:

    I quite agree - my observation was simply that 2 units with an equivalent AI value yet different actual "strengths" would both be built by the AI, thereby allowing greater "room" for modding.

    All The Best,

    Oz
     

Share This Page