Bazaar developer reference

CvEconomicAI::ScoreExplorePlot(CvPlot *, TeamTypes, int, DomainTypes)

Defined in
CvEconomicAI.cpp, line 1012
Class
CvEconomicAI
Hook name
CivHooks::CvEconomicAI_ScoreExplorePlot

Hooks

static bool BeforeCvEconomicAI_ScoreExplorePlot(CvPlot* pPlot, TeamTypes eTeam, int iRange, DomainTypes eDomainType, int& result);static void AfterCvEconomicAI_ScoreExplorePlot(CvPlot* pPlot, TeamTypes eTeam, int iRange, DomainTypes eDomainType, int& result);static int ReplaceCvEconomicAI_ScoreExplorePlot(int (*original)(CvPlot*, TeamTypes, int, DomainTypes), CvPlot* pPlot, TeamTypes eTeam, int iRange, DomainTypes eDomainType);CivRegisterBefore<CivHooks::CvEconomicAI_ScoreExplorePlot>(host, &BeforeCvEconomicAI_ScoreExplorePlot);CivRegisterAfter<CivHooks::CvEconomicAI_ScoreExplorePlot>(host, &AfterCvEconomicAI_ScoreExplorePlot);CivRegisterReplace<CivHooks::CvEconomicAI_ScoreExplorePlot>(host, &ReplaceCvEconomicAI_ScoreExplorePlot);

Code

1012int CvEconomicAI::ScoreExplorePlot(CvPlot* pPlot, TeamTypes eTeam, int iRange, DomainTypes eDomainType)1013{1014	int iResultValue = 0;1015	int iAdjacencyBonus = 1;1016	int iBadScore = 10;1017	int iGoodScore = 100;1018	int iReallyGoodScore = 200;1019	//int iGoodyHutScore = 100000;10201021	int iPlotX = pPlot->getX();1022	int iPlotY = pPlot->getY();10231024	FAssertMsg(pPlot->isRevealed(eTeam), "Plot isn't revealed. This isn't good.");1025	CvPlot* pEvalPlot = NULL;1026	for(int iX = -iRange; iX <= iRange; iX++)1027	{1028		for(int iY = -iRange; iY <= iRange; iY++)1029		{1030			pEvalPlot = plotXYWithRangeCheck(iPlotX, iPlotY, iX, iY, iRange);1031			if(!pEvalPlot)1032			{1033				continue;1034			}10351036			if(pEvalPlot == pPlot)1037			{1038				continue;1039			}10401041			if(pEvalPlot->isRevealed(eTeam))1042			{1043				continue;1044			}10451046			if(pEvalPlot->isAdjacentRevealed(eTeam))1047			{1048				if(plotDistance(iPlotX, iPlotY, pEvalPlot->getX(), pEvalPlot->getY()) > 1)1049				{1050					CvPlot* pAdjacentPlot;1051					bool bViewBlocked = true;1052					for(int i = 0; i < NUM_DIRECTION_TYPES; ++i)1053					{1054						pAdjacentPlot = plotDirection(pEvalPlot->getX(), pEvalPlot->getY(), ((DirectionTypes)i));1055						if(pAdjacentPlot != NULL)1056						{1057							if(pAdjacentPlot->isRevealed(eTeam))1058							{1059								int iDistance = plotDistance(iPlotX, iPlotY, pAdjacentPlot->getX(), pAdjacentPlot->getY());1060								if(iDistance > iRange)1061								{1062									continue;1063								}10641065								// this cheats, because we can't be sure that between the target and the viewer1066								if(pPlot->canSeePlot(pEvalPlot, eTeam, iRange, NO_DIRECTION))1067								{1068									bViewBlocked = false;1069								}10701071								if(!bViewBlocked)1072								{1073									break;1074								}1075							}1076						}1077					}10781079					if(bViewBlocked)1080					{1081						continue;1082					}1083				}10841085				// "cheating" to look to see what the next tile is.1086				// a human should be able to do this by looking at the transition from the tile to the next1087				switch(eDomainType)1088				{1089				case DOMAIN_SEA:1090				{1091					FeatureTypes eFeature = pEvalPlot->getFeatureType();1092					if(pEvalPlot->isWater() || (eFeature != NO_FEATURE && GC.getFeatureInfo(eFeature)->isImpassable()))1093					{1094						iResultValue += iBadScore;1095					}1096					else if(pEvalPlot->isMountain() || pEvalPlot->isHills() || (eFeature != NO_FEATURE && GC.getFeatureInfo(eFeature)->getSeeThroughChange() > 0))1097					{1098						iResultValue += iGoodScore;1099					}1100					else1101					{1102						iResultValue += iReallyGoodScore;1103					}1104				}1105				break;1106				case DOMAIN_LAND:1107					if(pEvalPlot->isMountain() || pEvalPlot->isWater())1108					{1109						iResultValue += iBadScore;1110					}1111					else if(pEvalPlot->isHills())1112					{1113						iResultValue += iReallyGoodScore;1114					}1115					else1116					{1117						iResultValue += iGoodScore;1118					}1119					break;1120				}1121			}1122			else1123			{1124				iResultValue += iGoodScore;1125			}11261127			int iDistance = plotDistance(iPlotX, iPlotY, pEvalPlot->getX(), pEvalPlot->getY());1128			iResultValue += (iRange - iDistance) * iAdjacencyBonus;1129		}1130	}11311132	return iResultValue;1133}

Calls

Called by