Jeckel
Great Reverend
Flat movement makes all tiles cost the same to move across, so if you have 3 movement you can move 3 squares regardless of forest and roads in the tiles.
I have to agree that limiting the number of railroads per group of tiles isn't very practical.
Here is the current code I'm working on. I have added a new building and improvement, both Railway Stations.
Basicly, if the build is not a railroad it is ignored by this code.
If the plot is inside a city's workable radius or if it is a resource then a railroad can be built there.
If those cases aren't valid then it will go through the 8 surrounding plots and determine if they are blocked. Plots are blocked if they don't have a city or Railway Station and have a railroad.
Then the last part of the code checks the block status of the loopplots and determines if a railroad can be built. My goal is to keep railroads from connecting to multiple other tiles.
This stops railroad spawl from covering the map, but allows all the functionality that railroads offer and the astetics of more railroad sprawl just around cities.
I've tested it a little bit and from a player perspective it works as I thought it would, but the AI seems to ignore the building of roads in tiles that can't have railroads. I may not have run the test game long enough or may have been a fluke, but just somthing I noticed.
Any ideas, suggestions?
I have to agree that limiting the number of railroads per group of tiles isn't very practical.
Here is the current code I'm working on. I have added a new building and improvement, both Railway Stations.
Code:
def canBuild(self,argsList):
iX, iY, iBuild, iPlayer = argsList
# < JRailroad Start / >
iRailroadBuild = gc.getInfoTypeForString("BUILD_RAILROAD")
if (iBuild != iRailroadBuild):
return -1
oMap = CyMap()
pPlot = oMap.plot(iX, iY)
if (pPlot.isCityRadius()):
return -1
if (pPlot.getBonusType(iPlayer) != -1):
return -1
dSquare = {"NORTH": (0, 1), "SOUTH": (0, -1),
"EAST": (1, 0), "WEST": (-1, 0),
"NORTHEAST": (1, 1), "NORTHWEST": (-1, 1),
"SOUTHEAST": (1, -1), "SOUTHWEST": (-1, -1)}
dBlock = {}
iRailroadRoute = gc.getInfoTypeForString("ROUTE_RAILROAD")
iRailroadStation = gc.getInfoTypeForString("IMPROVEMENT_RAILWAY_STATION")
bBlock = True
for sDir in dSquare.keys():
bBlock = True
tDir = dSquare[sDir]
pDirPlot = oMap.plot(iX + tDir[0], iY + tDir[1])
#alert.debug(0, "sDir", sDir)
#alert.debug(0, "pDirPlot.getRouteType() != iRailroadRoute", pDirPlot.getRouteType() != iRailroadRoute)
if (pDirPlot.isCity()):
bBlock = False
elif (pDirPlot.getImprovementType() == iRailroadStation):
bBlock = False
elif (pDirPlot.getRouteType() != iRailroadRoute):
bBlock = False
dBlock[sDir] = bBlock
#alert.debug(0, "dBlock", dBlock)
bN = dBlock["NORTH"]
bS = dBlock["SOUTH"]
bE = dBlock["EAST"]
bW = dBlock["WEST"]
bNE = dBlock["NORTHEAST"]
bNW = dBlock["NORTHWEST"]
bSE = dBlock["SOUTHEAST"]
bSW = dBlock["SOUTHWEST"]
if ((bN) and (bNE or bNW)) or (bS and (bSE or bSW)) or (bE and (bNE or bSE)) or (bW and (bNW or bSW)) \
or (bN and (bE or bW)) or (bS and (bE or bW)):
return 0
# < JRailroad End / >
return -1 # Returning -1 means ignore; 0 means Build cannot be performed; 1 or greater means it can
If the plot is inside a city's workable radius or if it is a resource then a railroad can be built there.
If those cases aren't valid then it will go through the 8 surrounding plots and determine if they are blocked. Plots are blocked if they don't have a city or Railway Station and have a railroad.
Then the last part of the code checks the block status of the loopplots and determines if a railroad can be built. My goal is to keep railroads from connecting to multiple other tiles.
This stops railroad spawl from covering the map, but allows all the functionality that railroads offer and the astetics of more railroad sprawl just around cities.
I've tested it a little bit and from a player perspective it works as I thought it would, but the AI seems to ignore the building of roads in tiles that can't have railroads. I may not have run the test game long enough or may have been a fluke, but just somthing I noticed.
Any ideas, suggestions?