AI Tech Shooting Ahead

albie_123

Modding In Secret
Joined
Mar 12, 2010
Messages
1,380
Location
Sydney, NSW
This is continually occurring in my games. Playing on Epic speed on King difficulty.

(This is turn 74.)
 

Attachments

  • Turn74Epic.jpg
    Turn74Epic.jpg
    86.5 KB · Views: 209
Same here in version 3.8 . It made the game more challenging but just didnt feel natural especially when I used info addict to see that the modern era AI had half my science output but was still getting techs faster than me.
 
What difficulty? Could you attach your savegame? I believe there might be some sources of science that infoaddict might not be able to account for with CEP active.
 
You can try commenting out CAT\AI\CEAI_Events.lua line 973:

PHP:
--LuaEvents.ActivePlayerTurnEnd_Player.Add(AIPerTurnBonuses)
 
It happened since 3.8 to me too.
Also on 3.8.1.
Doesn't seem to be just tech, more like about all AI bonuses.

It's especially crazy on deity. Played for Gandhi, haven't even covered half of ancient era, only one step into classical and I get a bunch of pikemen marching on me. A couple turns later I get a spy. That's right, I haven't even invented the wheel yet and the guys are already in Renaissance.

I was however able to pretty much catch them all up by the end of the game (although with quite serious focus on science), which suggests that AIs probably didn't get their bonuses increased as they got through eras meaning the whole 'progressive AI bonuses' thing seems to have fallen off.
Looks like a very major issue to me since imho the single greatest thing about this mod is that AIs get bonuses gradually instead of just having a super jump start, making top difficulty levels so much more playable. And it seems that because of other things the mod does (I guess more units at start, cheaper upgrades etc.), Deity here is now actually much crazier than in vanilla. albie_123's screen is not so bad compared to deity. If I remember correctly, I had 4 techs when top AIs had 25. And here's another screen: Hagia Sophia is built on turn 25.

If it helps, here's also a save with that Hagia Sophia (with 3.8.1).

I'll try to turn on logging and see what's happening within that AIPerTurnBonuses function.
 

Attachments

  • Hagia Sophia 25.jpg
    Hagia Sophia 25.jpg
    110.5 KB · Views: 105
  • Augustus Caesar_0025 BC-3000.Civ5Save
    904.8 KB · Views: 43
You may also want to set your logging level to Debug in CEAI_Events.lua line 11 if you don't disable the function:

PHP:
log:SetLevel("DEBUG")
 
I haven't tried Stackpointers suggestion yet. I just received the rankings for literacy. I have three techs, the leader had either 7 or 8. King difficulty. Logs attached.
 

Attachments

  • Lua.rar
    11.3 KB · Views: 65
Toby, the only errors in your logs is that you didn't delete the DoPolicyFreeBuildingClasses functions like I specified in the RnR thread. If you set your logging level to debug then we can see how much science the AI is getting early game.
 
Preeeetty sure I did. I better make sure I sent you the right logs.

Edit: hahahahaha

Such stupidity. I deleted DoPolicyFreeBuildingClasses(player, policyID) on line 792, but then deleted line 800 instead of 799.

Gawd I'm sorry for causing you so much extra trouble, always due to my own foolishness.
 
You can try commenting out CAT\AI\CEAI_Events.lua line 973:

PHP:
--LuaEvents.ActivePlayerTurnEnd_Player.Add(AIPerTurnBonuses)

commenting that out solved the problem, but it leaves the AIs pretty toothless. Appears we just need to retune the value of the bonus? where is that defined?
 
Either the constants or the formula needs adjusting. Here's the formula in CAT\AI\CEAI_Events.lua line 947:

PHP:
function AIPerTurnBonuses(player)
	local capitalCity = player:GetCapitalCity()
	if capitalCity == nil or player:IsMinorCiv() or player:IsHuman() then
		return
	end
	log:Debug("%-25s %15s", "AIPerTurnBonuses", player:GetName())
	local activePlayer		= Players[Game.GetActivePlayer()]
	local handicapInfo		= Game.GetHandicapInfo()
	local yieldStored		= player:GetYieldStored(YieldTypes.YIELD_SCIENCE)
	local yieldRate			= player:GetYieldRate(YieldTypes.YIELD_SCIENCE)
	local yieldMod			= handicapInfo.AIResearchPercent/100
	local yieldModPerEra	= handicapInfo.AIResearchPercentPerEra/100 * Game.GetAverageHumanEra()
	player:ChangeYieldStored(YieldTypes.YIELD_SCIENCE, Game.Round(yieldRate * (yieldMod + yieldModPerEra)))
	--
	log:Debug("Sci bonus for %-25s: %5s + %4s * (%4s + %-4s) = %5s (+%s)",
		player:GetName(),
		yieldStored,
		yieldRate,
		Game.Round(yieldMod, 2),
		Game.Round(yieldModPerEra, 2),
		player:GetYieldStored(YieldTypes.YIELD_SCIENCE),
		Game.Round(yieldRate * (yieldMod + yieldModPerEra))
	)
	--]]
