AltAI Mod - An additional, alternative AI (alpha)

Carboniferous

Warlord
Joined
Feb 9, 2008
Messages
107
The ALTAI Mod

Welcome to the AltAI mod. What on earth is this? Well, it's an experimental AI replacement, but with a big difference to other AI improvement mods. Instead of changing the existing AI we all know and love, this mod takes over the AI logic for only some players. So, you have two AIs competing. The aim is of course to develop the mod's AltAI to the point where it can eat the existing one for breakfast (and provide the player with something different) ;)

Latest version - version 0.4.

At this stage, the code is still very much alpha - the AI is not yet complete. However, it has reached the point where it is isn't totally hopeless and there is enough of interest to merit releasing a version.

This project started as an attempt to see how an AI which was based much more on calculation with a minimum of magic numbers controlling its logic would behave.

The main things which are implemented are an alternative worker AI, different city site selection code, city plot and specialist selection and basic building and unit selection.

I intend to continue development and release new versions fairly regularly, if there is interest.

To download the mod, follow this link:

http://forums.civfanatics.com/downloads.php?do=file&id=18053

I welcome constructive feedback and questions.

The code for this project can be found here: https://github.com/Carboniferous/AltAI

Please be aware that the mod does slow down the game to a degree. There is a lot of extra calculation going on (the mod can simulate a full city and its plots for a number of turns to work out the effect of buildings for example, and it calculates the value of plots by working out the full set of theoretical improvements for a city, it can chain irrigation, and understands impassable mountain ranges). Also, for now I recommend sticking with standard size maps and normal speed (the new worker AI does not yet stack workers in most cases)

Below are some screenshots from one of the recent Nobles Club Games - specifically this one: http://forums.civfanatics.com/showthread.php?t=408864

The first pair of screenshots compare running the game under autoplay for 200 turns with and without the AltAI mod at Noble, running just the human player with the alternative AI.
The second pair compare the build lists (v. different), and the tech situation. Hopefully these give an idea of how different the AI's behaviour is (not necessarily better, just different)

attachment.php


attachment.php


attachment.php


attachment.php


attachment.php


attachment.php
 

Attachments

  • Civ4ScreenShot0024.JPG
    Civ4ScreenShot0024.JPG
    333.2 KB · Views: 1,181
  • Civ4ScreenShot0027.JPG
    Civ4ScreenShot0027.JPG
    334.2 KB · Views: 1,172
  • Civ4ScreenShot0025.JPG
    Civ4ScreenShot0025.JPG
    199.8 KB · Views: 1,219
  • Civ4ScreenShot0028.JPG
    Civ4ScreenShot0028.JPG
    200.3 KB · Views: 1,164
  • Civ4ScreenShot0026.JPG
    Civ4ScreenShot0026.JPG
    172.9 KB · Views: 1,160
  • Civ4ScreenShot0029.JPG
    Civ4ScreenShot0029.JPG
    174.1 KB · Views: 1,171
One last screenshot - just to show that the new AI can fight wars - at least those on the same landmass (I still need to implement selection of boats (and aircraft!) in the build selection code).

Strictly speaking, it's the existing AI fighting the war, but the new AI deciding what units to build - but interestingly, this seems to work OK.

This is from another run of the game above (with two AIs under the Mod's control - note how Qin is teching OK, but not very high in score as he didn't manage to expand that much)

attachment.php
 

Attachments

  • Civ4ScreenShot0031.JPG
    Civ4ScreenShot0031.JPG
    311.1 KB · Views: 1,153
But also AltAI vs Kmod...

Merging BetterAI or KMod (didn't know about KMod until I posted my mod here) wouldn't be too hard, as almost all the AltAI code is in separate files - I've mostly only changed the existing code to switch certain decisions to AltAI. For example:

Code:
TechTypes CvPlayerAI::AI_bestTech(int iMaxPathLength, bool bIgnoreCost, bool bAsync, TechTypes eIgnoreTech, AdvisorTypes eIgnoreAdvisor) const
{
    PROFILE("CvPlayerAI::AI_bestTech");

    // AltAI (and not a free tech let the default AI handle that for now)
    if (m_bUsingAltAI && (!bIgnoreCost || eIgnoreTech != NO_TECH))
    {
        TechTypes techType = GC.getGame().getAltAI()->getPlayer(m_eID)->getResearchTech(eIgnoreTech);
        if (techType != NO_TECH)
        {
            return techType;
        }
    }

    // rest of function is as before...

Because of the way AltAI is written, it would get the benefit of much of KMod's changes to military tactics.

My main aims at the moment are to finish the unit selection logic to include boats and aircraft, and then to work on city specialisation. AltAI computes a complete set of plot improvements for each city (this is part of how it can attempt chain irrigation), and I plan to use that to determine which cities are best suited to different specialisations.
 
New version 0.2 uploaded (see link in my sig)

Please note that saves from the previous version (0.1) are not compatible with this version (0.2).

Includes various fixes/improvements including tech selection now values techs which give free techs (i.e. Liberalism), unit selection code will build boats for settlers (still needs some tweaking), fixed a bug in unique plot key calculation which sometimes caused certain tiles to be misvalued for city site selection. Tweaked settler build decisions to avoid over-expansion. Fixed city build selection to select build culture when available for new city with no culture.

I've also made the code available here:

https://github.com/Carboniferous/AltAI

Enjoy!
 
Version 0.3 is now out. Most of the changes are internal - speeding up calculations and fixing bugs with the code that tracks the value of plots for cities and suchlike. Allow the AI to build National Wonders, but its selection needs work (it will likely build Oxford, as it will tend to build enough universities).
 
Looks interesting and I'll probably keep an eye out for updates to see how your going :)
 
Just to say I've uploaded the latest version (0.4).

This contains lots of bug fixes/tweaks to the existing code, plus logic to understand projects (so it can build the spaceship).
City build logic now understands about power (the electric kind!).
Workers now build railroads to connect cities and improve squares which will benefit.

Still a long way to go, but I have observed this version win some games on autoplay (via diplomation and spaceship).

Next step is to further rework the city build logic to integrate dependant builds (i.e. build a monastery so can build missionary to spread religion to a city which needs more happiness, etc...)

Feedback is appreciated!
 
Hi Carboniferous!

So, any updates on your AI??
 
I am working on the next release - doing a major rework of the city building/unit selection logic at the moment.

Just curious, does anyone have any feedback on how the AI feels to play against compared to the normal one?
 
Top Bottom