Report Questionable Behavior

My guess on the Machine Gun things is thats its because MGs are classified as 'Siege Weapons'. Perhaps the AIs are even upgrading older units into MGs 'by mistake'.
 
Questionable behaviour: the AI builds too many spearman for city attack duties.

I've seen the AI attack with stacks with 6 spearmen, 2 axemen and 1 swordsman. I saw the same behaviour when I was continuing my game today and I thought I'd report it. I do have some horse based units (chariots), but not that many, so there's no reason to build that many spearmen. Below are two screenshots where you can see the relatively large amount of spearmen. Both screenshots are from the same year but a different empire (both stacks are there to kill me). I've seen worse than this, but I'd say that even in these stacks, there are too many spearmen.

My guess is that the AI views the spearman as a better city attack unit. Both units can get city attack upgrades. One has strength 4 and a 100% bonus against a specific unit and the other strength 5 and a 50% bonus against a specific unit. The AI probably doesn't look any further. However, the 100% bonus is against units that rarely defend cities because these units (mounted units) don't get defensive bonusses.

So maybe you could code something that when buiding units for city attack purposes that a specific bonus against units that don't get defensive bonusses is not considered valuable. So the 100% bonus against mounted units from the spearman is not considered interesting for city attack purposes because it is a bonus against units that don't get defensive bonusses.

Of course, spearmen are still needed as stack defence units.

Maybe the AI builds that many spearmen for a different reason. I'm just guessing here.

Spearmen for city attack 1.JPG
Spearmen for city attack 2.JPG

I added the bold. That is exactly right. It is a tricky problem to solve, if you do not allow yourself to know that melee and archer units are what is likely to be defending cities.

I know Blake was working on the problem, but I also know that it is not trivial to solve if you want your solution to work with mods as well.

-Iustus
 
I added the bold. That is exactly right. It is a tricky problem to solve, if you do not allow yourself to know that melee and archer units are what is likely to be defending cities.

I know Blake was working on the problem, but I also know that it is not trivial to solve if you want your solution to work with mods as well.

-Iustus

Ah, nice to hear that my first guess was correct. And I know that you're thinking about mods. You're not looking at spearmen and axemen, you're looking at units with values and bonusses and the code must work correct whatever these strength values and bonusses are.

That's why I suggested the following, also in that piece of text that you quoted.

However, the 100% bonus is against units that rarely defend cities because these units (mounted units) don't get defensive bonusses.

The spearman bonus works against mounted units and mounted units aren't good city defenders because they don't get defensive bonusses. To put it more abstract. You look at the 100% bonus and try to judge if it helps a unit in its potential city attack role. To judge this, you look at the units that are effected by this 100% bonus. If these units are good city defenders (get defensive bonusses in cities, have high strength value, can be build by the enemy), then the 100% bonus counts as a very good bonus for the city attack unit. If these units are not so good city defenders (no defensive bonusses in cities, low strength value, cannot be build by the enemy), then the 100% bonus is not considered useful for the city attack unit.

The spearman can be considered again for a stack defense role, but then other arguments are used to determine its value in that role.

For instance: the AI 'knows' that the opponent can build axemen, swordsmen, spearmen, archers, chariots and horsebowmen. It doesn't know which ones are good city defenders. It has to calculate that.

Let's take an average city defence value of 40%. That's a bit arbitrary and maybe not that perfect for mods. You could code is as a function of the maximum cultural defence value and the maximum building defence value.

You calculate the strength value of a basic promoted spearman for city attack duty versus each of the possible defenders. That would be a city raider 1 spearman in civ4 for the attacking sprearman, but might be different in a mod. The axeman would have the combat 1 promotion and the archer the city garrison 1 promotion and the chariot the combat 1 promotion for city defence duties.

The strength of the spearman versus the axeman would be 4 / 5* (1 + 0.5 + 0.1 + 0.4 + 0.25 -0.2) = 4 / 10.25 = 0.390

The strength versus the chariot would be 4 / (4 / (1 + 1 -0.1 + 0.2)) = 2.1

You take the minimum of all of these strength values and that is the city attack value of the spearman.
You do the same for the axeman versus all of these units. Now you have a city attack victory value for the spearman and the axeman.

