Offensive Drafting

I feel that the values that this code generates for drafting are simply too low, and worse, they are completely detached of the quality of the drafted unit and are pretty much detached of the military situation ( losing cities in war will make the AI more eager to go beauro than nationhood :crazyeye: ). This could definitely use a more elegant code...
 
I feel that the values that this code generates for drafting are simply too low, and worse, they are completely detached of the quality of the drafted unit and are pretty much detached of the military situation ( losing cities in war will make the AI more eager to go beauro than nationhood :crazyeye: ). This could definitely use a more elegant code...

I think the other problem here though is that 2-3 turns of anarchy to draft when it finally realizes it has a problem might be too little too late in the face of a human player. It's one of those "You can either watch the house burn to the ground or you can attack it with your garden hose, but first you need to be aware the house is on fire."
 
Thank you for all of the information Jdog and especially thank you for making it fairly easily readable. I reformatted it a bit so that it is even more readable for me and this makes it a bit easier for me to see the reasoning behind the chosen values. Some are due to the cost of the civic and others seem related to the various effects of the civics.

The reason that nationhood isn’t chosen can be due to undervaluing of the nationhood civic but can just as easily be the result of overvaluing of just one or two of the other civics. So we’ll have to look at the whole picture.

I think it’s important to understand the unit in which this value is being counted, otherwise any discussion about relative valuation between the civics is useless. Seeing that various elements among which the maintenance cost of the civics can easily be counted in gold, this allows us a basic measurement unit to compare the civics. We should try to translate all of the benefits of the civics back into gold. That’s pretty hard for some benefits but at least we’ll have some basis for valuing elements of the civics.

Vassalage value

Peace: 5/3 + Pop/20 (value for reduction in military upkeep cost) + 10 * #cities*relative warmongerpercent (value of experience bonus) - cost using vassalage

War or planning war: 5/3 + Pop/20 (value for reduction in military upkeep cost) + 16 * #cities*relative warmongerpercent (value of experience bonus) - cost using vassalage

Relative warmongerpercent = iWarMongerPercent /100 , a value between 0.5 and 1.66

Some comments on the valuation.

Spoiler :
Comment1: the reduction in upkeep cost for the AI is actually 5/2 + Pop/20 not 5/3 + Pop/20. This valuation is very accurate for the noble level benefits of the reduction in unit upkeep cost and the AI plays at noble level bonuses. It of course doesn’t take into account the benefits of the level that the human set but that true for every aspect of these calculations.

Comment2: The value of the experience bonus per city is equal to about 10 gold per turn per city at peace time and 16 gold per turn per city at war time! Wow, that’s a lot! Far too much in my opinion and actually the difference between war and peace is a bit small in my opinion. A more reasonable valuation would be related to the hammer production of the entire civilisation and the percentage of those hammers invested in military units.

Say, the experience bonus adds 40% to the value of the units constructed. Say furthermore that 20% of hammers are invested in military units at peace time and 50% of hammers are invested in military units at war time. Say a hammer is worth 1.5 gold (using the 10:6:4 valuation of food:hammers:commerce that jdog posted earlier)

Then the bonus due to the experience bonus would be:
Peace: 0.4*0.2* 1.5 * total production = 0.12 * total production

War or planning war: 0.4*0.5*1.5* total production = 0.3 * total production

Comment 3: The AI plays at noble level, so the cost of using the civic is actually 0.8 times the value used now (where that 0.8 is from xml-files)


Bureaucracy value

150 + 1.25 * hammer yield capital + 1.25 * commerce yield capital – cost using bureaucracy

Some comments on the valuation.

Spoiler :
Comment 1: I can’t really understand the 150, but there is of course a hidden benefit to having a supercity independent of the actual commerce yield and hammer yield of the super city. For instance, the fact that one of your cities has a super hammer output not only adds those hammers but also allows you to win wonder races. The fact that one of your cities has a super commerce yield not only adds those commerce points but also allows you to get the most of that by getting the best commerce multipliers in that city. However, valuing that hidden bonus at a value of 150 gold per turn? That’s a bit much. Wouldn’t something in the range of 50-75 be more reasonable?

