Buffed AI for BNW

Spoiler :

Code:
	for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		totalPlayerYield += pLoopCity->getYieldRateTimes100(eYieldType, false);
		totalPlayerPopulation += pLoopCity->getPopulation();
	}

	if (totalPlayerPopulation > 0)
		buffedYield = (totalPlayerYield / totalPlayerPopulation) * iAI_Population;

	if (buffedYield > iAI_Yield) 
		return buffedYield; 

	return iAI_Yield;

EDIT: It is a simple bullet proof technique that has a big effect on the quality of the game. The "false" means trade routes get included in the calculation.

If yield rate times 100 is that cities production / population, then for a human with a single city, that comparison value amounts total production / population ^2.
But it is simple to show that (sum of yield rate) / (sum of population) is not always the above when there are two or more cities.

In fact a human who had a mature city of pop 10 producing 30 science for a yield of 3.
Dividing by pop again, that yields .3

Then founds a new city of pop 1 producing 1 science for a yield of 1.

Sum of yield per population : 4. Empire population : 11. 4 / 11 is about .36. It's actually gone up! Were you intending to give the AI more of a bonus when the human founds a brand new city?

Edit:
I think though the AI needs an additional science buff for cases of human bulbing tech / research agreement / Korea's science boost. Something that would start kicking in if the human has at least 3 techs more than the AI does (Not outright grant a free tech, but some extra beakers on top of the existing formula, that would grow faster than linear as human tech difference increases.) Actually it looks like its the AIs with happiness problems that fall way behind, so perhaps if an AI gets too far behind in techs [say 5+ techs], apply the science part of the boost even if their unhappy.

It would probably be a good idea to lock Great Scientist & Great Writer strength to the turn they are born as well.
 
Additional edit : About 20 turns after entering Rean, Chinese GPT is way down from what it was earlier, they may be building an army to fight their neighbors.
I'm thinking that V17 is actually completely fine, it's just that Poruchiik panicked when the AI's built things increasing income (like external trade routes / market places) much earlier than what he's used to.

Yeah I think that might be it. I play on King difficulty but it seemed really weird that I was getting 2k+ gold per turn. Some AI's were getting 256-500 GPT, some of the luxury resources weren't improved and they had two trade routes going towards me.

As glider1 said lower difficulties might wig out and some random stuff will happen. Overall I don't play that often on Emperor or even higher, but even the combat scaling and just the general AI is alot better in combat even on lower difficulties. Props to Glider1 this mod has renewed my addiction to CiV!
 
Thanks for revealing the difficulty Poruchiik. I tested V15 on king myself and it was a challenge because the AI's started to mirror my own performance. As the difficulty level get's lower, the players seems to have a lot of cash which can be used to over-take the AI despite the adaptive buff.

Yes, agree the problem with this mod is that I too have become engaged in Civ5 again, and I admit I may have to go into rehab at some point which is actually not funny :-)

EDIT:
Still, what you were seeing does look pretty weird no question. I didn't see those numbers.
 
Yeah I think that might be it. I play on King difficulty but it seemed really weird that I was getting 2k+ gold per turn. Some AI's were getting 256-500 GPT, some of the luxury resources weren't improved and they had two trade routes going towards me.

As glider1 said lower difficulties might wig out and some random stuff will happen. Overall I don't play that often on Emperor or even higher, but even the combat scaling and just the general AI is alot better in combat even on lower difficulties. Props to Glider1 this mod has renewed my addiction to CiV!

You as the human were getting 2000 gold per turn? Were you playing Venice?
It's definitely a case that you triggered the gold buff. Too bad the AI doesn't know how to use cash on hand though. The AI really needs taught how to do that to take full advantage of the gold boost.
 
Were you intending to give the AI more of a bonus when the human founds a brand new city?

Here is an example (numbers not real):

Player city A pop 7 and 10 science
Player city B pop 3 and 3 science
This AI city pop 4 and 4 science

First step:
(1000+300)/(7+3) * 4 pop = 520 sci

AI city is doing 4 science (scaled to 400)

So AI city now get's 520 > 400 = 520 science (a boost)

but when the code finishes it is scaled back to 520/100 = 5

AI city gets 5 science instead of 4.

If human now founds a new city the total pop is up 1 and the total science is up 1

