Report Questionable AI Behavior

No; we've only been talking about AI code; nothing discussed here alters the way the game works.

Anyway; lakes aren't counted as coastal area's. I haven't altered lakes behavior; that's the way BTS works.
 
Os79, I looked into your save, and it seems that there was a myriad of factors that led to the AI's weakness:

  • The AI miscounted the number of workers it had, so the cities would not build enough for the empire
  • The Barbarians were receiving too many free techs, giving them advanced units early, which was corrected in patch B.
  • You are playing on Warlord difficulty, which slows AI production and research down. Try Noble or Prince.

But really, the lack of workers pretty much crushed the AI, and it's a bit late for them to get in the game. I've since fixed that issue, and it will be in Patch C.
 
Os79, I looked into your save, and it seems that there was a myriad of factors that led to the AI's weakness:

  • The AI miscounted the number of workers it had, so the cities would not build enough for the empire
  • The Barbarians were receiving too many free techs, giving them advanced units early, which was corrected in patch B.
  • You are playing on Warlord difficulty, which slows AI production and research down. Try Noble or Prince.

But really, the lack of workers pretty much crushed the AI, and it's a bit late for them to get in the game. I've since fixed that issue, and it will be in Patch C.

Great :). Looking forward to better game in Patch C.
Thanks!
 
NBAFan, I checked out Henry VII's Missionary Spamming, and it seems fairly sensible to me. He's heading for a Religious Victory, so he is building one missionary per city on the continent; except he is building them a bit too quickly and doesn't have all the city sites explored that he needs to spread to, so they are getting stuck. Basically, he needs more explorers, which I will tweak.
 
New game in 1.74B:

#1 About starting difficulty; I still have maximum at Noble but I now start with Noble instead of Settler.

#2 About Patch B fix for barbarians, cool :).

#3 Looking forward to Patch C fix for workers calculating.

Anyway, I'm now playing a nice game. Better than before. I have three cities and AIs also have three. They are not struggling with barbarians, apparently. Now I suspect only thing left holding them back is worker miscalculations that will be fixed in the next patch.

Anyway, here is my savegame for the new game so you can analyze it even more if needed. Same setup as before (remember to delete or remove Warlord).
 
NBAFan, I checked out Henry VII's Missionary Spamming, and it seems fairly sensible to me. He's heading for a Religious Victory, so he is building one missionary per city on the continent; except he is building them a bit too quickly and doesn't have all the city sites explored that he needs to spread to, so they are getting stuck. Basically, he needs more explorers, which I will tweak.
Alright, looks like he needs to be told he can't win just yet.:trouble:
 
Ai can be trapped on bad squares where it is surrounded and destroyed if you open a way to your on purpose undefended city...

Spoiler :
attachment.php


Later, if you established a good defensive position with units in your city AI comes in "stacks" of one archer, acting as a scout as I suppose... It's pretty easy to trap it on a square with high %, get some (small) xp and then AI will send another after a few turns and so on...
 

Attachments

  • Civ4ScreenShot0123.JPG
    Civ4ScreenShot0123.JPG
    188.6 KB · Views: 418
Hmm, I would say the bigger problem is that the AI tries to go to war way to early. I suspect it's an unintended side-effect of the new better AI victory AI. I'm going to try to make the AI not plan wars if there is still a decent amount of land left to expand into.
 
Hmm, I would say the bigger problem is that the AI tries to go to war way to early. I suspect it's an unintended side-effect of the new better AI victory AI. I'm going to try to make the AI not plan wars if there is still a decent amount of land left to expand into.
The AI does seem to like war in the early game.
 
dunno if it's irrational (I actually agree with the AI) but nobody is building the Olympic Games, when all other wonders get snagged up instantly (best demonstrated in a team with an AI)

the -90% Military Production is just way too harsh, even a city going for a culture win will ignore that
 
if one wants to play optimally he'll produce all military units in a single city with all the GGs settled there. following this most cities of good player will not produce any military units ever. thus the -90% production penalty is ignorable. AI is too stupid to understand this strategy thus it's ok it doesn't build it (it would produce military in the olympic city).
 
dunno if it's irrational (I actually agree with the AI) but nobody is building the Olympic Games, when all other wonders get snagged up instantly (best demonstrated in a team with an AI)

