Announcement

Collapse
No announcement yet.

AI unit building priorities

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

  • AI unit building priorities

    What determens what unit an AI civ will build?

    For instance, if the AI has a choice to build a 2-2-1 unit (cost 30) or a 3-3-1 unit (cost 60), with the same resources and roles, what will it build? The strongest one (in this case, the 3-3-1 unit)? The one with the best price-performance ratio (the 2-2-1 unit)? Both? And if it does build both, in what ratio does it build them?

    I hope someone has any insights in this matter.
    Quod Me Nutrit Me Destruit

  • #2
    I've no idea how the AI determines the unit construction. But the AI strategies of the unit matters (and a multiple strategy unit is counted either as one of the strategies) The AI will try to get to a given ration between defensive and offence units (But I don't know that ratio)
    Creator of the Civ3MultiTool

    Comment


    • #3
      This has been the subject of a massive study at CFC:

      I think the answer to this question might very well be The Holy Grail for mod makers. AFAIK no one has figured it out, nor has Infogrames or anyone else published it. So I think we should find out -- and I'd like help devising a simple mod/scenario to ascertain this. I'm thinking very...


      Synopsis:

      Essentially, it seems (to me, anyway) that the AI is designed to select from among a HUMAN-designed and intelligently crafted and LIMITED forcepool.

      The AI builds Defensive : Offensive units in the 55% : 45% range. It "understands" that highest attack value (at equal cost) equals the "best" attacker; ditto DF for defender. In a small force pool it seems to intelligently choose multiple HP units; not necessarily so in a larger pool.

      The basic experiments were sets of test with ( (AF + DF) * HP ) = 10. The AI seemed to build well balanced units with a limited number of choices; once all choices were presented it "fell in love" with 1-9-1 defenders and geared heavily towards 9-1-1 and 8-2-1 attackers -- the problem with play balance can be seen here as these attackers become relatively easy to pick off; hence my opinion re: the limited forcepool.

      The AI is also miserable with artillery and DOES NOT seem to take MF into account when "choosing" what units to build. For mods where heavy artillery production is desireable I think we're all eagerly awaiting the "auto-build" improvements in Conquests.

      Best,

      Oz
      Last edited by Ozymandias; October 20, 2003, 19:28.
      ... And on the pedestal these words appear: "My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!" Nothing beside remains. Round the decay of that colossal wreck, boundless and bare, the lone and level sands stretch far away ...

      Comment


      • #4
        I read the entire civfanatics thread, and then did some testing of my own. The AI seems to favor one main defensive unit, and one main offensive unit.

        the two tests conducted were with a modded map, rules, and civs. 1 human player, 3 AIs. The AIs had varying build-often priorities (attack units, defense units, attack+defense units).

        they could all build the following units:

        Warrior: 2-2-1-30 A/D
        Skirmisher: 2-1-1-20 A
        Spearman: 1-2-1-20 D
        Chariot: 2-1-2-30 A

        in this test, the three AIs build mostly the same units, with a small variation of 2 units per 100.

        the results:

        3% chariots
        11% skirmishers
        25% spearmen
        61% warriors

        the second test was essentially the same, only with warriors being Attack-only. This resulted in:

        2% chariots
        4% warriors
        30% spearman
        64% skirmishers

        Both tests were repeated three times each, with similar results.

        conclusions:

        As was already established in Civfanatics: the AI builds the cheapest defensive unit it can build, when the city is defenseless.

        The AI finds extra movement points (and thus, the ability to retreat) not worth spending extra shields on.

        problems:

        what determens what defensive or offensive units the AI will build?

        In the second test case, it favored 2-1-1-20 units over 2-2-1-30 units, suggesting it merely looks at the A-stat, and then picks the cheapest. However, the first test case shows the AI prefering 2-2-1-30 units over 2-1-1-20 units. The only difference is that in the first case, the unit has both A and D flagged. Yet, it is safe to assume most of those warrios were Attacking units (since the number of purely defensive spearmen being build remained roughly the same). Maybe the AI simply favors multi-role units? Maybe the AI will only look at the stat it has been flagged for? In that case, in the second test the A-warrior simply has a 2 attack strenght, costing 30 shields, while the A-skirmisher also has 2 attack strenght, while costing only 20. But in the first test, the A-skirmisher has 2 attack for 20 shields, while the A/D-warrior has 4 Attack+defense for 30 shields. More testing will be done on this subject, but I suspect that this is the case.
        Quod Me Nutrit Me Destruit

        Comment


        • #5
          new test:

          pikeman 1-3-1-30 D
          archer 3-1-1-30 A
          swordman 3-3-1-60 A/D
          cavalry 3-1-3-60 A

          result:

          cavalry: 5%
          archer: 10%
          pikeman: 35%
          swordman: 50%

          Results are much the same as the first test. Fast attack unit 3-5%, cheap attack unit 10%, cheap defense unit 25-35%, expensive multi-role unit 50-60%.

          I do have to say that one of the civs showed a different result in one instance:

          cavalry: 14%
          archer: 22%
          pikeman: 32%
          swordman: 32%

          It's probably a fluke, since in repeated tests the result didn't come up again.
          Quod Me Nutrit Me Destruit

          Comment


          • #6
            same test, only with swordmen being A-only

            result:

            swordman: 0%
            cavalry: 5%
            pikeman: 28%
            archer: 67%

            fairly similar as the earlier test with the A-only warrior. 5% or less fast and expensive units, 30% defenders, and 65-70% attackers.


            of course: the number of defensive units depends highly on the number of cities. more cities=more defensive units.
            Quod Me Nutrit Me Destruit

            Comment


            • #7
              How do Hidden Nationality options fit into their build scheme?

              Comment


              • #8
                Unscientific aka "annecdotal" evidence -- the AI likes specially flagged units.

                At CFC I was trying to devise a benchmark unit (as I mentioned in my earlier thread) to see, e.g., how many AF/DF "Invisibility" is worth -- but that's not how the algorithm seems to function ...

                More to follow as I play with flags this week --

                Although may I suggest tests? -- Try using my "benchmark" 5/5/1 1HP* and simply decrease total AF+DF while adding each flag in turn and seeing if an "equilibrium" can be reached for each flag either (i) vis-a-vis AF/DF (all my work indicates that the AI does indeed evaluate 1AF = 1DF, even though it tends to produce more high DF units in the % range I mentioned above - ~55% D : ~45% O) or (ii) vis-a-vis differently flagged units compared against one another.

                *I chose this as the benchmark as I wanted to be able to play around with 10% variations in "value" for the different tests - just trying to keep matters statistically equivalent - and this unit was the "obvious" midpoint of (AF + DF) * HP = 10

                Best Regards,

                Oz
                ... And on the pedestal these words appear: "My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!" Nothing beside remains. Round the decay of that colossal wreck, boundless and bare, the lone and level sands stretch far away ...

                Comment


                • #9
                  I'll try your tests after I'm done with mine. I'm working with some of the units for a scenario I'm working on, to see which ones the AI will build.

                  For this test, I lumped the 1st and 3rd test together.

                  Spearman 1-2-1-20 D
                  Pikeman 1-3-1-30 D
                  Skirmisher 2-1-1-20 A
                  Archer 3-1-1-30 A
                  Warrior 2-2-1-30 A/D
                  Swordman 3-3-1-60 A/D
                  Chariot 2-1-2-30 A
                  Cavalry 3-1-3-60 A

                  Results:

                  Chariot: 0%
                  Skirmisher: 0%
                  Archer: 0%
                  Warrior: 7%
                  Cavalry: 10%
                  Spearman: 14%
                  Pikeman: 14%
                  Swordman: 55%

                  The AI clearly prefers to have expensive strong units, to inexpensive cheap units. Spearmen were only build as first units in undefended cities, and after that they switched to the stronger Pikemen units. Likewise, the AI didn't build any chariots but went straight to the stronger (and twice as expensive) cavalry unit. The AI did build some "inferior" warrior A/D units, but clearly prefered the superior swordman A/D unit.

                  Once again, the AI seemed to prefer multirole units, over attack-only units.
                  Quod Me Nutrit Me Destruit

                  Comment


                  • #10
                    Same test, only with warriors and swordmen being A-only.

                    Results:

                    Chariot: 0%
                    Warrior: 0%
                    Cavalry: 2%
                    Swordman: 3%
                    Archer: 3%
                    Spearman: 16%
                    Pikeman: 22%
                    Skirmisher: 54%


                    As expected, the AI prefered the cheaper A-only skirmisher/archer units over the A-only warrior/swordman unit, as shown in previous tests. Also as expected, the AI prefered stronger cavalry over chariots and pikemen over spearmen. But oddly enough...it prefered 2-1-1 units over 3-1-1 units. I can't explain it.
                    Quod Me Nutrit Me Destruit

                    Comment


                    • #11
                      Repeating the last two tests, only with all units costing 10 shields.

                      Results (warrior/swordmen A/D)

                      Skirmisher: 0%
                      Archer: 0%
                      Chariot: 0%
                      Warrior: 2%
                      Cavalry: 4%
                      Spearman: 8%
                      Pikeman: 8%
                      Swordman: 78%

                      Results (warrior/swordmen A-only)

                      Archer: 0%
                      Chariot: 0%
                      Warrior: 0%
                      Swordman: 2%
                      Cavalry: 7%
                      Spearman: 12%
                      Pikeman: 27%
                      Skirmisher: 52%

                      This is seriously pissing me off....why would it prefer a 2-1-1 unit over a 3-1-1 unit of the same cost?
                      Quod Me Nutrit Me Destruit

                      Comment


                      • #12
                        Never mind any of the tests, there seems to be crap hardcoded in the game. AI unit building preferences are hardcoded per unit, that's why at times it seems to prefer inferior units to superior ones, simply because of hardcoded priorities. ****.
                        Last edited by Saint Marcus; October 20, 2003, 18:15.
                        Quod Me Nutrit Me Destruit

                        Comment


                        • #13
                          Originally posted by Saint Marcus
                          Never mind any of the tests, there seems to be crap hardcoded in the game. AI unit building preferences are hardcoded per unit, that's why at times it seems to prefer inferior units to superior ones, simply because of hardcoded priorities. ****.
                          It's not QUITE that dire -- among a limited choice of units, the AI will make certain "intelligent" choices -- but, as I wrote above:

                          "Essentially, it seems (to me, anyway) that the AI is designed to select from among a HUMAN-designed and intelligently crafted and LIMITED forcepool."

                          Don't be too depressed -- you ran some good tests and it's knowledge about how the beast works that is most important. Understanding the CONSTRAINTS is and will be the key to decent mod-making -- making certain that the force pools available at any time fall within patterns the AI recognizes.

                          Granted, it's hardly "ideal" -- why an all-purpose AI selection algorithm wasn't developed is a mystery to me (and note that no Firaxians ever seem to comment in these threads ...).

                          Indeed, it wouldn't suprise me if the genesis of the Conquests improvements which will auto-generate units (and can be set to expire as Wonders currently do) arose in direct response to these limitations on the AI -- and, who knows, it might even prove to be an elegant solution ...

                          Keeping My Fingers Crossed,

                          Oz
                          ... And on the pedestal these words appear: "My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!" Nothing beside remains. Round the decay of that colossal wreck, boundless and bare, the lone and level sands stretch far away ...

                          Comment


                          • #14
                            After further testing, I'm wary about the AI making "intelligent" choices. I added some new units to the game (without replacing the old ones), thus they should be "clean", without hardcoded preferences. Yet, this isn't the case. First the AI seems to be "smart" in building the strongest units, but after changing the stats (making the strong weak and weak strong) the AI still builds prefers the same unit, eventhough it's weaker.


                            so first:

                            Pikeman 2: 1-3-1-10 63%
                            Spearman 2: 1-2-1-10 9%

                            then:

                            Pikeman 2: 1-2-1-10 56%
                            Spearman 2: 1-3-1-10 31%

                            Makes no sense whatsoever. First, I believed there were preferences hardcoded for the existing units (thus making the AI prefer longbowmen over archers, regarless of stats), however, this newest test with new and "clean" units seems to indicate that these preferences too are hardcoded somehow, somewhere.

                            It's frustrating.


                            (And Conquests improvements generating units? What if the Russians capture a German tank factory and suddenly recieve Panzer IVs every few turns?)
                            Quod Me Nutrit Me Destruit

                            Comment


                            • #15
                              Originally posted by Saint Marcus [...]
                              It's frustrating.

                              (And Conquests improvements generating units? What if the Russians capture a German tank factory and suddenly recieve Panzer IVs every few turns?)
                              Hi Saint Marcus,

                              I'll be doing a recap hopefully in the next week or so of all that's been learned and not learned, and I am personally very grateful for your efforts!

                              A quick question on your most recent test -- whose results are indeed disturbing (I'm an ex-programmer and can't even imagine why anyone would design an algorithm in such a fashion) -- how were the units flagged re: O/D?

                              Also, re: Soviets churning out Mk IVs, don't forget that, even in PTW, improvements can be tied to government types, which Soviets and Nazis presumably wouldn't share!

                              Best Regards,

                              Oz
                              ... And on the pedestal these words appear: "My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!" Nothing beside remains. Round the decay of that colossal wreck, boundless and bare, the lone and level sands stretch far away ...

                              Comment

                              Working...
                              X