• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

How can I study AI performance?

gavenkoa

Prince
Joined
Jun 11, 2019
Messages
485
Location
Ukraine
In semi-isolation game https://forums.civfanatics.com/threads/nobles-club-366-justinian-i-of-byzantium.692846/ we have the only access to Financial AI. On IMM I found that AI very tech-performant. After few initial trades (which I enabled by planned resource & city gifting + shared religion) I cannot match performance of the AI and lose ability to trade after T100-120 - even if I control what AI is researching via espionage.

In the game all espionage goes to that single AI so I see F9 GNP report and I lose 2 times at T120. This & espionage research speed of techs are legit indicators of our economy difference. I compare F9 Gold report quite often to understand my performance.

To study the difference more I used non-legit means - Ctrl+W - WorldBuilder. In the F2 (Financial Advisor) I could choose AI and I so my rival works ~= 80% tiles more & generate 100% research. I want to study situation in finer details regardless if it is considered cheating. What are the options?

Can I see AI's happy / health limits? Can I look inside AI's cities and see their unit / building prices or how many GP settled in a city?

Will I see shrines in the list of Wonders on F9?

And somewhat offtopic - maybe it is dumb to try match semi-isolated AI economically and instead focus on breaking isolation or overthrow AI with military might before Optics / Astro?

