Help Modifying Computer's Happiness Bonus

EndoConvert

Warlord
Joined
Dec 17, 2010
Messages
297
I don't mind most of the computer bonuses on the higher difficulties like Deity and Immortal---after all, since the AI is a tactical idiot, it has to compensate somehow---but I don't like the way the way the computer can grow enormous cities on the crappiest terrain (arctic and desert) or on one-tile islands; it's ridiculous and unrealistic.

I have no experience with modding Civ5, but I was thinking that I could modify the computer's happiness bonus on those difficulties to try to get the computer to not exhibit that behavior. Can someone point me out the file and value I would have to modify if I want to change the computer's happiness bonus and nothing else? Thanks in advance.

Also, if anybody else has any comments or suggestions for how to get the computer to not have such an obsession with settling and growing large cities on tiny islands or cold, desolate terrain, that would be nice too.
 
The AI civs play at Chieftain level regardless of what level the human is using. Assuming you aren't playing at Chieftain yourself, if you want them to have less happiness this can be done by modifying one or more of the HappinessDefault (12), ExtraHappinessPerLuxury (1), NumCitiesUnhappinessMod (60), and PopulationUnhappinessMod (60) values for that difficulty.

For example, to give them Prince-level happiness bonuses while not changing anything else, you could make an XML mod such as this:
Code:
<GameData>
	<HandicapInfos>
		<Update>
			<Set HappinessDefault="9"/>
			<Where Type="HANDICAP_CHIEFTAIN" />
		</Update>
		<Update>
			<Set ExtraHappinessPerLuxury="0"/>
			<Where Type="HANDICAP_CHIEFTAIN" />
		</Update>
		<Update>
			<Set NumCitiesUnhappinessMod="100"/>
			<Where Type="HANDICAP_CHIEFTAIN" />
		</Update>
		<Update>
			<Set PopulationUnhappinessMod="100"/>
			<Where Type="HANDICAP_CHIEFTAIN" />
		</Update>
	</HandicapInfos>
</GameData>
Kael's Modders Guide should give you enough info on how to create the mod using the SDK tools. Just remember that such a mod will also affect you if you decide to start a game on Chieftain. ;)
 
To clarify what I want: As a human player, if I settle cities in snow, tundra, desert, or 1-tile islands, they barely grow in comparison to my cities in, for example, grasslands. Deity or immortal AIs, however, seem to grow just fine in terrible terrain. I want to somehow either disincentive them from settling in bad terrain, or make it so that they are hit by the same negative modifiers for bad terrain that human players are hit with, and I want to do this by modifying the game as little as possible.

The AI civs play at Chieftain level regardless of what level the human is using.

I don't understand what you mean by this statement. At higher difficulty levels, the AI cities grow really fast without taking crippling unhappiness penalties, so I assumed the AI must have a lot more happiness at higher difficulty levels, or how are they growing so much faster than at lower difficulty levels? (Well, I guess they could be getting free food?) Clarification, please?

Kael's Modders Guide should give you enough info on how to create the mod using the SDK tools. Just remember that such a mod will also affect you if you decide to start a game on Chieftain. ;)

Thanks, but can't I just edit some particular XML file without going through the process of actually creating a mod? I just need to know which file to edit.
 
I don't understand what you mean by this statement.

If a human player plays on Chieftain difficulty, then he has a lot more happiness than normal. Luxuries generate 6 happiness instead of 5, you start with 12 happiness instead of 9, and cities only generate 1.2 + 0.6/pop unhappiness instead of the usual 2+1/pop.

