[151.9] Giant AI Bug

I'm starting to think it's not a bug, but just poorly-assigned AI priorities.

This thought has occurred to me, too. Though the game described in the OP was certainly and severely bugged (and yesterday's screenshots should confirm it), so I don't know what to think.

Regarding flavor priorities, I think I misinterpreted what the "expansion" tag meant when I made the suggestions in the AI Priorities thread - it might be a good idea to remove some of the additions of that on buildings (so the AI doesn't think a Monument has the same expansion value as a Settler).
 
Those screenshots show the difference between vanilla and mod functions for display purposes only, so they can't confirm or disprove a gameplay bug. It doesn't matter what values appear visually on the screen. The "update modded yields" procedure works the same way regardless of what we see. This is why the debug output I added will be useful... it shows the actual gameplay values, bypassing any possible visual bug.
 
If it's not a bug - something we discussed in the thread that led to this one - then wouldn't it be relatively to isolate what changes were made around v148 that would so noticeably alter AI priorities?
 
I think these were the steps leading up to now:
  1. Vanilla flavors range from 0-10 without a discernible pattern.
  2. I changed these to a base-2 scale from 0-32 (2, 4, 8, 16, 32).
  3. AIs complained much more about land disputes, telling us to not settle cities even when we only have our capital. I eventually guessed Firaxis might use flavor_expansion as a factor in land disputes, so #2 caused #3.
  4. I returned flavors to the 0-10 range, while maintaining the base-2 scale for organization (0, 1, 2, 4, 8).
  5. AIs did funky things like not expanding, growing, or building wonders as expected.
  6. I adjusted AI flavors some more.
  7. They seem to be acting more rationally now.
If land disputes appear less now than before, we can reasonably conclude flavors affect both this thread's problem (odd AI behavior) and land disputes (the old thread).
 
Thanks, Thal. In v152.7, the 3 AI on my continent have grown quickly (!) from the start. Someone built the GL before I even got around to it. And An AI was conquered somewhere on t56... so, looking good!
 
I've discovered the AIs might not be getting their intended production and gold bonuses in the capital. I'm investigating why this might be. If this is true, it would explain the poor AI performance lately.
 
One anomaly is that a mediocre Germany had over 5000g at one point. This turn 3 civs have between 2621 and 2857. That's probably within the desired range.
 
Ah yeah... probably just failed in their purchase attempts for a few turns. For efficiency's sake AIs check at most 5 priorities, stopping when they find something to buy. If they don't find anything within 5 attempts, they wait until the next turn.
 
I just played a very competitive immortal level game up to turn 200.
I used the "Have Fun" mod several times to check out the enemy cities at turns 80 and 100.
All the yields added up to the terrain and the buildings. The capitals had a 20% bonus of some type going on.

Settlers were being built in every civ even at turn 100. It's an overwhelming drive that reminds me of civ 3. The AI settlers were always wandering around my territory and dropping down next to a resource right in the middle of my cities. They did this to each other as well. There was little sense of territorial contiguity.

Another possible problem is that most of the civs, except the militaristic ones, had merchant specialists in their granaries even when good yields were available in the terrain. No specialists in libraries or walls. It was as if there is an imperative to get out a great merchant.

Overall, the game was much more challenging than even 152.4. I missed at least half of the wonders. I noticed that my science and policy progress took much longer. The AI was ahead of me in every category by a bit despite my use of specialists in national wonder and wonder cities.

It appears the handicap file give the AI a 12% science bonus per era? Does that mean 24% in era 2?
 
On t229, the six surviving civs have between 9 and 15 cities. This seems reasonable, but on the high side. Happiness ranges: 0, 2, 18, 20, 26, 71.

How does Germany have 15 cities and 18 happiness?
 
Played 90 turns with 152.7 - AI was *extremely* expansive and competitive wrt wonders (ToA-28, Py-33, Mos-38, GL-44), and their tech was flying (blew me out of the water, really, but I got an isolated start). However, my gpt was bugged terribly, hovering around 100g for 30+ turns with between +3-7 gpt. I'd lose 20g for no reason one turn, gain 2 the next, etc.

Edit - don't know if it matters, but in fact I was playing 152.8.

Attached lua.log shows his repeatedly (I assume once for each civ/cs) every turn:
Code:
[504228.615] Runtime Error: [string "C:\Users\lg\Documents\My Games\Sid Meier's ..."]:79: attempt to call global 'IsMajorCiv' (a nil value)
 

Attachments

The "IsMajorCiv" bug was introduced in the Great Works mod, because I didn't create that function used in the mod. I fixed it in a recent version... don't remember which, and I forgot to put it in the patch notes.

It appears the handicap file give the AI a 12% science bonus per era? Does that mean 24% in era 2?

On emperor difficulty, yes. Era numbers start with 0 in the game files:

0% ancient
12% classical
24% medieval
36% renaissance
etc...

The bonus reduces over time from diminishing returns (100% to 110% is a bigger difference than 190% to 200%).
 
I think I found and fixed this bug in v152.11.

The new diagnostic tool helped me identify the problem, and after a few hours tracing execution back through the files I came to this line in the yield library's event registration file:
LuaEvents.ActivePlayerTurnEnd_Player.Add(CleanCityYieldRates)
It should have been:
LuaEvents.ActivePlayerTurnEnd_Player.Add(PlayerClass.CleanCityYieldRates)
To make things run faster the mod stores city yields in a table. The mod typically looks at that table to check city yields instead of re-calculating the entire yield structure from the bottom up. This saves a lot of time. CleanCityYieldRates tells it to recalculate the table from scratch. The problem is when I made CleanCityYieldRates part of the player class, I forgot to change this line to "PlayerClass.CleanCityYieldRates". This meant that rates recalculated for a city only if:

This matches the reports in this thread. In other words... AI cities were stuck with whatever yields they started with, until the game reloaded.
 
In other words... AI cities were stuck with whatever yields they started with, until the game reloaded.

Wow. If that was indeed the problem, then is the AI OP right now, in light of the buffs you gave it to counter the production problem?

And does this also address the recent gpt fluctuation issue?
 
The AI buffs were temporary until this bug was resolved.
It's better to make a quick change so the game is playable but buggy, rather than wait for the weeks it might take to isolate a bug.
 
Back
Top Bottom