OrionVeteran
Deity
I'm developing code to send a unit to a coastal city. This coastal city must have a harbor and trade routes established. There could be several coastal cities that might qualify. What I want to do is pick the best city, meaning a coastal city that is not surrounded by ice that could block its path to more than one other coastal city. How can I identify a coastal city that has access to multiple other coastal cities (that belong to my empire) and select that city over the city whose path is blocked by ice?
Here is what I have so far.
Here is what I have so far.
Spoiler :
Code:
def doNTIPlacementAI(pUnit):
# Orion's Combined Forces Mod
# Sends NTI unit to a city where the AI can build a Fleet
iOwner = pUnit.getOwner()
AIpPlayer = gc.getPlayer(iOwner)
iHarbor = gc.getInfoTypeForString("BUILDING_HARBOR"):
AICan = False
#CyInterface().addImmediateMessage("A", "")
for iCity in range(AIpPlayer.getNumCities()):
pCity = AIpPlayer.getCity(iCity)
# Is this a coastal city?
if pCity.isCoastal():
# Does the city have a harbor?
if pCity.isHasBuilding(iHarbor):
HarborInfo = gc.getBuildingInfo(iHarbor)
if HarborInfo.getCoastalTradeRoutes() > 0:
#Send unit to pCity