Report Questionable Behavior

I'm not sure exactly where this falls...but I will provide an explanation, screenshots, and a save.

First...I am playing as Vikings. I am at war (both declared on me) with both civs to my West - Korea & Arabia. Saladin had sent a fairly strong stack at me already that was mostly destroyed...and I believe he still has a fairly adequate stack that is not visible in the screenshots. Now...he has 2 units left in my land...both in a spot to do very little harm except annoy me. His units at this time have basically 4 movements they can make:

#1 - Attack my stack on the hill...which would result in suicide.
#2 - Move 1 tile SE, move in close to my city, and have the protection of the forest. This would maybe cause me to attack and lose a unit or 2, or even 3 with unlucky rolls, or maybe I do nothing, and he simply can keep the units and await the rest of his stack. Or do the same thing by moving 1 tile North...even though that really doesnt do him much good.
#3 - Retreat either going South, or SW...and join up with this stack & recalibrate their attack.
#4 - Move 1 tile to the NE, between TWO stacks and in an unprotected area. There is no river crossing penalty for either stack of mine. There is no forest to hide in...there is nothing. Basically, a suicide move.

And what decision does Saladin make? Well...#4. He move toward my capital/iron tile. But in a complete suicide mission with no protection. I destroy both units with zero casualties. Seems that Saladin shouldn't make that decision...I'd NEVER make that decision & I dont think anyone else would, either. There is no point to it. Is this something worth looking into JDog?....

*Both Screen shots, before & after, along with savegame.
 
Unfortunately, as far as I understand, the AI doesn't think like that. It will see that it has 2 Great Artists, and it will think, "Yeehaw, now which border city needs a culture bomb?" or "Yeehaw, I can start a golden age!" etc. The AI is like a small child. It doesn't have a memory from turn to turn of what it had been planning to do with those 2 Great Artists. I looks at each turn anew as if it had never seen the game before (aside from a few aspects like diplomacy).

Likewise, with pre-built SS parts, come the next turn the AI would see no reason to not just finish those SS parts, as it doesn't remember that its strategy had been to pre-build them so as to catch the human off-guard.

Would it really take so much memory to write down some necessary things like that described above? Or rather it just question of labour time that should be spent on development of appropriate code?
 
Would it really take so much memory to write down some necessary things like that described above? Or rather it just question of labour time that should be spent on development of appropriate code?

It would demand a lot of work AND will cause endless trouble with savegame compatibility. Giving useful memory to an AI is already hard ; in civIV it's harder because of the way the savegame are done, IIRC.
 
Unfortunately, as far as I understand, the AI doesn't think like that. It will see that it has 2 Great Artists, and it will think, "Yeehaw, now which border city needs a culture bomb?" or "Yeehaw, I can start a golden age!" etc.

Well, the suggestion is the change the way the AI thinks about that. It doesn't require any external memory to make it such that if the AI sees 2 Great Artists it assumes it is storing them. The trick will be preserving that first Great Artist, which it will probably spend before a second one can come along and trigger the "oh, that's what I'm doing with these" subroutine.
 
In the specific case of saving Great Artists, it looks like the AI needs a change to cvUnitAI::AI_artistCultureVictoryMove. To save artists up, we would need to first check whether we can use our Great Artists to instantly win. If we can, then we push the great work mission and return true, as now. If we cannot, but a great work would otherwise be a good plan, then we push the skip mission and return true. This ensures that our artist won't be wasted on other stuff.
 
Hi, I am incorporating Better AI into a mod, so thanks very much for this excellent project. The questionable behaviour I have seen is with respect to AI civic choices.

1) In my mod the default religion civic is Folk Religion (no upkeep; +25% culture), and with Polytheism you can instead run Imperial Cult (low upkeep; +50% great general points). As far as I have seen, the AI will switch into Imperial Cult at the first chance, incurring the greater upkeep for no tangible reward, when surely they only want to switch if they are at war... I have looked into the AI_civicValue method in CvPlayerAI.cpp and the value assigned to great general modifiers is given as:

Code:
	iValue += ((kCivic.getGreatGeneralRateModifier() * getNumMilitaryUnits()) / 50);

I think this should be changed to consider whether the AI is at war or planning for war, since surely increased great generals is a totally worthless benefit otherwise?! Suggestion:

Code:
	[COLOR="RoyalBlue"]if (bWarPlan)
	{[/COLOR]
		iValue += ((kCivic.getGreatGeneralRateModifier() * getNumMilitaryUnits()) / 50);
	[COLOR="RoyalBlue"]}[/COLOR]