the -90% Military Production is just way too harsh, even a city going for a culture win will ignore that

IMO, the Modern Olympic Games should based on the World's Fair concept, and move from different major cities every so often. As for abilities, I am fine with how the Modern Olympic Games are.
 
  • The AI miscounted the number of workers it had, so the cities would not build enough for the empire
  • The Barbarians were receiving too many free techs, giving them advanced units early, which was corrected in patch B.

But really, the lack of workers pretty much crushed the AI, and it's a bit late for them to get in the game. I've since fixed that issue, and it will be in Patch C.
If fixes to those two problems are in the svn already, I couldn't find them. If they are so AND-specific that I simply failed to recognize them, nvm. If they these problems can/do happen in the unmodded/UP/Better AI game too, please point the fixes out to me, I find them out myself.
 
If fixes to those two problems are in the svn already, I couldn't find them. If they are so AND-specific that I simply failed to recognize them, nvm. If they these problems can/do happen in the unmodded/UP/Better AI game too, please point the fixes out to me, I find them out myself.

The Barbarian thing was just tweaking a global define value. The Worker problem fix is here:
Code:
/************************************************************************************************/
/* Afforess	                  Start		 07/26/10                                               */
/*                                                                                              */
/* Better AI: This is a terrible way of counting workers, too many false positives              */
/************************************************************************************************/
/*
				iWorkersHave += (GET_PLAYER(getOwnerINLINE()).AI_plotTargetMissionAIs(pLoopPlot, MISSIONAI_BUILD));
				
				iWorkersHave += pLoopPlot->plotCount(PUF_isUnitAIType, UNITAI_WORKER, -1, getOwner(), getTeam(), PUF_isNoMission, -1, -1);
*/
				iWorkersHave += pLoopPlot->plotCount(PUF_isUnitAIType, UNITAI_WORKER, -1, getOwner(), getTeam(), NULL, -1, -1);
/************************************************************************************************/
/* Afforess	                     END                                                            */
/************************************************************************************************/

Which is in void CvCityAI::AI_updateWorkersNeededHere(). Anyway, I found that the cities would think they had more workers than the empire had even built in the first place. I think AI_plotTargetMissionAIs was not return correct values. Anyway, counting workers that are trying to get to the city, but aren't there already is a bit strange, since there is no guarantee that they will eventually arrive, they may find a better target. The AI is better at just using the present, not the future.
 
I found that the cities would think they had more workers than the empire had even built in the first place. I think AI_plotTargetMissionAIs was not return correct values. Anyway, counting workers that are trying to get to the city, but aren't there already is a bit strange, since there is no guarantee that they will eventually arrive, they may find a better target. The AI is better at just using the present, not the future.
Looking into the future, at least a bit, is quite essential imo, so unless the workers are really far away on a different continent, they should probably be counted.

If AI_plotTargetMissionAIs is broken then the problem might be bigger than just AI_updateWorkersNeededHere, it's used quite often in a lot of places. Do you have any idea why it would return bogus values? I tried looking but couldn't find any flaws. As long as there are no military units grouping with workers (which doesn't happen afaik), there should be no problems.
 
If AI_plotTargetMissionAIs is broken then the problem might be bigger than just AI_updateWorkersNeededHere, it's used quite often in a lot of places. Do you have any idea why it would return bogus values? I tried looking but couldn't find any flaws. As long as there are no military units grouping with workers (which doesn't happen afaik), there should be no problems.

I migh tbe able to go back and find the save where I noticed the bug, but basically, a city surrounded by a jungle reporting have a worker, when it had none. The empire only had 1 worker for the three cities, and it was close to 25 tiles away, working. When I changed that code, the city corrected itself, and it reported the number of workers correctly...

I'll try to reproduce it in Better Bug AI this weekend.
 
3 cities in the empire but a distance of 25 tiles? Normally the AI settles a bit closer.
If the worker is building something, the missionAIPlot is the plot it is standing on, unless the worker is building roads to the other city - in that case, that target plot is a tile of the other city. In that case, the city where the worker is now should report WorkersHave 0.

For now I'll leave this in the code, maybe I can get that Assertmsg to show up. Though I hope not.
Code:
[COLOR="Gray"]void CvPlayer::doTurn()

(...)

	for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		pLoopCity->doTurn();
	}[/COLOR]

[COLOR="Green"]//Fuyu WorkersHave check[/COLOR]
#ifdef _DEBUG
	int iTotalWorkersHave = 0;
	int iTotalWorkersFinishedSoon = 0;
	int iNumWorkerAIUnits = AI_getNumAIUnits(UNITAI_WORKER);

	for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		iTotalWorkersHave += pLoopCity->AI_getWorkersHave();

		[COLOR="Green"]//From AI_updateWorkersNeededHere[/COLOR]
		if (pLoopCity->getProductionUnit() != NO_UNIT)
		{
			if (pLoopCity->getProductionUnitAI() == UNITAI_WORKER)
			{
				if (pLoopCity->getProductionTurnsLeft() <= 2)
				{
					iTotalWorkersFinishedSoon++;
				}
			}
		}
	}

	FAssertMsg(iTotalWorkersHave <= (iNumWorkerAIUnits + iTotalWorkersFinishedSoon), "Player has less workers than he thinks he has");