Then you divide this city attack value of both units through the building costs of these units and the highest value gives you the best city attacker. In civ4, these building costs for the axeman and the spearman are the same, but that's not true in every mod.

It's quite a lot of calculations but a computer can do this very fast.

To make the AI less predictable, you could multiply these city attack values by a random variable between 1 and 3 and only then determine which unit is better in the city attack role. That way, there will be some less efficient city attackers which can be useful in specific situations. And it's always nice to have an AI that is not too predictable.
 
Hello,

As this is my first post on this thread I just want you all to know that I have been following this thread closely for quite some time and have downloaded the 1/30 build about about a week ago. I personally think that it is a great build and is making huge strides in the right direction for a better playing experience. I really do not have anything new to add in regard to questionable behavior that hasn't been said about the 1/30 build. Just thought I would introduce my self prior to me posting anything debatable so you regulars weren't like "who is this joker?"

see ya :rockon:
 
A trivial issue with the city build governor.

Leipzig is building culture to pop it's borders even though it doesn't need to because of the surrounding cities.

(From a build based on rev 356).
 

Attachments

  • Screen1.jpg
    Screen1.jpg
    308.2 KB · Views: 209
  • Screen2.jpg
    Screen2.jpg
    204 KB · Views: 169
This is on the 2/9 build, and I have not encountered this problem prior to it.

As you can see from the screen shot I am at war with Carthage, and there are two workers next to my axeman. Even more surprisingly, my axeman is already on top of two workers which he captured in the exact same way he is going to capture the highlighted workers.

I am not sure if this is occurring because The Better AI team adjusted the worker flee rate, but the behavior is rather dubious. Unless of course if the workers are eager to flee to a society that is not running the Slavery civic...:lol:

 
Just a follow up, I thought I would show how crazy this behavior is with this screen shot. I currently have 3 cities and 12 workers!! I'm sorry that I do not have a save, I need to change my ini file to start auto saving every turn.

 
Something I would report as 'questionable behavior' is some of the AI's panic builds when a city comes under threat. Using Nationalism to draft a guy here and there is fine, but wholesale slaughter of their population to add a single Catapult or other troop probably isnt good to see quite as often.

In my last game, I was fighting a war with Saladin. He had a couple of good-sized cities on the border that were culturally pressing against some newer cities I had taken from the French. I decided to declare war to remove those cities and the pressure. I moved in with stacks of Rifles/Grenadiers/Cannon but didnt have enough to actually complete the conquest. But even at only what I would consider a 'mild' threat, the AI ripped those cities from pop 12 and 14 down to 3 and 4 by panic building Cavalry and Catapults. IMO, thats just not worth the cost. And its exploitable to simply move adjacent to enemy cities and watch them self-destruct. Smart defense is one thing, but it appears that the AI is also overreacting in many cases.

When you add the above to the fact that many of the AI are in prolonged wars due to the removal of the 'auto-peace' and I think its stunting many AI cities and thus their long-term potential. I almost every game I've played, if I can get through the early game intact and with a little wiggle room, the AIs just totally fall behind in Industrial and beyond. Up until that point they are very competitive and often slightly ahead of me but then they seem to just hit a wall. I think they might be pop-rushing too much and suffering from too many long wars.

As I said in the impressions thread, I think some sort of 'auto peace' or war limit needs to be added back in. Without that, the AIs run the risk of running themselves into the ground in stalemated conflicts.
 
As I said in the impressions thread, I think some sort of 'auto peace' or war limit needs to be added back in. Without that, the AIs run the risk of running themselves into the ground in stalemated conflicts.


With all the glibness of someone who isn't going to do the programming, nor understands the difficulty of implementing his suggestions, perhaps instead of making it a simple hard-coded time of 30 turns, maybe make it a variable time -- something between 25 - 50 turns or something like that?
 
As I said in the impressions thread, I think some sort of 'auto peace' or war limit needs to be added back in. Without that, the AIs run the risk of running themselves into the ground in stalemated conflicts.