EDIT:
Finally, rinse and repeat for all AI cities, that is all there is to the adaptive buff (except for the possible trade route issue in V17)
 
You as the human were getting 2000 gold per turn? Were you playing Venice?
It's definitely a case that you triggered the gold buff. Too bad the AI doesn't know how to use cash on hand though. The AI really needs taught how to do that to take full advantage of the gold boost.

No, I was playing as Assyria on Alej's Africa Map with randomized resources. I think it may have been the fact that Arabia, Egypt, Babylon and Persia are fairly close spawns to each other. I had 2 Gold and one Silver improved, traded the Gold to Egypt for the 7 GPT and managed to get two trade routes (without them being plundered by the multiple barbarian encampments to the north) to both the capitals of Babylon and Persia.

But yeah it was weird. It was a really passive game. What I did was rush to Monarchy and then into the Liberty tree social policy to connect my two cities to reduce unhappiness (completely forget what it is called). As soon as I hit the Classical Era, the gold boost kicked in and I got major amounts of GPT.

There may of been other factors that I can't remember at this point and I didn't save it as I automatically just quit the game to test if it happened again. And it did on a Large Islands map with Byzantium. The GPT was less but hitting Classical Era did the same thing.
 
Here is an example (numbers not real):

Player city A pop 7 and 10 science
Player city B pop 3 and 3 science
This AI city pop 4 and 4 science

First step:
(1000+300)/(7+3) * 4 pop = 520 sci

AI city is doing 4 science (scaled to 400)

So AI city now get's 520 > 400 = 520 science (a boost)

but when the code finishes it is scaled back to 520/100 = 5

AI city gets 5 science instead of 4.

If human now founds a new city the total pop is up 1 and the total science is up 1

EDIT:
Finally, rinse and repeat for all AI cities, that is all there is to the adaptive buff (except for the possible trade route issue in V17)

Ok, if "yield rate * 100" is the total city's yield * 100 instead of being a yield rate [yield / pop], then the math works out well, that 520 would drop to 506 upon founding a brand new city and then back to 5 for no effect. Which is quite reasonable with the new city being such a small part of the human's empire.

Does the AI know about it's bonus when making decision about if it wants arts funding or science funding? Or is there something else in the mod that is causing the AI to want science funding more than normal?
 
Hi Joncnunn, it's good that you are checking this stuff and we should remain sceptical (particularly that Poruchiik's issue is unresolved). I guess time will tell what happens next. The mod does nothing to the AI's decision making process on funding strategies. It should though, that would be the best thing especially for the endgame.

I got your idea to possibly give the AI more yielding if the players tech level is higher than the AI. Can you think of an algorithm that keeps it all automatically under control without having to do a lot of guesstimating? That is the beauty of feedback systems. The feedback does the balancing automatically.
 
Is there a way to determine what it would currently cost to research all techs a player currently has?

If so, perhaps divide the number of beakers the human's techs would cost by the number of beakers the AI's techs would cost and if the ratio is more than 1, multiply your science buff by that?
 
Was thinking along the same lines.
In the DLL you can do anything.

What about this algorithm?:
Is players age at least the industrial?
YES: Is player leading all other AI's in tech?
YES: Concentrate on the AI's that have population within 10% of player or have greater population than player.

Do this every turn:
if the AI has 20 techs left to research at 1000 beakers on paper,
Player has 10 techs left to research at 500 beakers on paper.

AI is yielding at 100 beakers/turn
Human is yielding at 200 beakers/turn

There are expected 200 turns remaining in game.

FIXED goal is for AI to catch up tech in 200 turns / 2 = 100 turns

What does the AI need to yield to catch up tech in 100 turns?

Apply this yield to relevant AI's

Rinse and repeat algorithm
 
My version 17 test game as Korea just now entered Modern era.
Still not seeing anyone with an absurd level of gold for where we are in the game.

