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

A Better AI.

Discussion in 'Civ4 - General Discussions' started by Blake, Nov 4, 2006.

  1. Blake

    Blake The AI Guy

    Joined:
    Feb 18, 2006
    Messages:
    342
    Location:
    Apolyton
    Better AI information:

    Please head over to and use the New Better AI Sub Forum.


    Sourceforge Project (Downloads for Warlords and Vanilla).

    Better AI improves the AI's decision making, enabling the AI to put up a stronger game with less reliance on handicaps and ultimately to play a balanced game more like a human. Better AI improves nearly every aspect of the AI, for example the AI is capable of pursuing Cultural Victories and militarily it is far less of a pushover. It falls into less traps than the normal AI, with superior research choices, the Governor functions are improved for both Human and AI players, the Automated workers are also improved for both Human and AI.

    Gameplay compatibility is preserved with the exception of a few bug fixes and other "Grey areas", the most noteworthy being the starting point code, Better AI eliminates very close start points and generally makes starts a bit fairer or less absurd (in a nutshell this is because the starting point code was inadvertently changed in Warlords patch 2.08).
    Save game compatibility is also preserved, you can thus start or stop using Better AI at will.

    Installation:

    Better AI is contained entirely in the CvGameCoreDLL.dll file, it is the only file you need.

    To use Better AI for all your games place the DLL in your CustomAssets folder:


    To use Better AI as a mod, place the DLL in a \Mods\Better AI\Assets folder:


    You can tell if you have it installed correctly if you see "=== Better AI ===" in the score breakdown


    You see the score breakdown by holding down alt while mousing over your player name in the 'scoreboard'.


    Spoiler Original First Post :

    Greetings, Fanatics.

    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:

    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.

    Iustus explains how to get the Source via SVN.

    Link to the Original Thread at Apolyton.



    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 Poly and will check both threads.
     
  2. marioflag

    marioflag History Addict

    Joined:
    Oct 20, 2005
    Messages:
    1,902
    Location:
    Napoli, Italy
    Your improved AI in Warlords 2.08 is just great.I was achieving some victories at prince level before your AI improvements and now i'm stuck at this level and it's unlikely i will go to monarch now.I hope your successful efforts to improve AI will be noticed by firaxis for future civ games.
    Thank You
     
  3. phungus420

    phungus420 Deity

    Joined:
    Mar 1, 2003
    Messages:
    6,296
    I cannot find a custom assets folder, just an assets folder with Python, XML and other folders thierin. Where exatcly should I be extracting this file to?

    Also the link has two files to download, should I download both of them?


    Oh and thanks Blake.
     
  4. player1 fanatic

    player1 fanatic Fanatic

    Joined:
    Mar 19, 2002
    Messages:
    2,639
    Gender:
    Male
    Location:
    Belgrade, Serbia
    Custom assets is in MyDocuments\My Games\Warlords I think.
     
  5. Soil

    Soil ねねね

    Joined:
    Aug 22, 2005
    Messages:
    224
    Location:
    LV-426
    Same question as phungus420.

    Any instruction on what exactly to do, since I've never used a mod in my life.

    Do we need put all the extracted files together in one folder in custom assets? ;o
     
  6. player1 fanatic

    player1 fanatic Fanatic

    Joined:
    Mar 19, 2002
    Messages:
    2,639
    Gender:
    Male
    Location:
    Belgrade, Serbia
    There is just one DLL file and a readme.
    You should put it in Custom Assets folder, which is in "My Documents\My Games\Warlords" folder.

    P.S.
    My Documents could be called something else, depending from your user name in Windows.
     
  7. Gr3yL3gion

    Gr3yL3gion Voice of Madness

    Joined:
    Mar 19, 2004
    Messages:
    2,202
    Location:
    KL, Malaysia<->Singapore
    Thanks Blake!
     
  8. Zoolooman

    Zoolooman Space, Time, Travel

    Joined:
    Aug 21, 2006
    Messages:
    155
    Location:
    Texas
    While these AI improvements are very impressive, the AI is improved so greatly that one wonders if it's reasonable to play against it with mere Monarch penalties/bonuses, let alone Emp/Im/Deity penalties/bonuses.

    To put it another way: the more intelligent the AI becomes, the more overwhelming the AI handicaps become. Even without these further improvements, the 2.08 AI is tearing up on Prince.
     
  9. upstart

    upstart Warlord

    Joined:
    Oct 4, 2005
    Messages:
    145
    Awesome work, Blake! As I see it, the AI still remains CivIV's achilles heel(although I am proud of firaxis finally firmly addressing the problem as of the latest patch). So I am hoping to see your project go the rest of the way to address this, good luck to that end. By the way, you don't exactly state whether you will at some point start addressing overall strategy as well as tactics, as in the AI launching lengthy military campaigns...are there plans for this? I hope so anyways. I can only drool at the possibilty of my enemies' forces becoming a serious threat at equal or lesser numbers, rather than just a slight hindrance to my eventual domination.

    And I agree with Zoolooman, as this mod progresses the need for handicaps will only diminish. Maybe they should be readjusted so that at the lesser difficulty levels, the AI gets large negative bonuses to nerf it for beginners? I would love to actually have the positive bonuses dissapear completely, actually, if that can ever be possible. Really having a completely non-cheating AI that is still very challenging would be the ideal scenario.
     
  10. plesniak

    plesniak Warlord

    Joined:
    Oct 23, 2006
    Messages:
    238
    I agree totally with this last post. Tweaks to the AI are great...but it sure does a number on your understanding of the game and the difficulty levels. Just because now I have to go from monarch to prince or noble...How has that improved the game??Does the AI now have too much of a helping hand at monarch and higher. A truly balanced game would have no need for such rudimentary leveling tactics.
     
  11. Thedrin

    Thedrin Deity

    Joined:
    Jan 24, 2002
    Messages:
    2,650
    Location:
    London
    From reading the original AI improvement thread my understanding is that the ultimate aim of Blake's project is to make the AI challenging enough that the human player doesn't need to give it bonuses - to make it so that higher difficulty levels are unneccesary.
     
  12. drkodos

    drkodos Emperor

    Joined:
    Dec 26, 2005
    Messages:
    1,861
    Location:
    Renting-a-tent

    The only levels needed would be to lower the difficulty of the AI to give the human a better chance, so that effectively a even playing field would be the hardest highest level and that only the very best human players would be able to compete with the AI in this setting.

    As it should be, like good Chess programs.

    Not in any of the games I've played, or been witness to.
     
  13. Zoolooman

    Zoolooman Space, Time, Travel

    Joined:
    Aug 21, 2006
    Messages:
    155
    Location:
    Texas
    The AI is still a horrible warmonger. However, it has become a fairly effective builder. This means that I can't play Prince difficulty in a "lazy" manner.

    Edit: Blake, I've got a question. Have any of your improvements attempted to alter the tech-trading behavior of the various Civilizations? Currently, it *seems* like there is an AI conspiracy to trade fairly amongst themselves while they deny trades to me (or ask for absurd deals).
     
  14. cf_nz

    cf_nz Prince

    Joined:
    Mar 17, 2006
    Messages:
    414
    Location:
    New Zealand
    Excellent work Blake, I'll be keeping a close eye on your changes.

    Edit: Blake have you labeled you code changes in the .cpp and .h files? I would like to merge your AI changes in with other changes I have made. Thanks.
     
  15. drkodos

    drkodos Emperor

    Joined:
    Dec 26, 2005
    Messages:
    1,861
    Location:
    Renting-a-tent
    I concur.


    Long term strategic thinking is the bane of all AI. The only way that IBM was able to beat Kasparov with the computer was to have a human being give the computer some stealth help. The computing power of the AI is always superior, but it still cannot think strategically, which often calls for counter-intuitive thinking and planning. Knowing when the odds do not matter and one should plow ahead regardless only comes from wisdom, not intelligence.

    It is also good to know (as a human) that illogic has it moments when it produces the best results and that the sci-fi idea of being controlled by the machines we build is still very far in the future.

    I hesitate to even call what CIV has an AI. Intelligence learns from experience. That is the definition of intelligence. A true AI actually learns and makes better decisions all on its own based on the experiences it has had. I do not see that happening in this game anytime soon.

    To me, it is more a simple computing engine than an artificial intelligence.
     
  16. aelf

    aelf Ashen One

    Joined:
    Sep 16, 2005
    Messages:
    16,753
    Location:
    Tir ná Lia
    I think the changes to the AI so far only make aggressive warmongering even more essential. Not good in promoting different ways to play the game.

    It's a good job, so congrats on that :goodjob: But unless adjustments are made to accommodate the changes, I fear I will only lose interest in the game after installing the new patch. And not installing the patch just feels wrong because I'd be out of step with the public when discussing the game in these forums. Maybe you can help Firaxis make the adjustments for a future patch? :D
     
  17. Blake

    Blake The AI Guy

    Joined:
    Feb 18, 2006
    Messages:
    342
    Location:
    Apolyton
    [Repost of What I said on Poly]

    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.
     
  18. Blake

    Blake The AI Guy

    Joined:
    Feb 18, 2006
    Messages:
    342
    Location:
    Apolyton
    Reponses:

    Okay I'll state that I do plan to add better strategy and tactics altough this may be limited with save game compatability. Sooner or later I'll get around to adding new city attack logic. At that point a human will be hard pressed to stop an AI like Napoleon from smashing right through their empire, mainly because the AI wont actually engage in combat unless it can already win, it will be evasive and only strike when it has local superiority, no more suicidial smashing of attack forces against city walls.

    The AI will use a basic attack approach like this:
    1) Get a stack bigger than the enemy can kill.
    2) Park it next to a city on a defensive tile if possible.
    3) Blast the city defenses down to zero (skip turn for other units).
    4) Soften the city up with siege or low exp units.
    5) Kill the defenders with the best city attackers.
    6) Move in if it wont split up the stack too badly.

    The main problem will probably be getting the AI's to defend against such brutal tactics, I would give an AI like Gandhi no chance of survival against Napoleon, if they start together (just like Gandhi has no chance of survival against a human attack). So the game will end up with small, fast teching peacemongers like Mansa Musa, who manage to avoid being the target of a warmonger, then all devouring and conquering monsters like Napoleon, Caesar and Alexander, killing off their neighbours and building a massive war machine. Human strategy will be a matter of out-racing the warmongers to domination, or trying to tech to space while avoiding the wrath of a warmonger (since even if you survive, the war would be very punishing).

    Nope. You'll have to do a diff (ie WinMerge) against the stock 2.08 SDK or maybe 2.00 if you're talking about merging into 1.61.

    I tend to make changes all over the place so the labels would get really quite messy.


    "The real question is not whether machines think but whether men do." ;).

    In my opinion, CIV4 is relatively formulamatic. You can use formulas for developing cities, for sieging bases etc. I have a mind which is good at seeing the formulas (ie I try to reverse-engineer intution) and can I thus have little trouble teaching the AI the same formulas for success. The Pinacle of CIV gameplay seems to be learning all the formulas for everything. Not that much about CIV is fuzzy, hard logic tends to rule.

    Where the AI is fundamentally most lacking is co-ordination, things like slingshots, or bringing in war allies... in short, the AI isn't good at timing stuff, it's not a good puppet master. I think the AI can learn tactics, it can learn strategy. It'll have the most trouble with metastrategy.

    What I certainly don't agree with is that the AI has to do it's own learning. Humans share experience an awful lot, often in the form of rules of thumb and such. like "If you're boxed in you'll probably need to go to war to acquire more territory", what is the difference between learning this the hard way, and just being taught you need to bust out from such a sitution?

    I do agree that it's not really an AI, it's more accurately described simply as a Computer Player, as opposed to Meat Players.
     
  19. V. Soma

    V. Soma long time civ fan

    Joined:
    Apr 13, 2004
    Messages:
    3,879
    Gender:
    Male
    Location:
    Hungary
    Blake,

    I opened a thread on it but would like to see your opinion on it
    and perhaps this belongs to this "better AI" topic:

    So

    When on auto-pilot, or AI:
    do the workers take into consideration when working for a city
    that what the city governor's emphasies are set to?

    Thread:
    http://forums.civfanatics.com/showthread.php?t=191739
     
  20. Wlauzon

    Wlauzon Prince

    Joined:
    Oct 1, 2005
    Messages:
    573
    Does this change any of the AI controlled player side, like worker automation?

    Was wondering because in a couple of games I was also seeing the workers doing the chain farm thing when on auto.

    And does it have any effect on what the advisors suggest (which is often useless anyway, but...).
     

Share This Page