Announcement

Collapse
No announcement yet.

A Better AI.

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

  • A Better AI.

    Greetings, People of Apolyton.

    I'm sure many have been intrigued by the improvements to the AI in Warlords Patch 2.08, alas there was little time for doing much improvement and the process was hurried. I have continued to improve the AI and fix various AI/Auto Worker bugs and you can now download the updated AI mod for Warlords Patch 2.08 amd Vanilla Patch 1.61..

    Why might you want to use this mod? Firstly it is fully save-game compatible (if placed in CustomAssets) and game rules are completely unchanged. The change log includes some interesting improvements:

    - Fix to irrigation chaining bugs which would result in the AI farming excessively and flip-flopping between farms and cottages.
    - General worker unit AI improvements to make them more flexible, they will also stack.
    - Auto workers now come back and road up resources which had been built before roads were available.
    - Workers are now less fearful of enemy units, they should only run away if they are in actual danger of dying.
    - Tweaks to auto workers to achieve a better balance of hammers, they should build more mines now.
    - Code to add awareness of jungle chopping when choosing research.
    - Great People usage improved, the AI should be less Golden Age happy, only starting one if it’ll actually pay off compared with lightbulbs/settling.
    - Great Prophet Shrines valued a little more accurately.
    - Great Merchant cash bomb logic added.
    - AI's will now spend gold to perform deficit (100%) research and will decline to trade gold reserved for such research, enabling them to make better use of gold boons from huts, plunder, refunds, great merchants, etc.
    - AI Missionary code adjusted - both when choosing destination and when determining the number needed.
    - Awareness of freebie promotions (such as Aggressive Combat I, or Red Cross Medic I) when choosing which unit to train.
    - The AI will now chop Wonders and will chop to assist a war effort.
    - The AI will no longer pillage Barbarian Cities.
    - City Founding logic has been improved, a bug was fixed which could "force" the AI to found on top of resources that it otherwise wouldn't, the AI is also aware of existing culture (it's own) making tiles workable.
    - City Founding logic has been diversified, Creative leaders are more "Greedy", grabbing as many resources as possible per city, Organized leaders are the opposite, being more inclined to found cities right next to resources and founding more cities overall.
    I now have a Sourceforge project page for source control and distribution, thanks to Iustus of CFC/RBCiv. My intention is to use that for distribution of date-stamped test builds, once a build has been confirmed to be mostly stable without crashes or glaring AI flaws it will be given a version number and uploaded to the major Civilization Sites mod repositories. You can help in this process by testing, both reporting things which appear broken and things which do work, of particular value would be experience on larger maps. I would greatly value any report of experience, even if it's as simple as "I played out a full game and didn't notice any problems". Save games, especially from later in the game (ie before a world war, entering industrial era...), would also be quite useful as testing grounds.

    A Vanilla Build is now available, I work on Warlords and the changes are integrated back into Vanilla.

    Link to the Sourceforge Project.
    Link to the Original Thread.

    Enjoy,
    Blake.

    PS. For feedback and stuff, this thread is as good a place as any for now. I'm also crossposting this over on CFC and will check both threads.
    Last edited by Blake; November 18, 2006, 01:57.

  • #2
    Great improvements! I will definitely check them out soon!

    If you (or someone else) can do military improvements as well, we could even start reducing the AI bonusses... That would be sweet. The ultimate goal should be an AI that plays by the same rules as humans, and treats human players exactly the same as other AIs.

    I think such a level of AI play should be possible to reach at least up until monarch difficulty. Consider that a challenge

    Comment


    • #3
      Hell of a challenge .

      An AI that would play by absolutely the same rules as the human could be, just maybe slightly, done in some 5 years. It's a challenge of fantastic scope. But so far, Blake has managed to increase the AI skill by almost a whole difficulty level, which is great, and I am a big fan of his work. This is what I was looking forward to when I first learned that the Civ4 AI code is going to be public.

      But yeah, the military improvements are quite required. City attack improvements in particular...
      Solver, WePlayCiv Co-Administrator
      Contact: solver-at-weplayciv-dot-com
      I can kill you whenever I please... but not today. - The Cigarette Smoking Man

      Comment


      • #4
        One suggestion:
        Is it possible to make two versions of the AI mod?
        One stable with minimum of bugs. Relatively conservative.

        And another experimental, with more new AI things added. More prone to bugs or bad solutions.

        P.S.
        Basically, new things would go in experimental version, and if they prove good, they would be added in more conservative version.
        In the meantime, only bug-fixes are added in stable version.


        EDIT:
        That way, stable version could be used in things like Democracy game, Game of the Months, some mods or similar. While experimental one would be a sort of beta-test version to try new things.
        Last edited by player1; November 4, 2006, 10:50.

        Comment


        • #5
          Originally posted by Solver
          Hell of a challenge .

          An AI that would play by absolutely the same rules as the human could be, just maybe slightly, done in some 5 years. It's a challenge of fantastic scope. But so far, Blake has managed to increase the AI skill by almost a whole difficulty level, which is great, and I am a big fan of his work. This is what I was looking forward to when I first learned that the Civ4 AI code is going to be public.
          I don't think it has to take that long. On monarch most of the AI bonusses are not that big. The major exceptions are troop upkeep an upgrade costs, where they recieve huge bonusses. Making the AI smarter with military would go a long way to reducing those bonusses though.

          It's a tough challenge. But I don't believe it has to take 5 years.

          But yeah, the military improvements are quite required. City attack improvements in particular...
          Another reason why they are required is that the game is currently getting unbalanced. If you keep improving the economic side of the AI without improving their military side, you are slowly killing off builder strategies. If the only way to defeat the AI at the higher difficulties will be warfare, because that's the only place where they are dumb enough to overcome their bonusses, then builders will be in trouble.

          So... AI military improvements are needed.

          I fear I'm not a very good programmer, but I'm willing in any way I can. Perhaps we could set up a think-tank or something like that. Anyway let's not pollute Blake's thread too much with it

          Comment


          • #6
            - Great People usage improved, the AI should be less Golden Age happy, only starting one if it’ll actually pay off compared with lightbulbs/settling.
            How do you calculate that?
            Contraria sunt Complementa. -- Niels Bohr
            Mods: SMAniaC (SMAC) & Planetfall (Civ4)

            Comment


            • #7
              Hi Blake. I loaded your mod and can report a definite improvement in worker behavior.

              Prior situation: Great Wall is built. Worker is inside the wall, Barbarian is outside, but adjacent to the worker. The worker would stop whatever it was doing. However, the worker could not be attacked by the Barb due to the GW.

              Now, in the above situation, the worker continues with its action and ignores the Barb.

              It's possible that this behavior was fixed in patch 2.08 instead of your most recent mod. I assume that you will know which.

              Thanks for all your work!

              Petek
              "The avalanche has already started. It is too late for the pebbles to vote."
              -- Kosh

              Comment


              • #8
                Mansa Musa on Monarch: Liberalism in 785AD.

                The AIs are playing an annoying tech-swapping game. Did you encourage them to exchange with each other? I'm now at Scientific Method and Mansa recently popped a Great General, leading me to suspect he has Fascism.

                My only real option for victory is to pay everyone to have a massive world war and to stab some backs while thats going on.


                Perhaps one way to improve the military AI would be to make the AI closely observe who has what resources and techs and to ruthlessly attack those with units that are hard to counter.
                Now that you've got the AI spamming units, you really need to teach it to do something with them.

                Comment


                • #9
                  Yeah, it seems like the AI still uses its tech trading handicaps, trading amongst eachother like crazy, leaving you out. That's not normally so bad, but now they research MUCH better, so that combined with their trading tendencies can skyrocket their research. Perhaps this patch goes a bit too far with how much they trade techs?

                  Aside from this balance issue, I'm loving your work on the 2.08 patch and I'm getting this newer AI mod as we speak. Keep up the good work!

                  Comment


                  • #10
                    First thing: Usage.

                    The zip you need is the one not containing the word "Source", the source means source code - you don't need that as a user.

                    In the zip you'll find a folder called BetterAI and inside that folder you'll find CvGameCoreDLL.dll. You can either place the betterAI folder inside your Mods folder then load it as a mod in game (using Advanced Menu), or you can take the CvGameCoreDLL.dll file and place it directely inside your CustomAssets folder (not any of the sub folders), which if you go to My Documents should be:
                    My Games/Warlords/Custom Assets/

                    To return to normal play simply delete the CvGameCoreDLL.dll file.

                    Both methods work equally well, I reccomend using the mod method if you use other mods, and the Custom Assets method if you don't play with mods.



                    Okay other things mentioned many times...

                    Difficulty Levels:
                    The first thing I want to point out is that my mod primarly addresses the mid to late game AI incompetence, where the AI starts to spin it's wheels and not go anywhere, like the AI couldn't make use of Biology at all. It is not much harder at the start of the game, I mean sure, I improved some things like workboat and worker gettage, and I've ensured the AI wont be left without critical techs like Pottery or Iron Working (if Jungled). The main thing, is you can't rely on the AI stagmenting, it's not enough to get a lead at one point in the game then sit on your laurels, trusting the AI's to stagment. Now the AI's can leverage many more techs and gain an advantage.
                    You certainly need a REAL edge to beat the AI's at Monarch+, you can't just rely on their incompetence to be their undoing. For example you can use smart wonder usage, or you can use the crutch of warmongering, altough I've noticed the AI is certainly capable of bogging down an invasion under sheer weight of units (and now I've made them chop during wars, yikes...).

                    My long term plan is to tie play style to difficulty level, there's a few things which could change by difficulty level. Firstly, the skill in taking cities, a higher level AI would only attack when it knows it will win, while the lowbies will continue with "lemming attacks" (or as I like to call it, "Whack a mole" gameplay). Other possibilities are things like city placement, with the higher level AI's going for more cities overall (I've noticed newbie players tend to place cities far too spread out). Also chopping and whipping tend to be used more by skilled players and I might make the AI do that.

                    For now, the advantage gained, is that the game is more "balanced" - it's no longer just an early game where you gain an advantage then cruise to victory. You can lower the difficulty level, and I hope, have a more interesting later game. Also I'm also adding more variety in the AI play styles, you'll probably recognize this the first time you see an AI switch to Pacifism, or if you download my new mod, when a Great Merchant appears on your borders - in other words, not only have I made the AI play stronger in the same way handicap bonuses do, I've also taught it new tricks.


                    Another topic: Tech Trading.
                    I have not changed this other than making them put a higher priority on Alphabet (in one monarch game I played every AI had alphabet by 1AD, I didn't, yikes, but that's an exception not the rule). The AI's have generally far better research power. With my newer mod, not only do they have the stronger economy, they can also leverage gold boni into research, what's more they no longer squander Great People, meaning they might use that mid game GS to pop Education and thus win liberalism rather than wasting him on a GA, the AI who bags the Economics GM will probably use him for a Cash Bomb, resulting in another burst of research. As far as I can tell, most of the AI's higher tech speed is from their sheer researching speed moreso than any change in tech trading - they just really do reserach that fast. My AI seems to have reached the point where on Monarch they research faster than old Emperor AI's, I'm very reliant on tech trading tricks I used to do on Emperor, like Compass for one.

                    Comment


                    • #11
                      Originally posted by player1
                      One suggestion:
                      Is it possible to make two versions of the AI mod?
                      One stable with minimum of bugs. Relatively conservative.

                      And another experimental, with more new AI things added. More prone to bugs or bad solutions.
                      That is the plan.

                      The releases called Bleeding Edge will be the unstable ones, in fact I pretty much plan to make the current one I have up into the first stable release, with the new changes I'm making being more experimental.

                      I hope to use the Mod as a basis for the AU Mod, at very least, and I don't mind at all if it's used for other competitive gaming.

                      It's for the purposes of stable releases that I *really* need to know if the AI is working properly.

                      Originally posted by Diadem
                      Another reason why they are required is that the game is currently getting unbalanced. If you keep improving the economic side of the AI without improving their military side, you are slowly killing off builder strategies. If the only way to defeat the AI at the higher difficulties will be warfare, because that's the only place where they are dumb enough to overcome their bonusses, then builders will be in trouble.

                      So... AI military improvements are needed.
                      I disagree on the first point, the game was ALWAYS unbalanced in exactly that way. It's not getting more unbalanced, if anything you can play an entire game (maybe at a difficulty lower) which is interesting as a build fest, because the AI wont get out-builded so trivially.

                      I fear I'm not a very good programmer, but I'm willing in any way I can. Perhaps we could set up a think-tank or something like that. Anyway let's not pollute Blake's thread too much with it
                      I rely on the collective wisdom and experience of the CIV community so pollute all you like .

                      The main challenge with Military AI is that it's more of a case where each new feature adds a couple of new bugs... it's daunting.

                      Originally posted by Petek (Poly)
                      Hi Blake. I loaded your mod and can report a definite improvement in worker behavior.

                      Prior situation: Great Wall is built. Worker is inside the wall, Barbarian is outside, but adjacent to the worker. The worker would stop whatever it was doing. However, the worker could not be attacked by the Barb due to the GW.

                      Now, in the above situation, the worker continues with its action and ignores the Barb.

                      It's possible that this behavior was fixed in patch 2.08 instead of your most recent mod. I assume that you will know which.
                      This is a change I made post-2.08. In short the Workers are now only scared of things which can get to them. The 2.08 autoworkers would run away from barb animals even within the safety of cultural borders, I just had to fix that and the Great Wall thing was just a natural consequence of that fix.

                      In fact it's possible to move melee units right up to an autoworker before it'll run away, they only run when they actually could die. Movement speed is taken into account as are roads (to a degree).

                      Later in the game it'd be possible to gank workers with railroads or very fast moving units, but by then the worker costs a lot less than the ganking unit, which will probably die by counter-unit so I don't see it as a big issue.

                      Comment


                      • #12
                        Well, that is an issue, but for the war-AI... A silly thing to do.
                        I've allways wanted to play "Russ Meyer's Civilization"

                        Comment


                        • #13
                          I've resolved the gankable worker issue, workers are now paranoid about tiles which are adjacant to hostile culture, or tiles which are 2 tiles away from hostile, roaded culture. I did this after seeing a stack of 6 korean workers having a picnic on my borders (maybe they thought they were refugees ).

                          By the way I could also eliminate the possibility of early worker poaching by making the AI paranoid in the opening turns about warriors on it's borders. Should I do this? It would mean that the player could deny the AI a few tiles by parking the warrior on their border but I think it would be worth it as most capitals have valuable improving resources at many locations.

                          Comment


                          • #14
                            A worker that is protected can continue to work. That's perhaps difficult to program in correctly, but for the early game it could certainly work. Let the AI put on of its starting archers over its starting worker. That instantly solves the problem of early worker stealing.

                            For the rest of the game: Have you thought about commando units? With your first GG you could create a warlord with commando that could steal a lot of workers with little risk to itself - after all the enemy only moves 2 within its own borders as well.

                            Comment


                            • #15
                              Hi Blake, first of all thanks for putting all this effort into improving the most important part of civ, the AI

                              I have problems compiling your code though. The 2.08 source compiles fine but with your files I get five times:

                              "error C2039: 'AI_calculateGoldenAgeValue': is not a member of 'CvPlayerAI'"

                              all in CvUnitAI.cpp. CvPlayerAI indeed doesn't have a calculateGoldenAge member neither does Cvplayer from which it inherits. And your distribution doesn't contain 'CvPlayer.h' or 'CvPlayerAI.h'. So what am I doing wrong?

                              Comment

                              Working...
                              X