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

Civ 1 explained: AI wonders

Discussion in 'Civ1 - General Discussions' started by tupi, Apr 3, 2020.

  1. tupi

    tupi Chieftain

    Joined:
    Jun 25, 2011
    Messages:
    60
    Location:
    Russia
    As you know, in Civ 1 computer player is a cheating bastard and it gets Wonders for free. And here is the exact algorithm how it does that.
    https://pastebin.com/Psx6QegR

    This routine runs at the beginning of every turn right after check for global warming (in the same function). Game calls this function right after sea barbarian spawn and land barbarian spawn.

    Some notes:

    1) AI tries to build a wonder in a random city (0..127) at the beginning of every turn. Number of tries = game difficulty+1. City (0..127) and wonder (from 1 to 21) are randomly selected for each iteration.

    2) AI never builds more than 1 wonder per turn.

    3) Of course AI should know civ advance for wonder to build it. But it doesn't care if wonder is obsolete or not.

    4) AI can build a wonder only if [population of city > wonder cost in shields/100]. For example, most modern wonders cost 600 shields. This means AI can build such a wonder only in a city with population 7 or more.

    5) on Chieftain difficulty, AI never builds a wonder if human player don't have a civ advance to build a city improvement with the same number as a wonder. For -1 tech (hanging gardens/barracks) tech check always returns 1.

    6) on Chieftain and Warlord difficulty AI never builds a wonder if this wonder is selected as current production in one of human player's cities. (except for Manhattan Project - actually AI will change wonder to MP in this case).

    7) construction of Wonder zeroes the shield counter in the city

    8) AI actually pays for wonders with gold! But only 1$ per shield (full row = 10 shields here regardless of difficulty) and never more than 1/3 of its treasury. So even if it doesn't have enough money - it will still build a wonder and will only lost 1/3 of its gold for that. Accumulated shields should be counted as part of the wonder cost for 1$/shield discount, BUT shield counter is nullified BEFORE that, so it doesn't matter.

    9) for Manhattan Project, there's some additional rules. AI builds it only if it knows Rocketry tech (for nukes). If human player knows Rocketry too, then AI will build it only if AI civ military_power <= human player's civ military power. Not only that, but Manhattan Project is always selected in first iteration IF AI knows Rocketry and player doesn't.

    10) probably everybody knows, but if you have an embassy, you will get Foreign Minister report instead of Travellers report.

    11) AI civ can't build wonders when it's in anarchy state

    Sorry for some poor grammar.
     
    Last edited: Apr 21, 2020
    krus5, Tenochtitlan and axx like this.
  2. axx

    axx Chieftain

    Joined:
    Feb 19, 2011
    Messages:
    93
    Again, great job! :thanx:
    Reading this, it's quite interesting how they (he :queen:) implemented this back then. So playing on >= prince difficulty shouldn't bring any changes in the AI wonder building logic. And I guess the AI wasn't building wonders nearly as often as it should hence the logic in note 8).
    (posted this here https://github.com/SWY1985/CivOne/issues/505 if you don't mind)
     
    Last edited: Apr 3, 2020
  3. tupi

    tupi Chieftain

    Joined:
    Jun 25, 2011
    Messages:
    60
    Location:
    Russia
    Well, only more iterations, but I think this is most crucial difference. Apart from this, difficulty affects only indirectly: ai cities grows faster on highter difficulties/ai has more cities/ai researching advances faster so it can build some wonders.
     
    Last edited: Apr 3, 2020
  4. Mize

    Mize Warlord

    Joined:
    Jun 17, 2011
    Messages:
    292
    Great stuff, tupi! I very much like the logic for nuclear deterrence -- if AI civ military_power <= human player's civ military power.
    This fits in very nicely with what I have experienced. Whenever the AI nuked me first, I was always much more powerful AND I didn't have nukes of my own. As soon as you have nukes of your own, the AI will only strike in retaliation.
     
  5. tupi

    tupi Chieftain

    Joined:
    Jun 25, 2011
    Messages:
    60
    Location:
    Russia
    Note 5 was incorrect. On chieftain difficulty, AI don't build a wonder if human player don't have a civ advance to build a city improvement with the same number as a wonder.
     
    Last edited: Apr 17, 2020
  6. Noddy

    Noddy Chieftain

    Joined:
    Jan 24, 2015
    Messages:
    9
    Great info. I somehow have made the experience that if I (as human player,on harder difficulties) is building a certain wonder (and have half or 2 thirds of the required shields) than the AI will build the exact same wonder (before I'm finished). I wonder if this is random or is it in the code (in order to annoy the player)?
     
  7. tupi

    tupi Chieftain

    Joined:
    Jun 25, 2011
    Messages:
    60
    Location:
    Russia
    Nope, just illusion of perception. I think you better remember when this happens and don't care when it doesn't happen. I always use caravans for wonders, anyway. And still AI sometimes build the wonder before me. In this case, there's no way for the game to know what wonder I'm going to build with my stack of caravans. So, it's just our human psychology and nothing more.
     

Share This Page