2) Secondly and briefly, I could not find anything in the AI_civicValue method which accounted for bonus healthiness on buildings. Bonus happiness is covered, but unless I am mistaken healthiness is not. Could make a change like so:

Code:
	for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
	{
		iTempValue = kCivic.getBuildingHappinessChanges(iI);
		if (iTempValue != 0)
		{
			// Nationalism
			if( !isNationalWonderClass((BuildingClassTypes)iI) )
			{
				iValue += (iTempValue * getNumCities())/2;
			}
			iValue += (iTempValue * getBuildingClassCountPlusMaking((BuildingClassTypes)iI) * 2);
		}
	}

becomes:

Code:
	for (iI = 0; iI < GC.getNumBuildingClassInfos(); iI++)
	{
		iTempValue = kCivic.getBuildingHappinessChanges(iI)[COLOR="RoyalBlue"]+kCivic.getBuildingHealthChanges(iI)[/COLOR];
		if (iTempValue != 0)
		{
			// Nationalism
			if( !isNationalWonderClass((BuildingClassTypes)iI) )
			{
				iValue += (iTempValue * getNumCities())/2;
			}
			iValue += (iTempValue * getBuildingClassCountPlusMaking((BuildingClassTypes)iI) * 2);
		}
	}

3) Just thought of a third point: for civics which include faster maturation of cottages etc, the value assigned to them is given by:

Code:
	iValue += ((kCivic.getImprovementUpgradeRateModifier() * getNumCities()) / 50);

A civ emphasising farms and specialists etc won't have much use for this civic. Perhaps this should be altered to consider the quantity of cottages, hamlets and villages in an empire? Not sure how this would be achieved without simply counting the occurences of 'COTTAGE' etc, but since these are only integer references, if a mod has altered the order in which tile improvements are defined, this would break. Perhaps the current situation is actually the lesser evil?
 
Why is it useless for the AI to create Great Generals just because it's not going to be an aggressor?

I might be mistaken but I think bWarPlan doesn't just mean that the AI is gearing up for war, it also covers whether the AI is already at war. Since the AI has to be at war to accumulate great general points, I thought bWarPlan would have to be a factor in AIs deciding whether to emphasise great general points with their civic choices.

EDIT: if the if(bWarPlan) isn't a good idea, perhaps use if(getAtWarCount()>0) instead.

While we're talking about civic decisions, what is the purpose of this block regarding the AI's favourite civic?

Code:
	if (GC.getLeaderHeadInfo(getPersonalityType()).getFavoriteCivic() == eCivic)
	{
		if (!kCivic.isStateReligion() || iHighestReligionCount > 0)
		{
			iValue *= 5; 
			iValue /= 4; 
			iValue += 6 * getNumCities();
			iValue += 20; 
		}
	}
 
Munch, I brought up some other issues I had with civic logic, but it got largely ignored. You probably should hijack the thread with your points too, since my qualms were never fixed.

Hey man, I'd like to know if you have any ideas for fixing the points you and I raised, so that I can at least modify my own version accordingly. Here are some suggestions for your points:

Regarding your first point, the code in version 0.82 is different I believe, but I think you are still right that it doesn't take into account army size:

Code:
iValue += (getNumCities() * 9 * AI_getHappinessWeight(iTempValue, 1)) / 100;

How would you suggest fixing this? What about:

Code:
iValue += ([COLOR="RoyalBlue"]getNumMilitaryUnits()[/COLOR] * AI_getHappinessWeight(iTempValue, 1)) / 100;

that is, replacing "getNumCities() * 9" with just "getNumMilitaryUnits()".

For your second point, the code in 0.82 is:

Code:
	iValue += (kCivic.getBaseFreeUnits() / 2);
	iValue += (kCivic.getBaseFreeMilitaryUnits() / 2);
	iValue += ((kCivic.getFreeUnitsPopulationPercent() * getTotalPopulation()) / 200);
	iValue += ((kCivic.getFreeMilitaryUnitsPopulationPercent() * getTotalPopulation()) / 300);

Any ideas?
 
I don't have time now, but this evening, I'll look over the civic code. A lot of it needs changing. It could do with a big rewrite.
 
In the game that I just played, the AI's use of naval units was probably worse than just ignoring the sea altogether. The main problem was that they'd build heaps of ships and then just leave them sitting in a border city doing nothing. (see screenshots.) They'd just leave them there for ages, and upgrade them when they got more tech, then still just leave them there.