Comment 2: The variable part of the bonus might be valued a bit higher. A hammer is worth about 1.5 commerce (using the 10:6:4 valuation Jdog posted earlier) and the commerce bonus is still subject to all the gold and science bonuses in the capital so
1.5 * hammer yield capital + commerce yield capital * average commerce multipliers in city.

Comment 3: The AI plays at noble level, so the cost of using the civic is actually 0.8 times the value used now (where that 0.8 is from xml-files)


Free Speech

7/3 * # cities * Cultural Victory factor (value for the culture effect of the civic) + 8 * # cities * average commerce multiplier + 4 * # towns * average commerce multiplier (value for the town effect of the civic) - cost using free speech

Cultural Victory factor is a value of 2 or 4.
Average commerce multiplier is a value between 1 and 2 depending on the number of gold/science multiplier buildings.

Some comments on the valuation.

Spoiler :
Comment 1: The value for the town commerce bonus that this civic grants seems too high. It adds 4 per town while the civic only adds 2 commerce per town. Seems to be an overvaluation by a factor of 2.

Comment 2: There is an additional bonus of 8 per city (are you sure it’s 8, isn’t it 4?). There should be an additional bonus for the cottages that might grow into towns later or still need to be constructed, but 8 per city seems rather high to me. It assumes 4 non-town tiles per city are actually giving a bonus as if they were towns. If we were to assume 1.5 per city, then that’s more than enough, so I’d go for

3* # cities * average commerce multiplier + 2 * # towns * average commerce multiplier

as the value of the effect of the commerce bonus on towns.

Comment 3: The basic value of the doubling of commerce is set at 2 1/3 per city. I find this very hard to value. The value is doubled or quadrupled in case of a cultural victory.

Comment 4: The AI plays at noble level, so the cost of using the civic is actually 0.8 times the value used now (where that 0.8 is from xml-files).


Nationhood

Peace: 1.5 * #cities + 12 (value of drafting) + ~0.55 * #cities (value of esp bonus) + 6 * #barracks (value of happiness bonus)

War or planning war: 3 * #cities + 60 (value of drafting) + ~0.55 * #cities (value of esp bonus) + 6 * #barracks (value of happiness bonus)

Some comments on the valuation.

Spoiler :
Comment 1: The value of the happiness bonus of barracks is about 3 gold per happiness point. Seems ok. It’s hard to value happiness in gold.

Comment 2: I can’t say a lot about the valuation of the esp bonus. The AI just doesn’t do the espionage economy and doesn’t use espionage points very well so what can I say about this value. The 0.55 is just the average of the various multipliers that Jdog mentioned.

Comment 3: The drafting value should be calculated very different. I think it’s ok, to set it at 0 when at peace and not planning a war. A human player may use it at peace, but will typically only do so to prepare for war. I want the AI to value drafting when:

-it has lost lots of power since start of the war

+Value = (power start of war – power now)/power start of war * #cities * 20 * (1 or 2 depending on whether enemy capital on same land mass or not)
(example: AI loses 10% of power, 10 cities, enemy on same land mass: 0.1*10*20*2=40)

-it is fighting or going to fight strong opponents

+Value = (1.2* power enemies – power allies)/power allies * #cities * 2 * (1 or 2 depending on whether enemy capital on same land mass or not)
(example: enemies are 50% stronger than allies, 10 cities, enemy on same land mass: 1.2*1.5*20*2=72)

-it is losing cities since the start of the war

