Buffed AI for BNW

Sorry Juncnunn, I put the wrong DLL into V16. I have two versions of this mod, one released here and a private one that blends WHowards DLL with this mod. If you would like me to include Whowards code into this mod, I will gladly do that (which would prevent this mistake happening in the future), however I would have to get approval from WHoward himself.

From a software engineering standpoint, integrating with Whowards should be in a separate version to make testing and analysis of changes easier.
(If mixed together with the 16 change, it would be harder to know what differences the intended version 16 changes make as opposed to Whowards.)

Edit: This one works, I've now entered the Classical era.
 
Good point Joncnunn. I'm trying out Whowards DLL because it has a few nice things in it. One of it's options is to allow the fortified unit in the city to attack without leaving the city. That could help the AI.
 
I just installed the v17 of this mod and when I get to the Classical Era, everyone seems to get a ton of gold per turn. My guess is that this is a bug currently.
 
Thanks for letting me know, it will be because of the trade route idea that must not work for a reason I don't understand. I'll roll it back to V15 which we know works because Joncnunn and I have played through an entire game on it.

EDIT: You don't have to start another game, just roll back your game to before trade routes started happening and use V15. For now, I doubt that I will come out with another version for a while, until I can think up a definite improvement that is bullet proof and have had the time to play through.

Sorry bout that.
 
Thanks for letting me know, it will be because of the trade route idea that must not work for a reason I don't understand. I'll roll it back to V15 which we know works because Joncnunn and I have played through an entire game on it.

EDIT: You don't have to start another game, just roll back your game to before trade routes started happening and use V15. For now, I doubt that I will come out with another version for a while, until I can think up a definite improvement that is bullet proof and have had the time to play through.

Sorry bout that.

The name of the mod used is built into the saves in Civ V, and at some point after CD release but still before G&K they added as part of the save process loading the mod that was included, even in the 4000 BC initial save.
At a minimum you'd have to while Civ V wasn't running copy the DLL of V15 into the V17 mod file to do a hot swap. But if your only in classical era it may be better to either start a new game or continue it as is for ten turns to see if the AI was in a golden age.

In my own case, I haven't met anybody yet in V17. I might just play some more turns to see if the same problem occurs for me as Poruchiik reported.

Edit: I'm in Midevil era, Indonesia's income seemed a bit high when I met them (33 GPT in 100 BC), but isn't absurd considering their UA and the possibility they could have made Currency a higher priority than I did. It's no surprise they are also #1 in happiness on a large island map.

Left hand of AI doesn't know what right hand is doing issue: Ottoman AI choose God of the Sea (made sense with 3 Whales in their capital alone) but has refused to connect any except for the first one, which is keeping it from really exploiting their pantheon (and causing them happiness issues as the other AIs have spare luxuries).

I'm going to abandon this one, Ottoman AI (nearest neighbor) took over one of my cities in 540 AD, which is unrecoverable in Civ V at Immortal even if the one taken over was only size 2. But I never saw an AI with absurd GPT. But if the problem reported was trade related, then none of the AIs had formed a trade route with me pre-war.
Ottoman AI correctly built enough Galleys, with the built in human ranged penalty + AI attack bonus.

Based on what's known about AI flavors, if it hadn't been one of the AIs with high naval flavors near me, I'd have won even with the handicaps (most AIs would have sent just one or two galleys and the rest embarked forces). For that matter, the more peaceful AIs wouldn't have attacked me at all.

Also, in the mod it didn't seem to make nearly as big a difference against the AI not having a river (and thus unable to build watermill) as base game particularly with my start having been on a lake and so it was still able to build a garden in the capital.
 
Thanks for that. It is a pity that the AI hurt you so much you had to pull the plug on the game.

Here is the algorithm for V15 (can give the code as well if people want it):

Whenever a cities yield rate needs to be known by the game, this happens:
  • Is the city an AI and is AI global happiness at least zero?
  • YES: Is the requested yield rate one of {science, production, gold}?
  • YES: Get the specific requested yield rate and compare to player
  • Get players total empire wide yield rate for this yield
  • Get players total empire wide population
  • Calculate minimum yield rate threshold BUFF = Player(totalYieldRate/totalPop) * AI(this city pop)
  • Is the AI's actual city yield rate less than BUFF?
  • YES: Reject AI's yield rate and replace with BUFF
  • Repeat through all AI's and all AI's cities each time the game requests a yield rate to be known

EDIT:
So end result is if you pick a low difficulty level but are an experienced player, all AI's will flat line with players yielding, but rarely exceed it. This will appear to give an exciting game, but AI will probably not get enough boost to win endgame (unless an AI goes on a successful domination spree).