Later on in that same game I declared war on Saladin and was able to easily take that city with all the ships in it. He only had 3 or 4 ground defenders, and my borders were pressed right up against the city. Before that turn my military rating thing was something like 0.7 against his, but after wiping out his massive stack of ships it jumped to 1.0. I just don't see any benefit in having so many ships garrisoned in a border city like that. It would be far far better to have them somewhere on the coast. Leaving a big pile of full health naval units in a border city is clearly an unnecessary risk.

Also, during war time, the AI ships would often attack when they had less-than-even odds, even if their was no good reason to do so. I'd only attack like that if I had a clear reason, such as trying to defend a particular place, or if I have a second ship waiting to finish what the first one started, or something that.
 

Attachments

  • Civ4ScreenShot0003.JPG
    Civ4ScreenShot0003.JPG
    305.5 KB · Views: 106
  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    278.8 KB · Views: 99
In the game that I just played, the AI's use of naval units was probably worse than just ignoring the sea altogether. The main problem was that they'd build heaps of ships and then just leave them sitting in a border city doing nothing. (see screenshots.) They'd just leave them there for ages, and upgrade them when they got more tech, then still just leave them there.

Later on in that same game I declared war on Saladin and was able to easily take that city with all the ships in it. He only had 3 or 4 ground defenders, and my borders were pressed right up against the city. Before that turn my military rating thing was something like 0.7 against his, but after wiping out his massive stack of ships it jumped to 1.0. I just don't see any benefit in having so many ships garrisoned in a border city like that. It would be far far better to have them somewhere on the coast. Leaving a big pile of full health naval units in a border city is clearly an unnecessary risk.

Also, during war time, the AI ships would often attack when they had less-than-even odds, even if their was no good reason to do so. I'd only attack like that if I had a clear reason, such as trying to defend a particular place, or if I have a second ship waiting to finish what the first one started, or something that.

I noticed this too. The AI built 4-5x as many ships as me, with no real purpose. Then just idled, and when I finally did declare war, they sent tons of galleys against my Battle-cruisers. I didn't mind, lots of free XP, but I thought Naval AI was better than that. Is it possible that the latest Better AI broke Naval AI in some way?
 
In a recent game (Hemispheres map, 0.82 Better AI modded), I founded 2 cities on a nearby island. When I tried to give them independence, I was offered to gift them to a civ not met yet. This civ is in a continent on the other hemisphere, so this behaviour is very odd indeed! In fact, gifting them a city could be used as an exploit to:
  • Trade (or stole) technologies years before the "standard" contact (by a caravel reaching their continent).
  • Raise their city maintenance cost greatly, due to distance from palace.

I've attached a screenshot and a savegame.

Edit: Removed the savegame due to quota issues.
 

Attachments

  • Civ4ScreenShot0001.jpg
    Civ4ScreenShot0001.jpg
    100.9 KB · Views: 101
This is not a BBAI issue, but of the game itself, because the liberate city code does not check if you know the civ you suposedely want to liberate the city to. jdog corrected one form of this bug ( see here and here ) in the UP 1.3 ( that is included in BBAI 0.82 ) , but it looks that this issue is more deep than a simple block of pop up can solve :( ....

I sugest you to post this also in the UP thread .
 
The automated city governor made a terrible decision here, choosing to work a plains forest instead of a plains hill goldmine. When building a worker both tiles give equal production, but the goldmine gives extra free commerce. Additionally, the AI governor has not considered the +75% hammers on workers, which make the goldmine the clear winner.

I did manage to get the AI governor to change its mind by emphasising food, hammers, commerce, research and great people all at once, however. :crazyeye:

 
Noticed something odd in my last game. If you look at the screenshot, I just got 450 hammers from chopping. IIRC, I had just build a cottage(and thus chopped the forest) on the tile west of the city. The game is on marathon speed and the city(which was a barbarian city) was liberated for me by my vassal. I don't know if I'm missing something obvious, but 450 seems kinda high.

Also, I couldn't build railroad on the mines south and southwest of the city, but was able to build them on the east side as you can see.
 

Attachments

  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    255.6 KB · Views: 4,831
In the game that I just played, the AI's use of naval units was probably worse than just ignoring the sea altogether. The main problem was that they'd build heaps of ships (...)
I noticed that too, when I played a duel-sized perfectworld2 map that turned pangea: AI with at least a dozen caravels, and all of them just parking. Without any real threat by sea to defend against and with all possible enemies on the same landmass (and no unpassable mountain chains inbetween either).
Excessive ship building exists with enemies on different landmasses too but at least there it looks like there is some kind of purpose behind it - and those ships aren't always parking. Though mostly they don't do much there either, and it probably hurts AI progress a lot.
 
Top Bottom