I'm trying to address some annoying ai issues, namely:
i) A computer based somewhere in the middle of the map sends an army to attack a barbarian city on the Arctic/Antarctic coastline. This city will never grow above size 2or contribute anything meaningful, so it just wastes resources and lots of maintenance to keep it. Occasionally there is a strategic resource (in which case I'll let it off), but often there isn't. Visa versa, you get computers near the poles trying to capture a desert city near the equator.
ii) Computer 1 attacks computer 2, takes a city and makes him a vassal, this city is miles away from computer 1's main area and gets dwarfed in culture, it then revolts back to the original owners and starts the war up again. I've seen this repeating in endless cycles, which means a would be powerful computer wastes the entire game just fighting one other civilization, over and over again.
So my questions are:
1) How can I tell the computer to trade away, free as a colony or even gift cities that are a long way from it's main borders and of no strategic value?
2) Once a computer has vassalled another empire, get it to liberate any useless captured cities back to the vassal (rather than having them repeatedly revolt)?
At the moment I've being trying to put some code into 'void setVassal' within CvTeam, but I'm still on a rather steep learning curve and am probably commiting some obvious errors! To start with I'm just trying to do a simple distance check. I know the code is incomplete to do the above, but I'm just trying to get the simplest bit into the DLL to start with (note obviously brackets out of position in the spoiler!):
When compiling the DLL it's telling me things like 'plotDistance' : is not a member of 'CvCity' and 'getY_INLINE': identifier not found, even with argument-dependent lookup.
In any case, is this the best way for me to achieve what I've listed above or is there a better way? I still can't see in the code where the ai evaluates whether or not it should liberate a city or gift it (does it do this at all in the default code?).
All guidance welcome!
i) A computer based somewhere in the middle of the map sends an army to attack a barbarian city on the Arctic/Antarctic coastline. This city will never grow above size 2or contribute anything meaningful, so it just wastes resources and lots of maintenance to keep it. Occasionally there is a strategic resource (in which case I'll let it off), but often there isn't. Visa versa, you get computers near the poles trying to capture a desert city near the equator.
ii) Computer 1 attacks computer 2, takes a city and makes him a vassal, this city is miles away from computer 1's main area and gets dwarfed in culture, it then revolts back to the original owners and starts the war up again. I've seen this repeating in endless cycles, which means a would be powerful computer wastes the entire game just fighting one other civilization, over and over again.
So my questions are:
1) How can I tell the computer to trade away, free as a colony or even gift cities that are a long way from it's main borders and of no strategic value?
2) Once a computer has vassalled another empire, get it to liberate any useless captured cities back to the vassal (rather than having them repeatedly revolt)?
At the moment I've being trying to put some code into 'void setVassal' within CvTeam, but I'm still on a rather steep learning curve and am probably commiting some obvious errors! To start with I'm just trying to do a simple distance check. I know the code is incomplete to do the above, but I'm just trying to get the simplest bit into the DLL to start with (note obviously brackets out of position in the spoiler!):
Spoiler :
CvCity* pLoopCity;
int iI;
int iLoop;
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (!isHuman())
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
{
if (plotDistance(pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE(), pCapital->getX_INLINE(), pCapital->getY_INLINE()) / GC.getMapINLINE().maxPlotDistance() * 100 > 30)
{
pCity.liberate(false);
}
}
}
}
}
int iI;
int iLoop;
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (!isHuman())
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
{
if (plotDistance(pLoopCity->getX_INLINE(), pLoopCity->getY_INLINE(), pCapital->getX_INLINE(), pCapital->getY_INLINE()) / GC.getMapINLINE().maxPlotDistance() * 100 > 30)
{
pCity.liberate(false);
}
}
}
}
}
When compiling the DLL it's telling me things like 'plotDistance' : is not a member of 'CvCity' and 'getY_INLINE': identifier not found, even with argument-dependent lookup.
In any case, is this the best way for me to achieve what I've listed above or is there a better way? I still can't see in the code where the ai evaluates whether or not it should liberate a city or gift it (does it do this at all in the default code?).
All guidance welcome!