If you get the difficulty just right, some AI's will receive BUFF and some AI's might even continue to get a bit of buff in some cities that the AI is mismanaging. But there will be a couple of AI's that are solidly progressing largely on their own terms except for passive buffs built into this mod.

If you pick a high difficulty but are a beginner, AI will rarely get buff and AI will win on own terms except for passive buffs built into this mod already.

BENEFITS:
Even if you harass an AI with an ancient age perma-war stealing it's workers, all that will mean is that you will be more productive relative to that AI, but your yield gains from the perma-war could likely be fed to the other AI's you don't even know are there.

STRATEGY:
Accentuate the differences between your empire population and AI's population. Pure high yielding strategies are less successful. Player needs to peg tech gap more by other means and potentially engage in war/diplomacy to cause other AI to shrink in population. If player chooses a high population low yield strategy, other AI's should be aggressive enough to attack player and be more likely to succeed because of combat buffs and passive buffs built into the mod already. In any case, the AI might get players science yield rate if nothing else.

NOTES:
This mod will break multi-player. This mod get's more difficult the more AI's are in the game (because they all could get players yield). Duel games will be very easy in this mod (just perma-war and cripple AI). This mod and the new Super Power total conversion mod are the first mods I know of that deploy adaptive AI buffing. SP uses a different method to this mod.
 
A couple more V15 strategies come to mind:

1. Research Agreements are somewhat more powerful than in base game.
A. The handicaps themselves will increase the AI's science rate when your own is higher, and since RA is based on last X turns science * multiples that would increase the value.
B. With the mod itself based on ongoing science rate, a completed RA is a way to get tech without it being fed into all the AIs.

2. Some of the Academies will leak. It will leak even more if in the NC city or if you have Observatory or if you've gone Rationalism

3. Blubing won't leak (in V15), so in end game it's a great way to cement a tech lead.

4. Rationalism isn't as super powered in the mod as in base game since that will leak. Still, if one of the AI goes Rationalism and you don't you could be in a world of hurt even without the bonuses (which in this case that AI wouldn't get)

5. Trade route science will leak somewhat less to the AI and somewhat more to the human than in base game.

6. Trade route income itself will sometimes leak to the AI, but you still need trade routes since you'd get crushed even without AI bonuses if you don't have them.

7. A human Golden Age may leak to the AIs while it lasts.

8. The mod has the least impact on a human seeking Cultural victory, especially if you are either playing Brazil going for a super early cultural victory or are attempting the sacred sites gambit.

9. Civ & start based science, gold, and hammer bonuses will leak.
 
Thanks, that does help get some of the factors clearer. Don't understand trade route leak though. It was always off in V15. Trade route yielding is not included in the calculations of what leaks.

EDIT:
It seems players should try to maximise RA's by playing peacefully, but this mod is designed that AI's will be more aggressive towards the player (less likely to be allies). If player keeps up with the arms race to ensure perma-peace and RA's, that should drain players economy because of military upkeep. At least that is the idea.

Tip 10:
Plunder is a weak form of non-leaking yield. Depends whether plunder makes the AI's yield rate drop low enough to trigger leak to the AI.

Question:
How much did RA's contribute to wins on V15?
 
Thanks, that does help get some of the factors clearer. Don't understand trade route leak though. It was always off in V15. Trade route yielding is not included in the calculations of what leaks.

EDIT:
It seems players should try to maximise RA's by playing peacefully, but this mod is designed that AI's will be more aggressive towards the player (less likely to be allies). If player keeps up with the arms race to ensure perma-peace and RA's, that should drain players economy because of military upkeep. At least that is the idea.

Tip 10:
Plunder is a weak form of non-leaking yield. Depends whether plunder makes the AI's yield rate drop low enough to trigger leak to the AI.

Question:
How much did RA's contribute to wins on V15?

Trade routes themselves in base game leak science (and religion) both ways. This mod gives the AI more science, which makes it both more likely they will have a tech the human doesn't while reducing the number of techs the human has that the AI doesn't.

The other mod impact is if you're looking at the total human's gold per turn / science per turn to determine the factor, that would be after the effect of trade routes have been added in. In fact that science bonus from trade routes is before Rationalism opener.

RAs: You won't be able to have as many friends with the mod than in base game so there are fewer possible civs to have RAs with between the increased AI aggression and the hammer leak helping the AIs behind in production build units faster / science leak helping the AIs behind in science keep up with military techs. But each RA you do have will be worth more. (As long as you avoid signing one of the deceptive AIs who DOWs you before it completes)

Tip 11: Internal food cargo routes / Hanging Gardens / Temple of Artemis / Tradition policies / Maritime city states / etc. will have the effect of decreasing the AI's buff. More food equals more population, and with the buff being total yield dived by population ...

Edit: I'm still not seeing any absurd income per turn from the AI in the V17 that was pulled in my new game in Rea era, not even the one with an (AI initiated) active trade route from me. In fact during much of the Classical era, a couple of AIs were losing money every turn. (They'd gone Liberty which does tend to have money problems during Classical)
 
