Afforess
The White Wizard
Code Proposal:
This code forces the AI to look at adjacent tiles the settler can move to without using up all of its moves. So if the AI starts in a spot with a better spot directly next to it, the settler will move to the better spot and then found a city.
Code:
void CvUnitAI::AI_settleMove()
{
PROFILE_FUNC();
if (GET_PLAYER(getOwnerINLINE()).getNumCities() == 0)
{
/************************************************************************************************/
/* Afforess Start 08/26/10 */
/* */
/* Check Adjacent Tiles for Better Spot */
/************************************************************************************************/
if (!hasMoved() && canMove())
{
//Force Recalculation
plot()->setFoundValue(getOwnerINLINE(), -1);
for (int iPlot = 0; iPlot < NUM_DIRECTION_TYPES; iPlot++)
{
CvPlot* pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iPlot));
if (pAdjacentPlot != NULL)
{
pAdjacentPlot->setFoundValue(getOwnerINLINE(), -1);
}
}
int iCurrentValue = plot()->getFoundValue(getOwnerINLINE());
CvPlot* pBestPlot = NULL;
for (int iPlot = 0; iPlot < NUM_DIRECTION_TYPES; iPlot++)
{
CvPlot* pAdjacentPlot = plotDirection(getX_INLINE(), getY_INLINE(), ((DirectionTypes)iPlot));
if (pAdjacentPlot != NULL)
{
int iPlotValue = pAdjacentPlot->getFoundValue(getOwnerINLINE());
iPlotValue *= GC.getMOVE_DENOMINATOR();
iPlotValue /= pAdjacentPlot->movementCost(this, plot());
if (iPlotValue > iCurrentValue)
{
iCurrentValue = iPlotValue;
pBestPlot = pAdjacentPlot;
}
}
}
if (pBestPlot != NULL)
{
getGroup()->pushMission(MISSION_MOVE_TO, pBestPlot->getX_INLINE(), pBestPlot->getY_INLINE(), MOVE_SAFE_TERRITORY, false, false, MISSIONAI_FOUND, pBestPlot);
return;
}
}
/************************************************************************************************/
/* Afforess END */
/************************************************************************************************/
...
This code forces the AI to look at adjacent tiles the settler can move to without using up all of its moves. So if the AI starts in a spot with a better spot directly next to it, the settler will move to the better spot and then found a city.