With all the glibness of someone who isn't going to do the programming, nor understands the difficulty of implementing his suggestions, perhaps instead of making it a simple hard-coded time of 30 turns, maybe make it a variable time -- something between 25 - 50 turns or something like that?

I disagree with both these ideas. The declaration of peace should not be related to the length of the war, but to the success rate of the war. If after 30 turns of fighting, neither side has captured a city, then the war is not going to be a profitable one. If the war weariness is becoming intolerable, then peace should be a preferred option, even if the war has only lasted a few turns. If the war has cost many units, but also many cities were captured and war weariness is still tolerable, then the war should be continued.

The problem with coding this is probably keeping track of the right statistics of the war (lost cities, captured cities, lost units, killed units, war weariness, relative military strength) and then deciding what to do based on these statistics. Please do not let the AI sign a peace treaty when it has a huge stack in front of a lightly defended city. Good luck with coding something reasonable.

By the way, I'm usually able to sign a peace treaty after I've defeated some attacking stacks of the AI. And most AI wars are also not indefinite in nature.
 
The declaration of peace should not be related to the length of the war, but to the success rate of the war. If after 30 turns of fighting, neither side has captured a city, then the war is not going to be a profitable one.....

The problem with coding this is probably keeping track of the right statistics of the war (lost cities, captured cities, lost units, killed units, war weariness, relative military strength) and then deciding what to do based on these statistics. Please do not let the AI sign a peace treaty when it has a huge stack in front of a lightly defended city. Good luck with coding something reasonable.



Well, that's the rub, isn't it? I'm not referring to player versus AI wars, but rather to AI vs AI wars. I have seen on multiple occasions an AI player get bogged down in a war with another AI player, where a couple of cities will change hands, and then things will just sputter to a halt. But the war continues along with the negative effects attendant (skewed production/tech priorities, lack of trades, etc.) I would much prefer the AI to act as you describe but it sounds as though this would be something that perhaps should wait until Better AI 2.0 or 3.0 given the difficulty of the programming task. All I was suggesting was that in the interim, a variable "auto-peace" solution might avoid the AI "always war" stagnation effect.
 
I disagree with both these ideas. The declaration of peace should not be related to the length of the war, but to the success rate of the war. If after 30 turns of fighting, neither side has captured a city, then the war is not going to be a profitable one. If the war weariness is becoming intolerable, then peace should be a preferred option, even if the war has only lasted a few turns. If the war has cost many units, but also many cities were captured and war weariness is still tolerable, then the war should be continued.

Well sure, if thats possible that would be great. But if something like that cant be easily rigged, then I'd vote to have the AI more likely to make peace than they are now.

As jkp1187 noted, the AI to AI wars are often extremely long and drawn out and indecisive after a while. And that has a decidedly negative effect on the AI's growth. So, its not 'smart' to keep fighting an inconclusive war and pop-rushing troops and being subjected to pillaging and whatnot.

I think in many cases people focus on the AI to player relations but the AI to AI interactions are just as important (and in fact since they are more constant, the AI to AI relations might be MORE important). So its critical to make sure that these increased numbers of wars and the longer durations arent simply making things EASIER for the player be wearing the AIs down fighting each other.
 
Well, that's the rub, isn't it? I'm not referring to player versus AI wars, but rather to AI vs AI wars. I have seen on multiple occasions an AI player get bogged down in a war with another AI player, where a couple of cities will change hands, and then things will just sputter to a halt. But the war continues along with the negative effects attendant (skewed production/tech priorities, lack of trades, etc.) I would much prefer the AI to act as you describe but it sounds as though this would be something that perhaps should wait until Better AI 2.0 or 3.0 given the difficulty of the programming task. All I was suggesting was that in the interim, a variable "auto-peace" solution might avoid the AI "always war" stagnation effect.

Well sure, if thats possible that would be great. But if something like that cant be easily rigged, then I'd vote to have the AI more likely to make peace than they are now.

As jkp1187 noted, the AI to AI wars are often extremely long and drawn out and indecisive after a while. And that has a decidedly negative effect on the AI's growth. So, its not 'smart' to keep fighting an inconclusive war and pop-rushing troops and being subjected to pillaging and whatnot.