I want to understand why AI is so ahead in research. I see 2 reasons from Worldbuilder F2 screen - I work less much cottage tiles against Financial AI. But I designed empire to work on cottages, probably my cities are small (3-6 vs AI's 6-10). But I don't have happiness enough for large cities... Maybe AI is full of religious buildings... because it wasn't at Monarchy yet at some point...
 
And somewhat offtopic - maybe it is dumb to try match semi-isolated AI economically and instead focus on breaking isolation or overthrow AI with military might before Optics / Astro?
Yes, it frequently is better to meet others ASAP.

Will I see shrines in the list of Wonders on F9?
Yes.

I want to understand why AI is so ahead in research. I see 2 reasons from Worldbuilder F2 screen - I work less much cottage tiles against Financial AI. But I designed empire to work on cottages, probably my cities are small (3-6 vs AI's 6-10). But I don't have happiness enough for large cities... Maybe AI is full of religious buildings... because it wasn't at Monarchy yet at some point...
On higher difficulties the AI gets significant boni, take a look at Beyond the Sword/Assets/XML/GameInfo/CIV4HandicapInfo.xml, especially all the iAI... entries. These boni increase with each era.

Keep in mind that in that game you are isolated with Willem, who is one of the best AI techers.


For getting more information on how AI cities look like, I can think of three main options.
  1. include a better WB mod, e.g. the Platy Builder
  2. have enough espionage points to be above the "explore city" threshold
  3. use the debug mode (Cheatcode = chipotle in the .ini file)

1 is more difficult, and maybe less insightful, but having lots of :espionage: against an AI, as required in option 2, will impact AI behaviour. I do not have any experience with 3.
 
One additional note about inefficiency I spotted, comparing my performance to AI's: I paid extra ~ 10gpt for unit count & 5gpt for units away. Those were Warriors & Chariots for fog busting.

AI paid zero, and WorldBuilder's F2 screen showed different "free unit" (it is based on city size + population somehow), like 28 vs my 12. Also some AIs had astonishing handicap, like -13 for Shaka, while for a human it is always a fixed discount -1.

On higher difficulties the AI gets significant boni, take a look at Beyond the Sword/Assets/XML/GameInfo/CIV4HandicapInfo.xml, especially all the iAI... entries. These boni increase with each era.
I'll comment IMM:


Code:
iResearchPercent = 125 (human pays 25% more for research)
iFreeUnits = 2 (in fact it is not clear final "free cost" for a human & an AI, AIs have huge handicaps)
iHealthBonus = 2 ("From difficulty level", same for me & AI)
iHappyBonus = 4 ("We just enjoy life", same for me & AI)
iAIStartingDefenseUnits = 3 (AI has 3 archers at start)
iAIStartingWorkerUnits = 1 (AI has one Worker - stealing of Worker punishes AI the same as you)
iBarbarianDefenders = 4 (Barb's cities spawn with 4 Archers inside)
iAIGrowthPercent = 85 (AI has a lower city grow threshold by 15%)
iAITrainPercent = 80 (units are chipper by 15% for AI)
iAIConstructPercent = 80 (buildings are chipper by 15% for AI)

iCivicUpkeepPercent = 100 (% for human)
iAICivicUpkeepPercent = 80 (% for AI)
iInflationPercent = 100 (% for human)
iAIInflationPercent = 80(% for AI)

iAIUnitCostPercent = 80 (% for AI, reduces the unit support cost, based on total number)
iAIUnitSupplyPercent = 50 (% for AI, reduces the unit supply cost outside of cultural border)
iAIUnitUpgradePercent = 50 (% for AI)

iAIWorkRateModifier = 75 (AI workers requires less turns for improvements, base / (1+mod%), for a cottage it is 4 / (1+.75) = 2T?? as rounding is down)

Happy/Health caps seems the same for human / AI - checked with Great Spy.

But Great Spy shows 2-pop sity has 18 food threashold instead of 24, 8-pop - 27 vs 36. So it is 18/24 = 27/36 = 75%, but iAIGrowthPercent = 85. I didn't get why XML & UI show the difference...

So AI has cheaper techs, units, buildings (exept Wonders), faster workers' improvements, faster city grows (meaning better slavory). And initial Worker + some techs (Wheel, Agri, Hunting - help grow early).

Now I see why AI has more improved tiles - 2T per cottage?? (haven't confirmed in game) + faster city growth (25% discount??) + cheaper Workers (20% discount??).
 
This is possibly due to iAIPerEraModifier
Actually it is confusing, because source code of DLL tells that the cost of city growth should increase for AI CvPlayer::getGrowthThreshold:

Code:
    if (!isHuman() && !isBarbarian())
    {
        iThreshold *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIGrowthPercent();
        iThreshold /= 100;

        iThreshold *= std::max(0, ((GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIPerEraModifier() * getCurrentEra()) + 100));
        iThreshold /= 100;
    }

Like (AIPerEraModifier * era + 100) / 100 should increase iThreshold. I cannot explain difference between source code & in game numbers...
 
You could just run espionage slider 100% and put spies in AI capital? Great spy from great wall will speed this up but you can just cook the map to have stone for you :) You will be able to click and open AI cities
 
If you take a look you will notice that iAIPerEraModifier is negative, and thus (AIPerEraModifier * era + 100) / 100 is smaller than 1, resulting in lower costs for the AI.
 
Regular or Great Spy? I know only about Great Spy mission of implanting spy points... And what is importance of AI's capital, what about any other city?
Yes, use great spy for points and then regular spies for doing missions. I've only done it a few times. But at some point you start to see stuff like AI build order and city screens. I would put a few spies in capital (doesn't have to be capital) and steal techs. You get discount on missions if you spy has been in the city longer.
 
use the debug mode (Cheatcode = chipotle in the .ini file)
I tried this option because I saw Python files, defining Advisors' screens have conditions on "debug mode" for displaying dropdowns for leader selection. Dropdowns are available in WorldBuilder too, but switching to it has some 3sec delay, so I thought debug mode enables selection of leaders.

Unfortunately editing the CivilizationIV.ini is not enough, you need to press Ctrl+Z, but then you are in much "advanced" mode, not comparable even with WorldBuilder - you can see inside AIs' cities (which early I simulated planting Great Spy via WorldBuilder).

Ctrl+Z works faster than Ctrl+W (WorldBuilder). So I'm happy. IDK if other options are available...
 
Dropdowns are available in WorldBuilder too, but switching to it has some 3sec delay, so I thought debug mode enables selection of leaders.
I remember that those advisors were implemented in Python code. After some search I found them in:

Civ4/Assets/Python/Screens
Civ4/Beyond the Sword/Assets/Python/Screens
Civ4/Beyond the Sword/Mods/BUGMod_4.4/Assets/Python/Screens

In my case I start the game with mod="Mods\BUGMod_4.4" so only edits in last directory had effect.

I replaced few cases of CyGame().isDebugMode() with CyGame().isDebugMode() or True and now I can see AI's stats without WorldBuilder or debug mode. It is not cheating because if you don't choose another AI in the dropdown - that info won't be revealed against your will.
 
I noticed that Lain used F9 Demographic screen a lot, instead Graph.

Demographic screen is always available, regardless espionage points or met AIs.

Also I didn't know that Demographic & Graph screens shows the same data different way.

Food & Prod are Food & Hammers after all multipliers - basically the engine iterates over all cities and extract attribute performance (IDK if Food have any multipliers, but Hammers should take into account leader's trait, 100% for having access to resource, Forge, etc).

GNP is a bit difficult to understand. It is like Research + Gold + Culture + Espionage - Expanses. But not exactly:

Code:
int CvPlayer::calculateTotalCommerce() const {
    int iTotalCommerce = calculateBaseNetGold() + calculateBaseNetResearch();
    for (int i = 0; i < NUM_COMMERCE_TYPES; ++i) {
        if (COMMERCE_GOLD != i && COMMERCE_RESEARCH != i) {
            iTotalCommerce += getCommerceRate((CommerceTypes)i);
        }
    }
    return iTotalCommerce;
}

enum CommerceTypes                    // Exposed to Python
{
    NO_COMMERCE = -1,

    COMMERCE_GOLD,
    COMMERCE_RESEARCH,
    COMMERCE_CULTURE,
    COMMERCE_ESPIONAGE,

    NUM_COMMERCE_TYPES
};
 
Maybe you need to improve your general game play. Some AI like Mansa and others will out tech you. Of course the human play knows how to bulb techs. You can also trade techs to catch up with the leading AI. That or wipe them out before they get too far ahead.

The Ai get bonuses against the player and these increase on the harder difficulty levels.Plus many free units on Immortal and deity. If you saw the city tile management of the Ai you would understand how badly the Ai can play at times.

Most AI will refuse to trade with you if they see you have traded too many techs with other AI. I forget the exact number but some are set really low at 8 or so. So trading 2 techs for 1 early on is bad. Trading for techs under 200 beakers is very bad in general
 
Back
Top Bottom