+Value = (#cities lost - #cities conquered) * #cities * 2 * (1 or 2 depending on whether enemy capital on same land mass or not)
(example: AI loses 2 cities conquers none, 10 cities, enemy on same land mass: 2*10*2*2=80)

The three above mentioned valuations shouldn’t be allowed to be negative. I don’t know if the valuations are correct. It’s mainly the idea.

The AI shouldn’t switch out of nationhood due to war success when it switched into the civic to get that war success. And with the above value modifiers, that could happen. So I think, the AI should just be forbidden to do this.
 
It would not be better to use the war sucess variable too in the drafting when losing ( power or cities ), Roland? As you know, the AI pretty much puts all non garrison units in a single SoD and marches on. Losing that SoD will probably be a better indicator than the balance between lost and won cities ( especially if you weight a 20 pop city in the same way than one of those weedy AI tundra cities ). Same for the power, especially if we are talking of the gazilion units monty....
 
I think any changes would probably work best if they factor in the AI's power relative to who it's fighting, and also who declared on who, if a powerful civ declares on a weaker one then there might not be a real need to switch to nationhood?

I think that a AI who get's declared on and is weaker, than the person declaring should really be looking to make a early switch, were as someone powerful should maybe only switch if preparing a big war vs someone else also powerful or if the war is not going all that well
 
It would not be better to use the war sucess variable too in the drafting when losing ( power or cities ), Roland? As you know, the AI pretty much puts all non garrison units in a single SoD and marches on. Losing that SoD will probably be a better indicator than the balance between lost and won cities ( especially if you weight a 20 pop city in the same way than one of those weedy AI tundra cities ). Same for the power, especially if we are talking of the gazilion units monty....

The war success variable... I've heard about it but I don't know exactly how it is calculated. One of the motivations that I suggested for the AI to switch to nationhood was when the AI lost a fraction of its power. Losing a SOD is typically very visible in the power graph and thus would result in this value to become significant. Maybe the war success variable could work in a similar way and I'm reinventing the wheel. I'll spoiler the relevant part of my post so that we can see if we're talking about the same thing.

Spoiler :
I want the AI to value drafting when:

-it has lost lots of power since start of the war

+Value = (power start of war – power now)/power start of war * #cities * 20 * (1 or 2 depending on whether enemy capital on same land mass or not)
(example: AI loses 10% of power, 10 cities, enemy on same land mass: 0.1*10*20*2=40)


I think any changes would probably work best if they factor in the AI's power relative to who it's fighting, and also who declared on who, if a powerful civ declares on a weaker one then there might not be a real need to switch to nationhood?

I think that a AI who get's declared on and is weaker, than the person declaring should really be looking to make a early switch, were as someone powerful should maybe only switch if preparing a big war vs someone else also powerful or if the war is not going all that well

I think that's about the same as what I suggested in my suggestions for the valuation of the drafting part of the nationhood civic. So I guess we agree. :) I tried to put these ideas into formulas.
 
Roland -

Thank you for going through things so carefully, we came to several very similar conclusions.

Vassalage:

I agree that the experience bonus granted here is over-valued, I think someone balancing AI civic usage at Firaxis probably pumped up the values to compete with the also inflated value of Free Speech ... I like the war-monger weighting here though, as it assumes that aggressive civs will eventually get into war and has them favoring Vassalage as a kind of military offensive civic. While it's true that most military units are built when the AI is planning or engaged in war, leaders like Montezuma and Ragnar are going to declare sooner or later anyway so I wouldn't want them to waste anarchy to change civics when they hit their brief peace windows. I think if we get it right, in many circumstances the war mongers will hold on to Vassalage when they're large, successful empires.

Bureaucracy:

I was also puzzled by the large constant factor (150) and how the hammer and commerce parts were considered equal and missing the scaling found in other sections of the code.

Free Speech:

It is hard to know what the right value for the cultural boost is. I think Firaxis did well with having civs going for Cultural Victory basically always run this civic, it halves their time to victory basically.

The town part is also strangely set up, just as you say. I am sure that it's 8*#cities and 4*#towns though, since the code breaks down as:

Code:
iTempValue += (average commerce multiplier) * 2 * (#towns + #cities* 2))) / 100;
iTempValue *= 2;

The 2*2*2*#cities part is definitely over-valuing in my book, its true that there may be villages etc which will grow into towns in a while, but there is no benefit from a village for being in Free Speech now. It's also not like the AI actually puts down more cottages after switching to Free Speech to eventually get the +2 bonus from them after they turn into towns.

Nationhood:

I particularly like your proposal about multiplying the value of drafting by the relative power of enemies the AI is facing. Calculating the power of enemies is easy, but allies is a little more nebulous. Here's how I'm thinking of calculating what I'm calling iEnemyPowerPercent (enemy power as a percentage of our power):

Code:
iEnemyPower = 0;

for each enemy team :
      if( enemy has cities in our main area )
            iEnemyPower += (100*enemy team power)/(num wars enemy is in)
      else
            iEnemyPower += (66*enemy team power)/(num wars enemy is in)

iEnemyPowerPercent = iEnemyPower / (our power including vassals)

.

When an AI player is considering declaring war on another civ, the valuation would work basically the same by using the future enemy's "defensive" power (power of all those we will be at war with after declaring on them, including vassals and pacts). I was thinking of boosting iEnemyPowerPercent by 20% in this war planning state, an intentional over valuation of the future enemy's power so that an AI preparing war with an equal adversary will more strongly value the ability to draft going into such a tough war.
 
Roland -

Thank you for going through things so carefully, we came to several very similar conclusions.

Thank you. :) I'm very glad to hear that as it means that we're more likely to be 'right'.

Vassalage:

I agree that the experience bonus granted here is over-valued, I think someone balancing AI civic usage at Firaxis probably pumped up the values to compete with the also inflated value of Free Speech

Quite likely. But it makes it hard to compare things if everything get inflated by seemingly arbitrary factors. Still it's good to understand the original programmers intentions.

I like the war-monger weighting here though, as it assumes that aggressive civs will eventually get into war and has them favoring Vassalage as a kind of military offensive civic.

Me too. I just didn't mention it explicitly. It should definitely be a factor.

Free Speech:

It is hard to know what the right value for the cultural boost is. I think Firaxis did well with having civs going for Cultural Victory basically always run this civic, it halves their time to victory basically.

Agreed.

The town part is also strangely set up, just as you say. I am sure that it's 8*#cities and 4*#towns though, since the code breaks down as:

I misread when trying to look at the code that you posted. I'm not very familiar with it. I shouldn't have doubted you.

The 2*2*2*#cities part is definitely over-valuing in my book ...

Agreed.

Nationhood:

I particularly like your proposal about multiplying the value of drafting by the relative power of enemies the AI is facing. Calculating the power of enemies is easy, but allies is a little more nebulous.

I wonder why allies is harder, but I guess it's a coding thing. Or do you mean that it might not be a good idea?

Here's how I'm thinking of calculating what I'm calling iEnemyPowerPercent (enemy power as a percentage of our power):

Pseudo code looks good. However, if we're but one small nation in a huge alliance, we might overestimate the trouble we're in (the nebulous allies factor).
The allies factor is of course not an issue in the war planning phase as allies usually join later after the war has already started so maybe it's ok this way. We're contemplating whether nationhood is a good choice in the war planning phase.

Permanent allies should be counted but I guess that works similar to vassals.

When an AI player is considering declaring war on another civ, the valuation would work basically the same by using the future enemy's "defensive" power (power of all those we will be at war with after declaring on them, including vassals and pacts).

Such similarities in approach are more likely to lead to desirable results.

I was thinking of boosting iEnemyPowerPercent by 20% in this war planning state, an intentional over valuation of the future enemy's power so that an AI preparing war with an equal adversary will more strongly value the ability to draft going into such a tough war.

Completely agree. I also had a 1.2 factor in my formula.

Are you going to do something with the 'losing cities and power' parts or do you foresee trouble with such an approach because it is a less stable stimulus to use nationhood. It would be typical for an AI facing a good human player to lose cities and power while still having a higher power value. In that case, nationhood and drafting would still be a good idea. If it were to lose power and cities while more powerful against another AI then it would still be a good idea but that scenario is less likely to occur.
I think it's a bad idea if an AI civilisation would move out of nationhood halfway through a war or after some drafting in the planning phase. So maybe an overvaluation (20%) of the civic (or the difference in power) if the AI is using it and if the AI is at war or planning a war. It's a bit similar thought to the 6/5 and 16/15 factors that you described earlier to avoid an AI that keeps switching between civics. Only switching out of war civics while at war is in my opinion an extra bad idea.
Switching out of vassalage during a war is less likely to occur, but use of the drafting mechanic could shift the power balance in such a way that the use of the nationhood civic reduces its valuation.
 
Roland -

Glad we're in agreement on most of the valuations, it definitely does make it seem like we're on the right track.

Finding the power of allies is a little harder than enemies since Civ4 doesn't have explicit offensive alliance relationships (other than permanent/vassal). We sort of have to use the old "the enemy of my enemy is my friend" approach. Between AIs you'll almost never get war triangles, where civs A, B, and C are all at war with each other, since the AI avoids opening second fronts like the plague.

The losing cities and power part is something the AI doesn't keep track of in a usable fashion currently, so that was one of the reasons I focused on power ratios. The AI tracks how many cities it has lost in total over the whole course of the game, and then also tracks it and its enemy's "war success" for each individual war. War success is something like:

4*(enemy units killed while attacking) + 3*(enemy units killed while defending) + 25*(enemy cities captured)

So, our enemy's war success variable basically counts how much we have lost in the war. This is what is used in determining whether to capitulate, I have added another variable to the AI which basically computes how close the AI is to considering capitulating or whether its enemies are close to considering capitulating. It's called something like WarSuccessCapitulationRatio and goes from -99 to 99, so less than -50 means the AI is getting whooped, higher than 50 means it's doing quite well in wars.

Using war success or creating some new version of it certainly could be done, but it's inherently reactive ... the power ratio is something that can cause the AI to switch to nationhood immediately when attacked, while counting cities or power lost in the war means the AI is already doing badly. Switching civics in the middle of a losing war can be a costly proposition unless you're Spiritual.

I also felt that the power ratio covered most of the scenarios where the AI would be losing cities or power from the war already, although I definitely take your point that a human player can capture important cities while having equal or even lower power than their opponent. As a hack, a human player's power could be over estimated to account for their inherently superior tactics.

Thoughts?
 
Roland -

Glad we're in agreement on most of the valuations, it definitely does make it seem like we're on the right track.

Finding the power of allies is a little harder than enemies since Civ4 doesn't have explicit offensive alliance relationships (other than permanent/vassal). We sort of have to use the old "the enemy of my enemy is my friend" approach. Between AIs you'll almost never get war triangles, where civs A, B, and C are all at war with each other, since the AI avoids opening second fronts like the plague.

What if the AI was losing relative power during a war which would make nationhood seem attractive but it had just bought an ally into the war. At that point, the combined strength would make nationhood uninteresting, not needed to win the war or stop the enemy. However, in the present plans the AI doesn't consider this war ally.
Or what if the AI was the one who was bought into a stable war between 2 parties or who backstabbed one party in a stable war between 2 parties where each party was double its power. In the present plans, the AI would immediately consider nationhood as it's enemy is twice as strong as it is itself, but it is really not needed due to its strong ally. Together, they're 50% stronger than the single enemy.

I do think the power of an ally should be valued less than your own power. It's clear that an ally won't protect your cities well and it also won't capture cities for your civilisation.

The AI does consider war allies when backstabbing someone. It looks at the balance of power already in the war and decides whether it's a good opportunity to join the fray. So the idea that an ally should count for something is not unheard of.

The losing cities and power part is something the AI doesn't keep track of in a usable fashion currently, so that was one of the reasons I focused on power ratios. The AI tracks how many cities it has lost in total over the whole course of the game, and then also tracks it and its enemy's "war success" for each individual war. War success is something like:

4*(enemy units killed while attacking) + 3*(enemy units killed while defending) + 25*(enemy cities captured)

It seems that war success is something that holds the necessary values. But if I understand you correctly, the AI only maintains this combined value and not the individual values of killed units and captured cities. So it would be tougher to teach it to also maintain those values.
I think the combined value 'war success' is good enough to help the AI see it needs extra troops quickly and thus needs drafting abilities.

So, our enemy's war success variable basically counts how much we have lost in the war. ...

Using war success or creating some new version of it certainly could be done, but it's inherently reactive ... the power ratio is something that can cause the AI to switch to nationhood immediately when attacked, while counting cities or power lost in the war means the AI is already doing badly. Switching civics in the middle of a losing war can be a costly proposition unless you're Spiritual.

In my mind, there are 2 good reasons to go to nationhood:

1) you're going to fight or are fighting in a tough war
2) you're losing the war and you need troops now or you'll lose your entire civilisation