I think in many cases people focus on the AI to player relations but the AI to AI interactions are just as important (and in fact since they are more constant, the AI to AI relations might be MORE important). So its critical to make sure that these increased numbers of wars and the longer durations arent simply making things EASIER for the player be wearing the AIs down fighting each other.

Yes, it might be very hard to code this. But as long as I haven't heard that it is too hard (by the betterAI team), I'll vote for the harder solution where the arguments for peace and war are taken into account.

The BetterAI team has removed the 'peace after 30 turns' rule and the AI are still capable of signing peace treaties. I don't know exactly why they sign them and according to your descriptions they sometimes sign them too late. But I don't think they sign them at random. I think there is some coding logic behind the signing of peace treaties. At least when an AI is attacking me and has lost a whole lot of units, then it typically wants to sign a peace treaty. That at least seems reasonable to me. Maybe the logic isn't perfect yet and needs some refining so that the AI will sign peace treaties sooner in some cases.

If you think that in one of your games an AI-AI war is taking too many turns without any success, then maybe you should upload some savegames of these two AI's at war and suggest some improvent.
Something like: France and Spain went to war in 1305 and stayed in that war for 50 turns while no cities exchanged hands. Both their power graphs dropped dramatically and their cities shrunk through massive drafting. You should provide some savegames at various points in the war.
That kind of data might help the team refine the code that governs the signing of peace treaties. If I see some endless inter AI wars, I'll try to do the same.
 
On the whole I agree with what you're saying Roland, but there are times that AI's should engage in fruitless wars. It would present a decent simulation of real life where both sides refuse to end the attrition even though neither is benefiting from ti. Clearly, if it can not continue to happen at the rate that it is otherwise the game would not be fun.

Perhaps it can be tied to personalities? For example, Monty or Toku could be more inclined to continue in a war for 30 + turns even though it has not proven to be beneficial. Where as Gandhi would be willing to talk after 2 turns even if the war is going well for him.
 
Perhaps it can be tied to personalities? For example, Monty or Toku could be more inclined to continue in a war for 30 + turns even though it has not proven to be beneficial. Where as Gandhi would be willing to talk after 2 turns even if the war is going well for him

