AI cheats...

Yakk

Cheftan
Joined
Mar 6, 2006
Messages
1,288
I think I caught the AI cheating.

This was in a way that ... actually, probably hurt it. :-)

It defended a square that had a mine on a hill that, later in the game, would have coal on it. But at the time, nobody in the entire world had steam power, so nobody could see the coal at the time.

As the AI didn't have access to coal, the unit was in effect exposed for no good reason. I just ignored it and passed by it to take the city (confused, at the time, and later figured it out when I got steam power).

I'm going to look into it (it seems like a relatively simple problem) -- but does anyone else have examples of the AI cheating? In either ways that help or hinder it. :)
 
If you have a save, check to see if the AI unit was running MISSIONAI_GUARD_BONUS. I just took a peak at the code, it shouldn't be defending resources it hasn't discovered yet since it's using pLoopPlot->getNonObsoleteBonusType(getTeam()) in CvUnitAI::AI_guardBonus ... the AI may also use this MISSIONAI for camping on forts, but that doesn't apply in this case.

I've seen units sit in a position for seemingly no reason as well, my guess has been that their waiting for someone to join them ... haven't been able to figure that out yet. This might be what you're seeing.

One other example where the AI does cheat is in checking power rankings, it's not constrained by espionage levels. My feeling is that's acceptable however.
 
*nod*, I just checked.

Line 9550 of CvUnitAI.cpp:
Code:
						if (NO_BONUS != pLoopPlot->getBonusType())
						{
							iValue += GET_PLAYER(eTargetPlayer).AI_bonusVal(pLoopPlot->getBonusType()) - 10;
						}
cheats. (paradrop code?)

AI_betterPlotBuild, AI_nukeRange, AI_calculatePlotWorkersNeeded, AI_workerSeaMove also cheat.

Sadly, I seem to be wrong about my OP: the AI defender allocation code doesn't seem to cheat.

(Bah, I was reading the standard CvUnitAI source, not the 0.3 or 0.35 versions. Checking... no changes in 0.35...)

...

As an aside, compare the values of resources in AI_targetCityValue to AI_cityTradeVal.

Target cities are worth 1 per population, times (0.5 to 1.5) based on the player's culture. Possibly a random factor of (0 to 0.5) times population is added.

Bonus values are 1/10 the value stored in the target city code, capped at 4 and 1 respectively.

Holy cities are worth +2 (I think that might be undervalued? We should look at the spread of that religion, really).

Trade cities are worth 200 points per population, times the percentage culture.

Bonuses are worth 10 times the AI bonus val of the bonus.

So ... the two are relatively close. :-)

...

Also somewhat randomly:
Code:
	if (isAnimal())
	{
		if (pPlot->isOwned())
		{
			return false;
		}

		if (!bAttack)
		{
			if (pPlot->getBonusType() != NO_BONUS)
			{
				return false;
			}
Animals cannot move into any square that has a bonus from any era, unless they are attacking. I guess that way the Tigers don't eat the Deer!

(I decided to look into all calls to getBonusType() while I was looking for unit guarding exploits.)
 
*nod*, I just checked.

Line 9550 of CvUnitAI.cpp:
Code:
						if (NO_BONUS != pLoopPlot->getBonusType())
						{
							iValue += GET_PLAYER(eTargetPlayer).AI_bonusVal(pLoopPlot->getBonusType()) - 10;
						}
cheats. (paradrop code?)

AI_betterPlotBuild, AI_nukeRange, AI_calculatePlotWorkersNeeded, AI_workerSeaMove also cheat.

Sadly, I seem to be wrong about my OP: the AI defender allocation code doesn't seem to cheat.

(Bah, I was reading the standard CvUnitAI source, not the 0.3 or 0.35 versions. Checking... no changes in 0.35...)

...

(I decided to look into all calls to getBonusType() while I was looking for unit guarding exploits.)

Some of those aren't so much cheats as little bugs ... no need to double the number of workers now in a plot that will someday have oil. It doesn't seem to really benefit from them.
 
Yes, most of them are cheat-bugs, where the AI uses knowledge it shouldn't have to be dumb about things. :-)
 
Back
Top Bottom