1 is covered and 2 might be covered by the power ratio consideration.

I also felt that the power ratio covered most of the scenarios where the AI would be losing cities or power from the war already, although I definitely take your point that a human player can capture important cities while having equal or even lower power than their opponent. As a hack, a human player's power could be over estimated to account for their inherently superior tactics.

In my latest game, there was a situation where 2 AI-led civilisations were actually balanced in power and still quickly after declaring war, one of them captured several (5 or so) cities of the other. There was a very good reason for this. One of the AI's had just transported its stack of doom and entire fleet over to another continent to fight in a war against a weak opponent (it immediately signed peace with that enemy). It was doing well in that oversees war, but it didn't have any spare troops in its homeland and the enemy stacks could do what they wanted with little resistance. I'm quite sure that an immediate switch to nationhood after losing 1 or 2 cities could have made a difference.

What if max(War Success enemy/War Success us , 1) was used as a multiplier of the enemy power (in the power ratio valuation of drafting)? In that case, an enemy with relatively lots of war success would be valued as having a greater power. This would help the AI recognize capable human generals or lucky AI's who caught them in a bad tactical sitiuation. Of course some damage would have already been done but drafting might stem the tide.
It would even be ok, if the War Success from earlier engagements with the same opponent would be considered.

I'm personally not a fan of isHuman type of modifiers because not all humans behave the same. Some human players are quite bad at war and complain that capturing cities is far too hard and that they need 5 times the AI troops to capture cities. And there are also players who are quite allergic to isHuman modifiers in the AI. ;)