Hi ya Gekko. If you can try this mod out and recommend it to the community patch people, I will gladly give the code and run two versions of this mod. If they don't want the adaptive buff concept, I'll just hand them want ever AI improvements there are. This mod fixes the bug where the AI is too willing to engage in a third party war which I'm sure they would need.

The known weakness this mod has at the moment is for duel games where the player cripples the one AI, and even though the AI get's leaking buff, it won't be enough. If you cripple an AI with larger numbers of other AI's around, the problem is much less pronounced. So the instant ancient age war declaration could be an issue with this mod. Why? Because the AI starts with much lower unit numbers but higher combat buffs.

IMPORTANT NOTE:
I could look into making the AI start with two warriors and an archer? Problem there is that the worker steal option (which can be fun), is likely to be gone (except that you might pick up workers from CS and barbs). I actually like this idea thinking about it now. The AI's potency would increase a lot. You couldn't insta-war as much and the AI's archer and city would really hurt the player's warrior raid. (Best of all would be to teach the AI how to play the start with only the two warriors and a scout....)

Thanks for sticking with V17 Joncnunn :goodjob: I lost confidence in it because I haven't personally played through a whole game on it, but would love to see it in because it will boost the AI a bit more which will help the endgame.

On trade routes, I have personally experienced what you are talking about with the greater diversity between known techs. The thing you won't know is the detail about how total yield is calculated. It is the total player yield summed on a per city basis excluding trade route income. However, in V17, the total yield is summed the same way but INCLUDING trade route income.

On tip 11, yes that is true, but higher population means higher science which will leak to the AI. Also higher population means lower happiness and potentially more risk of war. It depends on how people set up the game I guess. Also, so long as the player has a high pop, that increases the risk of leak to the AI because it is difficult not to be productive with a high population, unless the pop is diverted to the unaffected yields culture, tourism or faith (or diverted to unemployment?)

Tip 12: I think this mod initially favours AI's that have a high food start. They could get benefits of leak. However, they also hit the happiness cap sooner and immediately loose the leak buff. At the end of the day what this means is that in the ancient age, civs that are high population and aggressive are the biggest risk, until they hit the happiness cap. Civs that start in low food areas will be less of a threat because they won't get the full benefit of the leak.

EDIT:
Note: It is easy to make the mistake of thinking that domination does not work in this mod because players that own half the map will be leaking so much to the AI that domination can't work. BUT this is not true. The leak is the ratio of yield/pop which is somewhat independent of the players empire size.

I'm not 100% sure but I think there is a quirk in this adaptive buff concept, that if you play on prince as an immortal player, you will initially feed so much leak to the AI, that they will more quickly build an army and attack (ancient age rush more likely). If they fail, the game will be super easy. If they take a city, even prince could be a challenge....However prince players playing on prince will not feed as much leak to the AI and the game will normalise.
 
On trade routes, I have personally experienced what you are talking about with the greater diversity between known techs. The thing you won't know is the detail about how total yield is calculated. It is the total player yield summed on a per city basis excluding trade route income. However, in V17, the total yield is summed the same way but INCLUDING trade route income.

On tip 11, yes that is true, but higher population means higher science which will leak to the AI. Also higher population means lower happiness and potentially more risk of war. It depends on how people set up the game I guess. Also, so long as the player has a high pop, that increases the risk of leak to the AI because it is difficult not to be productive with a high population, unless the pop is diverted to the unaffected yields culture, tourism or faith (or diverted to unemployment?)

Hum, well I thought you would simply have grabbed the total values that are displayed to the interface on the man screen.
Going at a the city by city level even if you also include trade routes though would skip Rationalism openers science bonus of 10%, which doesn't show up on the per city screen but instead is shown on the top section as first total from all cities, then trade route science, and then the science bonus from happiness for the grand total in science.

Obviously a new citizen is going to produce something, but it will sometimes be the case that old yield / old population was actually more than (old yield + 3) / (old population + 1)
Two factors are at work though, the bigger the yield is, the more the new citizen would have to contribute just to keep the average. And the one countering is is the more population there already is, the less yield the new citizen has to contribute to keep the average.
Science is the easiest to keep up with every citizen always contributing at least 1 beaker. OTOH, until the player has Secularism (or is Korea), chances are the human was already getting all science from specialists possible and was also already working all tiles with science so it's just that base yield * city multiplers that increased.

I've not seen anything indicating that the AI considers either its happiness or the humans in war decisions.