I do note that playing Korea with the mod feels like one difficulty level easier than playing Babylon with the mod. (Korea's "boosts" from completing science buildings/wonders in capital don't get fed into AI science buff unlike Babylon's academies) China is going to be the main obstacle to a cultural victory with them having the most culture I need to overcome.
Also the AIs changed their minds again about which of Arts Funding & Science Funding they want:

1. First session: They wanted Arts Funding proposed, but 30 turns later when it was time to vote they voted it down.
2. Second session: They wanted Science Funding proposed. (Denied)
3. Third session: They want Arts Funding proposed. We're still quite a few turns away from when it will convene.

(I think there are side effects to giving AI boosts dealing with which of Arts Funding & Science Funding they want [known in the programming field as action at a distance when a small change in one part of the code base causes an unexpected huge change in the outcome of another part of the code base], but with base game being so boring in this regard [typically 6 out of 7 AI civs in base game want arts funding] its more interesting.)
 
Wow, that is an interesting side effect one I had not considered Joncnunn. The possibility is that if they are flat lined and are relying on the players science yield rate, it could cause them to fluctuate their assessments and even give players some control over what funding proposals they make (not that this is good mind you - just interesting...

EDIT: it depends whether the AI is getting fed leak or doing it for itself. That could easily change within a 30 turn window.
 
Have you had a chance to post your DLL source files yet? I'd like to take a look.
G

Hi ya Gazebo good to talk with you. I've got the engine cover wide open and there are bolts and cables and bits and pieces lying all over the shop floor. I am in the middle of a work in progress re-writing these code bases to teach the AI to guard workers:

CvHomelandAI and CvTacticalAI

I'm also thinking of scrapping the changes and am thinking about trying to turn the guarding into an CvAIOperation instead, but this idea is new to me.

You have experience with moving diplomats so I should go and take a look what you have done.

EDIT: Have you tried this mod, what do you think of the adaptive buffing?
 
My Version 17 game as Korea on Immortal is now complete. Cultural victory in turn 335. (It was delayed by about 20 turns via late Olympics [I had lost control of being able to propose it a few turns before the first time it was possible to do so and it took awhile to regain enough control to propose it]

Highlights are that at no time did anyones income reach absurd levels. My own income peaked out around 500 GPT.
At the end of the game my polices were full Tradition, full Aesthetics, full Exploration, every somewhat useful tenet within Freedom, Commerce opener, and Patronage opener)

Korea is probably the easiest civ to win as with this mod (even in base game it's close between Babylon & Korea when controlled by human) but Korea's tech boosts from completing regular science buildings & national wonders was more than the mod could handle. (The base game AIs can't handle this either)

AI China was again my strongest opponent (I played with random opponents, but the RNG gave me China in both games), they forced AI France into an involuntary OCC before they accepted peace (The French city on a different landmass and kind of useless, kind of like a human trying to avoid coup de grace diplomatic penalty would) and they forced AI Babylon into an involuntary two city challenge on 1 and 2 tile islands (again bad enough cities that those would be the ones a human would let a defeated opponent keep)
They had the strongest culture for me to overcome.

Right after I completed Olympics [this was after I discovered Internet] is when I faith bought two great Musicans. At the time China's relations was hostile so I was escorting them with my Navy with plans to DOW China to have a forced double tour.

But on turn 333, China switched from Hostile to Friendly (probably pretend), but it allowed embassies to be established and free mutual open borders, so the war was canceled, but I did place a naval unit in the tile I wanted my Great Musicans to use to keep it open.
Victory at current pace in 13 turns.

Turn 334: Victory at current pace in 12 turns
Tour #1: now influential with China (100.1%)
Tour #2: (no kill like overkill), Now at 125.7% influence over China.
In fact China & Polynesia were the over civs I wasn't dominant with.
Hit next turn

Turn 335: Cultural Victory complete. (My score was in the Abe Lincoln category

(If we'd reached the second world leader opportunity turn 348, I'd have won diplomatically then)

I think I'll try Polynesia in V17 next (aiming for new cultural victory given their UI)
 
Awesome story, Joncunn. I did a game with Korea on King and found it was so much easier to get science as well. I was going for a diplomatic victory but got stamped out by a rampaging Spain and Portugal (they teamed up). Should of built more military. :-(

Glider1 can you upload v17 again? I want to see if I can recreate the circumstances in which I got a ridiculous amount of gold in. Either it was due to the scenario itself with the close spawns or my mind just wigged out and saw it happen for some reason. Either way eager to test it out again.
 
No probs Poruchiik, here you go:

What map conditions were you playing in your king game?

Joncnunn, what about Korea on deity? There isn't that much difference between immortal and deity except that the AI gets ramped up passive bonuses. It should be fun to try?
 
Back
Top Bottom