#endif
[COLOR="Green"]//Fuyu WorkersHave check - END[/COLOR]

-

Yet another question: Isn't this fix in CvUnitAI::AI_groupMergeRange relevant for Better BTS AI forums? AI_groupMergeRange(UNITAI_SETTLE, bla) is only called twice in the SDK, in both cases it's from jdog.
Code:
if (eUnitAI == UNITAI_SETTLE) return false; [COLOR="Green"]//Fixes a Waiting For Civilizations Bug.[/COLOR]
 
3 cities in the empire but a distance of 25 tiles? Normally the AI settles a bit closer.
If the worker is building something, the missionAIPlot is the plot it is standing on, unless the worker is building roads to the other city - in that case, that target plot is a tile of the other city. In that case, the city where the worker is now should report WorkersHave 0.

For now I'll leave this in the code, maybe I can get that Assertmsg to show up. Though I hope not.
Code:
[COLOR="Gray"]void CvPlayer::doTurn()

(...)

	for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		pLoopCity->doTurn();
	}[/COLOR]

[COLOR="Green"]//Fuyu WorkersHave check[/COLOR]
#ifdef _DEBUG
	int iTotalWorkersHave = 0;
	int iTotalWorkersFinishedSoon = 0;
	int iNumWorkerAIUnits = AI_getNumAIUnits(UNITAI_WORKER);

	for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
	{
		iTotalWorkersHave += pLoopCity->AI_getWorkersHave();

		[COLOR="Green"]//From AI_updateWorkersNeededHere[/COLOR]
		if (pLoopCity->getProductionUnit() != NO_UNIT)
		{
			if (pLoopCity->getProductionUnitAI() == UNITAI_WORKER)
			{
				if (pLoopCity->getProductionTurnsLeft() <= 2)
				{
					iTotalWorkersFinishedSoon++;
				}
			}
		}
	}

	FAssertMsg(iTotalWorkersHave <= (iNumWorkerAIUnits + iTotalWorkersFinishedSoon), "Player has less workers than he thinks he has");
#endif
[COLOR="Green"]//Fuyu WorkersHave check - END[/COLOR]

-

Okay, I'm going to add that too and see what happens.

Yet another question: Isn't this fix in CvUnitAI::AI_groupMergeRange relevant for Better BTS AI forums? AI_groupMergeRange(UNITAI_SETTLE, bla) is only called twice in the SDK, in both cases it's from jdog.
Code:
if (eUnitAI == UNITAI_SETTLE) return false; [COLOR="Green"]//Fixes a Waiting For Civilizations Bug.[/COLOR]

Yeah, honestly, I have no idea why it causes loops, but it does. I found that calling AI_group and AI_groupMergeRange with certain UnitAI's lead to infinite loops. (UNITAI_CITY_DEFENSE seems to cause an infinite loop too). Perhaps they weren't built quite right, IDK. I simply lack the knowledge to fix them.
 
Units running cityUnitAIs (city defence, city special, city counter, reserve) are always moving alone so I'm not surprised gouping them could lead to issues but AI_group(UNITAI_SETTLE, ...) is known to work, this is how settlers are escorted to the next city site.
 
It might be. A quick question, if a unit is escorting a settler, what unitAI is it? UNITAI_SETTLE? UNITAI_CITY_DEFENSE?
 
Back
Top Bottom