A human suffering from low happiness would be less likely to want an immediate war unless a neighbor has a massive happiness wonder such as Forbidden Palace.
 
The calculation of yield uses CvCity::getYieldRateTimes100().

Tell me what you think I should do and I will try it.

EDIT: The reason I use that function for both player and AI is I want to be consistent so that AI yield is being compared with the same calculation of player yield (apples compared to apples). It was a conservative approach to ensure minimum unintended side effects.

Sorry for not making that clear in above algorithm.
 
[to_xp]Gekko;13341504 said:
Splendid, I'll point them this way then :D . this thread might be relevant to you: http://forums.civfanatics.com/showthread.php?t=528319

Hi Gekko, I just realise that this mod cannot be used anywhere but here because it breaks multi-player. It is only useful to enhance the single player experience.

EDIT: Thinking about a multi-player version of the adaptive buff algorithm, it could be made multi-player compatible, if the adaptive algorithm were adjusted to calculate the total yield rate per population of all human players in the game. But suspect it would not work well because it could be gamed in ways that are not possible in single-player.
 
The calculation of yield uses CvCity::getYieldRateTimes100().

Tell me what you think I should do and I will try it.

EDIT: The reason I use that function for both player and AI is I want to be consistent so that AI yield is being compared with the same calculation of player yield (apples compared to apples). It was a conservative approach to ensure minimum unintended side effects.

Sorry for not making that clear in above algorithm.

If that's done for the human side as well and then the yield rate is averaged, that's not actually the human empires yield per person, but would instead be the average human city's yield rate.
e.g. Say early on the Human's capital was size 6 before they founded any city, the moment they do so the new city is size 1 but will have very little yield. Averaging the city yield rate would basically cut the average yield rate almost in half. While instead if the two cities yields had been combined and then divided by the combined population the average yield rate would go down some but not more than 16%.

Also, I'm now only a few turns from Rean era in my V17 game, China has been the gold per turn leader all game long but with none of the other AIs near them in income I think this really is China having made a lot of effort into gold sources and not from the buff. (In fact at the moment some of the AIs are running deficits)
I am thinking that the most noticeable difference between V15 & V17 would be if the human is playing a civ with a direct or indirect trade route income boost (such as Morocco, Venice, Indonesia, Portugal),

Edit: Tracking net income in V 17 of before and after trade routes:

Before:
24 103 12 23 1 14 20
Form first external trade route:
33 103 12 23 1 14 20
Next turn:
32 116 16 22 0 19 24

A few turns later before:
31 115 16 18 (-4) 18 26
Form second external trade route:
35 115 16 18 (-4) 18 26
Next turn [I also founded my fourth city this turn]:
34 104 16 18 (-4) 18 25

Science status when entering Rean:
Spain: Behind 7 techs
Babylon: Behind 2 techs
China: Ahead 2 techs & behind 4 techs
[no other civs were within trade route range]
It does seem I need to pick a more normal civ (one without a science advantage) next. Korea's boosts when completing science building / wonder in the capital bypasses the AI boosts. (By contrast Korea's extra science from all specialists and Babylon's extra academies both get fed into the AI)

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.
 
Hi ya Gazebo - would be glad to hand any code over because that means I get to use the community patch as well as supporting this one. I'll start posting the code for this mod on the OP with the mod itself. This mod extends the shelf life of this game by heaps because the player gets a competitive game and there is still motivation to improve the AI as well (because the better the AI is, the less it will get the adaptive buff).

Thanks Joncnunn for testing V17. If you think that V17 has given you a good challenge, I'll just update this mod to that when you have finished (take your time no hurry). I'll have to play through on different difficulties to see the effect of the trade route change in case it does something weird at low difficulties.

Hey Gekko - a multiplayer version of this would be possible but weird? I am in the middle of trying to teach the pesky AI warriors to guard their damn worker. In single player it doesn't matter if the player steals an AI worker because the other AIs in the game might benefit from the player doing that depending. But in multi-player what will happen is that every player will try to steal workers from their AI neighbour, and suddenly you have to got multiple crippled AIs. So basically the worker steal loophole has to be closed at the start of the game.

Joncnunn, here is a quick post of the actual code I think you will be interested in:
Spoiler :

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

	if (iTotalPlayerPopulation > 0)
		iBuffedYield = (iTotalPlayerYield / iTotalPlayerPopulation) * iAICityPopulation;

	if (iBuffedYield > iAICityYield) 
		return iBuffedYield; 

	return iAICityYield;

EDIT: I updated the variable names to make it more readable. It is a simple technique that has a big effect on the competitiveness of the AI. The "false" means trade routes get included in the calculation.
 
Back
Top Bottom