I think thats the way it was before the change...each leader had a different 'timer' (but I'm not sure...someone from BetterAI would have to confirm).
 
On the whole I agree with what you're saying Roland, but there are times that AI's should engage in fruitless wars. It would present a decent simulation of real life where both sides refuse to end the attrition even though neither is benefiting from ti. Clearly, if it can not continue to happen at the rate that it is otherwise the game would not be fun.

Perhaps it can be tied to personalities? For example, Monty or Toku could be more inclined to continue in a war for 30 + turns even though it has not proven to be beneficial. Where as Gandhi would be willing to talk after 2 turns even if the war is going well for him.

I think it's reasonable that Montezuma and Tokugama and other crazy warmongerers would find a higher level of war weariness acceptable than Gandhi. And of course, a warmongerer should find it more interesting to continue a war when it captures cities. Such things could give them personality. Still the general idea that high levels of war weariness and a stalemate war would result in a bigger chance of peace seems reasonable.
 
I disagree with both these ideas. The declaration of peace should not be related to the length of the war, but to the success rate of the war. If after 30 turns of fighting, neither side has captured a city, then the war is not going to be a profitable one. If the war weariness is becoming intolerable, then peace should be a preferred option, even if the war has only lasted a few turns. If the war has cost many units, but also many cities were captured and war weariness is still tolerable, then the war should be continued.

The problem with coding this is probably keeping track of the right statistics of the war (lost cities, captured cities, lost units, killed units, war weariness, relative military strength) and then deciding what to do based on these statistics. Please do not let the AI sign a peace treaty when it has a huge stack in front of a lightly defended city. Good luck with coding something reasonable.

By the way, I'm usually able to sign a peace treaty after I've defeated some attacking stacks of the AI. And most AI wars are also not indefinite in nature.

Many of these things are already being tracked. If you turn on chipotle, you can see the value an AI puts on peace, which is how it determines if it is winning or losing a war. From the chipotle thread, take a look at this picture:


If you look at the middle picture, you can see that Brennus is winning the war with Iustus (because 150 is lower than 210), losing the war with Ramesses (because 400 is higher than 40), and losing the war with Roosevelt (because 190 is higher than 60). These values very nearly translate into gold, so in this case, Brennus would ask Iustus for about 60g for peace, but you would pay Ramesses about 360g for peace, and pay Roosevelt about 130g for peace.

Specific examples of when you think the peace value calculations are in error would be helpful.

Well, that's the rub, isn't it? I'm not referring to player versus AI wars, but rather to AI vs AI wars. I have seen on multiple occasions an AI player get bogged down in a war with another AI player, where a couple of cities will change hands, and then things will just sputter to a halt. But the war continues along with the negative effects attendant (skewed production/tech priorities, lack of trades, etc.) I would much prefer the AI to act as you describe but it sounds as though this would be something that perhaps should wait until Better AI 2.0 or 3.0 given the difficulty of the programming task. All I was suggesting was that in the interim, a variable "auto-peace" solution might avoid the AI "always war" stagnation effect.

Well sure, if thats possible that would be great. But if something like that cant be easily rigged, then I'd vote to have the AI more likely to make peace than they are now.

As jkp1187 noted, the AI to AI wars are often extremely long and drawn out and indecisive after a while. And that has a decidedly negative effect on the AI's growth. So, its not 'smart' to keep fighting an inconclusive war and pop-rushing troops and being subjected to pillaging and whatnot.

I think in many cases people focus on the AI to player relations but the AI to AI interactions are just as important (and in fact since they are more constant, the AI to AI relations might be MORE important). So its critical to make sure that these increased numbers of wars and the longer durations arent simply making things EASIER for the player be wearing the AIs down fighting each other.

Yes, it might be very hard to code this. But as long as I haven't heard that it is too hard (by the betterAI team), I'll vote for the harder solution where the arguments for peace and war are taken into account.

The BetterAI team has removed the 'peace after 30 turns' rule and the AI are still capable of signing peace treaties. I don't know exactly why they sign them and according to your descriptions they sometimes sign them too late. But I don't think they sign them at random. I think there is some coding logic behind the signing of peace treaties. At least when an AI is attacking me and has lost a whole lot of units, then it typically wants to sign a peace treaty. That at least seems reasonable to me. Maybe the logic isn't perfect yet and needs some refining so that the AI will sign peace treaties sooner in some cases.

If you think that in one of your games an AI-AI war is taking too many turns without any success, then maybe you should upload some savegames of these two AI's at war and suggest some improvent.
Something like: France and Spain went to war in 1305 and stayed in that war for 50 turns while no cities exchanged hands. Both their power graphs dropped dramatically and their cities shrunk through massive drafting. You should provide some savegames at various points in the war.
That kind of data might help the team refine the code that governs the signing of peace treaties. If I see some endless inter AI wars, I'll try to do the same.

Keep track of the peace values, is there a common theme?

I think thats the way it was before the change...each leader had a different 'timer' (but I'm not sure...someone from BetterAI would have to confirm).

No, it was a hard coded maximum (50 turns for total war, and 40 turns for limited war, if memory serves). The more aggressive leaders have a modifier on the peace value though, so that is what changes how long a war lasts. Some leaders require a bigger difference in order to accept peace.

I think it's reasonable that Montezuma and Tokugama and other crazy warmongerers would find a higher level of war weariness acceptable than Gandhi. And of course, a warmongerer should find it more interesting to continue a war when it captures cities. Such things could give them personality. Still the general idea that high levels of war weariness and a stalemate war would result in a bigger chance of peace seems reasonable.

Spoiler more than you want to know about how end war values are calculated :

Code:
AI_endWarVal
{
	EndWarValue = 100

	EndWarValue = EndWarValue + (CountOurCities + CountTheirCities) * 3);
	EndWarValue = EndWarValue + (CountOurPopulation + CountTheirPopulation);

	EndWarValue = EndWarValue + (WarSuccessThemVsUs * 20)

	EndWarValue = (EndWarValue * (TheirPower + 10)) / (OurPower + TheirPower + 10)
	
	if (weAreNotHuman and our power is at least 20% higher)
	{
		if DaggerStrategy then reduce EndWarValue to (90% * TheirOurPowerRatio)

		if We Own 20% more Land than Them then reduce EndWarValue by (90% * TheirOursLandRatio)
		
		if we in financial trouble // warmonger war to solve finances factor
		{
			if TotalWar and (Dagger or (maxWarRand < 100)) reduce EndWarValue by (70% * power ratio factor)
			if LimitedWar and (limitedWarRand < 100) reduce EndWarValue by (70% * power ratio factor)
			if DogpileWar and (dogpileWarRand < 100) reduce EndWarValue by (70% * power ratio factor)
		}
	}

	if total war and the aggressor is non-human, double EndWarValue
	if total war and the aggressor is non-human, increase EndWarValue by 50%

	round to the nearest 10 (actually using "DIPLOMACY_VALUE_REMAINDER" from GlobalDefines.xml)

	if human and less than 10, set it to 10.
}

WarSuccess itself is calculated the following way:
every action triggers a change in the value, based on the values from GlobalDefines.xml:
Code:
	<Define>
		<DefineName>WAR_SUCCESS_DEFENDING</DefineName>
		<iDefineIntVal>3</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>WAR_SUCCESS_ATTACKING</DefineName>
		<iDefineIntVal>4</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>WAR_SUCCESS_UNIT_CAPTURING</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>WAR_SUCCESS_CITY_CAPTURING</DefineName>
		<iDefineIntVal>10</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>WAR_SUCCESS_NUKE</DefineName>
		<iDefineIntVal>10</iDefineIntVal>
	</Define>


I may add showing the war success value as well to Chipotle.

-Iustus
 
I found a big bug, war is declared much much much more often than they should be. In updating the chipotle code to use the new percentages (based on a change made recently to declare war more when AI is paying high unit support costs), I found a bug in that code. When it thinks it should have a 5&#37; chance of declaring war, it actually has a 95% chance for declaring war.

So, your observations that the AIs are always at war is not in error. I think this was also in the 1/30 build, but perhaps I am mistaken about that.

Expect a fix soon.

(I meant to post this on the 2/9 feedback thread, I will post it there as well)

-Iustus
 
Many of these things are already being tracked. If you turn on chipotle, you can see the value an AI puts on peace, which is how it determines if it is winning or losing a war.

-Iustus

I actually expected that the AI was already tracking many of these things and that's why I didn't want to revert back to the old maximum war time limit. I think that some of the complaints by players about indefinite AI-wars should be solved by refining the formulas that you showed at the bottom of your post.

Thanks again to take the time to explain how the AI functions. It's always interesting to read this kind of stuff and helps debates to become a bit more constructive.

About the warsuccess thingy. I expect that war success for the opponent means negative war success for you. If you kill a unit then that is a positive thing, but if your opponent kills a unit of yours, then that is a negative thing. If you capture and then lose a city again, then that's a neutral effect on warsuccess. Is that correct?

I didn't see a factor for war weariness. I know that it is connected to killing and losing units in foreign territory and capturing cities and nuking and getting nuked. So it resembles the warsuccess modifier a bit. But the main difference is that war weariness can only become worse during a war. Another difference is that a very succesfull war can lead to disastrous levels of war weariness. Even if you sign a peace treaty after a war has lasted so long that war weariness became crippling, then redeclaring war after a short peace period won't reset the war weariness. It will still be crippling and thus such a redeclared war is bad for both parties involved (assuming both have high levels of war weariness).
Crippling war weariness is a thing that should cause both parties in the war to want to end the war and stay in peace for a while. War weariness decreases only very slowly.
 
I found a big bug, war is declared much much much more often than they should be. In updating the chipotle code to use the new percentages (based on a change made recently to declare war more when AI is paying high unit support costs), I found a bug in that code. When it thinks it should have a 5% chance of declaring war, it actually has a 95% chance for declaring war.

So, your observations that the AIs are always at war is not in error. I think this was also in the 1/30 build, but perhaps I am mistaken about that.

Expect a fix soon.

-Iustus

Good job finding the error. It might explain at least a part of those dozen war declarations that I got in my 1/30 game before 0 AD. ;)
 
Top Bottom