Reconsideration: the quotient of war success is a bit too variable. If one party loses 2 units and the other 1, then the quotient is suddenly 2 which is too influential as a multiplier of power. If you add a constant to both the numerator and denominator, then the variability is a lot less. Say a constant of 25-50 or so (25 is 6-8 units or 1 city, right).
 
Alright, so the logic for valuing Nationhood which I've got working right now scales up the value of drafting when:

1) The draftable unit is at least 70% as strong as the strongest land unit anyone has built in the game. (If well below 70%, then the value goes down to eventually 0 at the 25% marker.)

2) If the player's enemies have much higher power using the EnemyPowerPercent formula above. Allies are counted by dividing the enemies power by the number of wars they are in against non-vassals and non-minor civs.

3) If the player's enemies are having much more success in war, meaning the player is losing large numbers of units and/or cities. It kicks in when the player has lost the equivalent of one city more than they have gained.


The valuation for the other civics of this type have also been updated following the logic we worked out above. So far things are looking good in testing, but I'll need to be checking and tweaking for a little while.

Now, all we have left to do are the four other civic option types ...
 
Alright, so the logic for valuing Nationhood which I've got working right now scales up the value of drafting when:

1) The draftable unit is at least 70% as strong as the strongest land unit anyone has built in the game. (If well below 70%, then the value goes down to eventually 0 at the 25% marker.)

2) If the player's enemies have much higher power using the EnemyPowerPercent formula above. Allies are counted by dividing the enemies power by the number of wars they are in against non-vassals and non-minor civs.

3) If the player's enemies are having much more success in war, meaning the player is losing large numbers of units and/or cities. It kicks in when the player has lost the equivalent of one city more than they have gained.

Sounds good.

So I guess nationhood will be used in tough wars and vassalage in easy wars.

The valuation for the other civics of this type have also been updated following the logic we worked out above. So far things are looking good in testing, but I'll need to be checking and tweaking for a little while.

I can imagine that such things need quite some tweaking to get it to behave correctly. Thinking of the right motivations to use the civic is one thing, getting each of the motivations exactly influential enough is a lot harder.

Now, all we have left to do are the four other civic option types ...

:hide:


Seriously, are there problems in other categories of civics? I haven't heard of any, but of course it's not something that players pay attention at during a typical game. So there are bound to be some valuations that we consider to be off a bit. We are likely to understand the balance of the game a bit better than some of the game designers who didn't play the game a lot.
 
nevermind......... police state came in my mind but it just cannot be used until fascism got researched (by the AI without pyramids) -> therefore not that important.
 
Top Bottom