What he's saying is that there's a bug where, for whatever reason, AIs will sometimes be stuck on Chieftain regardless of what setting YOU use (which is not how it's supposed to work). So while YOU are playing on Prince, King, et cetera, and seeing those penalties, the AI is only paying 60% of the normal unhappiness and gaining extra happiness.

So, you can basically remove Chieftain and set its values to those of Prince, like he suggested. Instead, I just set the default handicap to Prince, and that seemed to work. (I was trying to get the default at the Advanced Setup screen to be Prince, but that STILL doesn't work.) In my games the AI is definitely not having a huge happiness surplus, although my mod tends to reduce happiness in general.

AIs generally have a large happiness surplus, but it's not just because of the handicap. There are two other reasons for this:
1> The AI rarely expands as quickly as a human. Sure, you laugh at the AI for missing out on that great city location you just grabbed, but in the meantime he's got fewer drains on his happiness and so is entering Golden Ages more often. More GAs means a LOT more cash, and more production.
2> Resource trades. When an AI hooks up a second unit of a luxury, he looks around to see who he can trade it with. Since this is happening during the AI's turn, the first person that he'll check? Another AI, of course. So the AIs tend to have a LARGE number of luxury trades going back and forth. (You see the same thing with Research Agreements.)
The AI also isn't as picky about "even" trades, or insisting on resource-for-resource trades. So one AI might offer a resource for some gold, and then a few turns later get a similar offer in reverse. Since, as mentioned above, the AI is more likely to be in a Golden Age and so will have more money on hand, this is actually very common.

As for why the AI's little island cities grow so quickly? It's because island cities grow quickly; once you get a Lighthouse, all water tiles generate 2 food; add in any fish and ally yourself with a Maritime, and you're set. You could do the same. Land tiles have all kinds of other bonuses, sure, but it's a bit harder to get them to that 2+ food self-sufficiency; your land cities will be working a lot of tiles that don't reach that threshold. (Plains with trading posts, hills with mines.) This slows down your growth tremendously, although you obviously get other benefits instead.

Thanks, but can't I just edit some particular XML file without going through the process of actually creating a mod?

No.

Well, you probably COULD, but it'd be a really bad idea. Editing the core game's XML files is just a really bad way to do things in general; your changes will get destroyed any time the game auto-patches, and your changes could easily conflict with a mod. And if you do it badly, then you could easily cause a game crash without having any way to easily fix it.
 
If a human player plays on Chieftain difficulty, then he has a lot more happiness than normal. Luxuries generate 6 happiness instead of 5, you start with 12 happiness instead of 9, and cities only generate 1.2 + 0.6/pop unhappiness instead of the usual 2+1/pop.

What he's saying is that there's a bug where, for whatever reason, AIs will sometimes be stuck on Chieftain regardless of what setting YOU use (which is not how it's supposed to work). So while YOU are playing on Prince, King, et cetera, and seeing those penalties, the AI is only paying 60% of the normal unhappiness and gaining extra happiness.

So, you can basically remove Chieftain and set its values to those of Prince, like he suggested. Instead, I just set the default handicap to Prince, and that seemed to work. (I was trying to get the default at the Advanced Setup screen to be Prince, but that STILL doesn't work.) In my games the AI is definitely not having a huge happiness surplus, although my mod tends to reduce happiness in general.

If the computer's happiness is always at Chieftain regardless of actual difficulty level, then what value is being changed that causes the computer to grow faster at Deity than at Immortal, faster at Immortal than at Emperor, etc.?
 
what value is being changed that causes the computer to grow faster at Deity than at Immortal, faster at Immortal than at Emperor, etc.?

If you actually go into the HandicapInfos table, you'll see that there are two sets of multipliers: those that apply to the player (generally dealing with things like happiness) and those that apply to the AIs (dealing with growth rates, upgrade costs, maintenance costs, etc.). You can tell which are which because the latter category all start with the letters "AI". (Convenient, huh?) So when you play on higher difficulties, the AIs are getting the Chieftain happiness boosts AND the Deity AI boosts. They SHOULD be getting the Deity AI boosts, but the Chieftain part is a bug; at best, they should be getting the Prince boosts (since that's the baseline), and realistically should be getting the same values the player has.

But the numbers involved for the AI multipliers just aren't that large. x1.1, x1.2, x1.3, that sort of thing. You also get those kinds of multipliers just for playing on a larger-than-normal map size; it's an advantage, yes, but it doesn't have a very drastic effect on the outcomes. It's not nearly as damaging as, say, x0.6 unhappiness in all cities, which can make AIs basically stay in a perma-Golden Age, hence the earlier point about balance.
 
What he's saying is that there's a bug where, for whatever reason, AIs will sometimes be stuck on Chieftain regardless of what setting YOU use (which is not how it's supposed to work).

Only "sometimes", or always?

I searched the full bug list thread at http://forums.civfanatics.com/showthread.php?t=381414 for the word "happiness", "happy", "unhappiness", "unhappy", and variants and cannot find any such bug listed. Is there a thread for this bug in the bugs forum? If not, such a thread needs to be created.

Edit: Hmm, never mind. After some more searching, I found the threads

-"Sick of AI happiness bonus?"
-"AI Equalizer"
-"How Does AI Support So Many Cities?"
-"WTB - Facts on AI cheating"
-"Handicaps: Not working as advertised"
-"seriously why can the ai ics so hard?"
-"[MAYBE A BUG][.221] Do happiness rules apply to the AI ?"

which, some more tangentially than others, talks about this, but it's not one of the "confirmed bugs" in the above bug list thread.
 
Only "sometimes", or always?

Always, unless you use a mod that fixes it, at which point it becomes Never. Hence the "sometimes".

You see, it's not ACTUALLY a "bug", per se. It's right there in GlobalDefines:
Code:
<Row Name="STANDARD_HANDICAP">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="MULTIPLAYER_HANDICAP">
  <Key>HANDICAP_PRINCE</Key> 
  <Table>HandicapInfos</Table> 
  </Row>
<Row Name="STANDARD_HANDICAP_QUICK">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="BARBARIAN_HANDICAP">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="MINOR_CIV_HANDICAP">
  <Key>HANDICAP_PRINCE</Key> 
  <Table>HandicapInfos</Table> 
</Row>

See? Those aren't setting what the value for YOU is when you start up a new game (although that's Chieftain, too); they're setting what the handicaps are for the AIs. You'll note that city-states default to Prince, and multiplayer games as well, while everyone else defaults to Chieftain. (Barbarians are on chieftain but since they have no cities, no unhappiness, no policies, etc. it doesn't matter for them.)

So all you need to do is change those values and you're done. Set them to Prince, and the AI will lose the massive happiness advantage it has over the humans. You can confirm this in-game in FireTuner by doing a call to Players:GetHandicapType; my mod does this, and I've confirmed that all AIs are playing on Prince (3) instead of Chieftain (1). (Prince and above are all identical for the Happiness part. It's only below Prince that you get a boost.)

The point is, it's not ACTUALLY a bug. It's just that the value set in the game's database isn't really a good value for a default.
 
It's right there in GlobalDefines:
Code:
<Row Name="STANDARD_HANDICAP">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="MULTIPLAYER_HANDICAP">
  <Key>HANDICAP_PRINCE</Key> 
  <Table>HandicapInfos</Table> 
  </Row>
<Row Name="STANDARD_HANDICAP_QUICK">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>

Hmm, what does the setting under STANDARD_HANDICAP_QUICK affect anyway? From the name, one would naturally guess that it affects games with game pace set to Quick, but I've just spent some time testing the modification of those settings and examining the resulting effects on happiness, and it appears that the setting under STANDARD_HANDICAP affects both Standard-pace and Quick-pace games, so I'm at a loss for what the setting under STANDARD_HANDICAP_QUICK affects.
 
They SHOULD be getting the Deity AI boosts, but the Chieftain part is a bug; at best, they should be getting the Prince boosts (since that's the baseline), and realistically should be getting the same values the player has.
I don't think it's a bug, because the civ5 AI is very bad.
The AI heavy relies on bonuses to be competitive.

I've played several games with the AI handicap_PRINCE change.
See the examples.
Ramesses had adopted Monarchy + Theocracy + Freedom, just like I did (in most games) in the other example.
Choosing other policies means you'll be fighting unhappiness until it's game over, a very bad and unfun game design.

Spoiler :




 
I've played several games with the AI handicap_PRINCE change.

And I've played hundreds. Because I only EVER play with my own content mods, and this is built into all of them. So this isn't idle speculation.

Yes, the vanilla AI will have problems with happiness if this is the only change you make. Happiness is one of the few areas of the game where the AI overrides the Flavor values based on its current needs, but the problem is that when the AI decides it wants/needs more Happiness, it simply doesn't have many things it CAN do to add more.

This doesn't take much to fix. For instance, in my mod I changed the Temple from +3 culture to +1 happiness and +1 culture. I then removed it from the culture building chain, making the Opera House depend on the Monument directly and making the Temple be buildable as soon as you unlock its tech. That +1 in each city makes a huge difference in whether an AI can stay above zero when it needs to, and that's what the game cares about; if an AI decides that it wants/needs more happiness, it'll look to see what happiness things it can build. If its only option is the Colosseum, and it's already built that in most cities, then you're out of luck. But if it's got a handful of other options, then the AI will be MUCH more capable of adapting to the situation.

You see, in my mod I raised the base city unhappiness from 2 to 4, but then added a whole slew of buildings that add +1 happiness. Monastery? +1 happy, but two less culture. Mint? +1 happy, but one less gold per deposit. Garden? +1 happy, plus its previous effects. Aqueduct? +1 happy, and less food storage, which got shifted to a couple later buildings, the Sewer System and Recycling center... both of which also give +1 happiness.
In practice, the AI has proven to be more capable of keeping itself above zero in this sort of system than in the vanilla, because if it decides that it needs a little more happiness, it has multiple options. So it no longer needs the Chieftain handicap to stay competitive.
 
I don't think it's a bug, because the civ5 AI is very bad.
The AI heavy relies on bonuses to be competitive.

It is a bug, though, because the manual and Civilopedia claims that humans and AIs are on equal footing at Prince, with both only getting the Prince settings, but the AI is in fact getting the Chieftain bonus, when it should actually be set to the Prince settings.
 
What results did you get from setting it on Warlord instead of Chieftain?

Is that still too much happiness or what?
 
What results did you get from setting it on Warlord instead of Chieftain?

Never tried that. As EndoConvert points out, it's SUPPPOSED to be on Prince, according to the manual, so I set it to that and never touched it again. All of the other happiness balancing things I mentioned were done after that point, to make the AI not cripple itself by doing what it was supposed to be doing already.

I've done a lot of that in my own mods, changing various balance points so that the behavior the AI already follows more closely matches the optimum strategy. And it's worked very well, IMO.
 
You see, it's not ACTUALLY a "bug", per se. It's right there in GlobalDefines:
Code:
<Row Name="STANDARD_HANDICAP">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="MULTIPLAYER_HANDICAP">
  <Key>HANDICAP_PRINCE</Key> 
  <Table>HandicapInfos</Table> 
  </Row>
<Row Name="STANDARD_HANDICAP_QUICK">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="BARBARIAN_HANDICAP">
  <Key>HANDICAP_CHIEFTAIN</Key> 
  <Table>HandicapInfos</Table> 
</Row>
<Row Name="MINOR_CIV_HANDICAP">
  <Key>HANDICAP_PRINCE</Key> 
  <Table>HandicapInfos</Table> 
</Row>
Sorry for the necro :)

Anyway, are you sure those are the ones to change? I think what you actually want is in GlobalAIDefines.xml (all the way at the end):
Code:
	<PostDefines>
		<Row Name="AI_HANDICAP">
			<Key>HANDICAP_CHIEFTAIN</Key>
			<Table>HandicapInfos</Table>
		</Row>
	</PostDefines>
Well, this is what I changed and it seems to work so maybe doing either will do the trick?
 
It's a combination. Yes, you need to change the AI_HANDICAP value, but that only affects major AI civs, not the city-states (the MINOR_HANDICAP) or barbarians.

Those others that I mentioned (three months ago) are the default handicaps for the player. So yes, they wouldn't really apply to this discussion.
 
Back
Top Bottom