end

LuaEvents.ActivePlayerTurnEnd_Player.Add(AIPerTurnBonuses)

The constants AIResearchPercent & AIResearchPercentPerEra can be found in CAT\AI\CEAI_FixTables.lua:

PHP:
	Line 374: AIResearchPercent              = 0, --HANDICAP_SETTLER
	Line 375: AIResearchPercentPerEra        = 0,
	Line 453: AIResearchPercent              = 0, --HANDICAP_CHIEFTAIN
	Line 454: AIResearchPercentPerEra        = 0,
	Line 532: AIResearchPercent              = 0, --HANDICAP_WARLORD
	Line 533: AIResearchPercentPerEra        = 0,
	Line 611: AIResearchPercent              = 18, --HANDICAP_PRINCE
	Line 612: AIResearchPercentPerEra        = 4,
	Line 690: AIResearchPercent              = 36, --HANDICAP_KING
	Line 691: AIResearchPercentPerEra        = 8,
	Line 769: AIResearchPercent              = 54, --HANDICAP_EMPEROR
	Line 770: AIResearchPercentPerEra        = 12,
	Line 848: AIResearchPercent              = 72, --HANDICAP_IMMORTAL
	Line 849: AIResearchPercentPerEra        = 16,
	Line 927: AIResearchPercent              = 200, --HANDICAP_DEITY
	Line 928: AIResearchPercentPerEra        = 20,
	Line 1006: AIResearchPercent              = 0, --HANDICAP_AI_DEFAULT
	Line 1007: AIResearchPercentPerEra        = 0,
 
I'm playing Epic and King too with Babylon. Total focus on science with 4 cities. I'm almost last in techs by Industrial even though my science output (info addict) is tied for top. The leading civs are 5-7 techs ahead, almost an era. They have also spamed cities to the tune of 15+.
 
I have conducted a handful of tests to determine what is going on with this science boost and have come to the conclusion that the AI must be getting techs from either ruins, gifts from CS or Great Scientists.

There simply is not that much of a difference in the :c5science: output to justify being 5 or 6 techs behind the rest of the pack.

Even when I mainline a scientific civ to get science boosting wonders and free techs, I have been behind the leading civ. Yet the logs, that I have changed to show results every 5 turns, show the yields simply don't allow for the huge lead.

I have no way of seeing what 'extras' the AI is receiving to give them this boost so it is not a definitive result. If anyone can provide another alternative to where they get the techs, I'm all ears.
To set everyone's mind at ease, the :c5science: output each civ produces is not skewed to the detriment to the player.
 
OK, so I followed the link.

When will this formula change be integrated into a new version of the mod? Or isn't it that simple? (And what changed from when science was working well?). Correct me if I'm wrong, but the above seems a bit hit-and-miss.

Basically, what Expired is saying. So, following the link ain't that great/useful.
 
Ok, let me say it here and for those that also read this thread.

Whilst the actual formula used to govern the science output was changed, and produced some 'odd' results. It alone is not the cause of the AI Tech boost.

All the tests I have done show a direct correlation between population and science output, obviously. So any civs with a population bonus will likewise get a science boost.

But!

I can match them in the actual output of :c5science: and they still get techs from somewhere else.
Until we can pinpoint what bonuses are giving the AI these extras, the likelihood of them running ahead remains.
They do get some insanely powerful boosts from CSs. In one test, England was cut-off from 3 CSs by my empire early in the game yet still managed to form alliances with them and get gifts and happiness from them. All of which helps their science output.
Just how England managed to trump me to the alliances without constant gold-buying of influence is beyond me.

So, to everyone that is troubled by this experience may I ask you to take notes on your progress through the game. Use IGE, the FireTuner, InfoAddict or just the logs, but take as much notation as possible. The more of a range of scenarios to work from the greater the chance this 'quirk' will be found and squashed.
I am particularly interested in the background stuff.
Take note of ruins being found and if that civ gets the boost.
How many alliances with CSs does the leader have?
Is their :c5happy: level comparable with their :c5science:?
What is the population, etc. like?
Are they building Wonders and getting the techs there?
 
stackpointer and I are currently in discussion about this matter and something important has come to my attention.

The yields displayed in InfoAddict and the logs 'may' not be including the AIBonuses as described in stackpointer's post.

We are now tweaking the values back down to the values as found in GEM. They were initially 'upped' to compensate for the failings of the AI but since stackpointer has now fixed that bug, the values 'may' now be the fault.

Both he and I are setting up some tests to run and examine the new values.

If anyone else wants to do the same the values we will use are:

AIResearchPercent = 0 for all the levels.

This should give us a baseline to work from.
 
I realized this is probably an unintended consequence of not updating the Yield Library after BNW. I thought I'd disabled all references to it, but it turns out there's a few bits of code still lingering around the project. I'm starting to think it will be better to just adapt the library to BNW so it can be used again.

I was hoping to fix the problems directly in the game core files, but it would be such a massive undertaking I just haven't been able to get the motivation to do it the "right way."
 
Top Bottom