Realistic Railroads- how?

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.
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
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 think that the best way to go is not to block the creation of railroads but rather to make roads more valuable in the late game, and both the player and the AI will get rid of railroads where they aren't needed. To do this also there needs to be a change in the way roads and railroads are built. Railroads are treated as just better roads and so if you build a railroad, you can't replace it with a road like you can tear down a Town and replace it with a Workshop or vise versa.
 
Well, other then removing the movement bonus from railroads, I don't see how to make them less valuable. What whare you thinking along that front?

Good news is it is easy to make roads buildable ontop of railroads.
Code:
	def canBuild(self,argsList):
		iX, iY, iBuild, iPlayer = argsList
		# < JRailroad Start / >
		iBuildRoad = gc.getInfoTypeForString("BUILD_ROAD")
		if (iBuild == iBuildRoad):
                        oMap = CyMap()
                        pPlot = oMap.plot(iX, iY)
                        if (pPlot.getRouteType() == gc.getInfoTypeForString("ROUTE_RAILROAD")):
                                return 1
                return -1
 
Well it may be not a great idea. But how do units use railroads to move faster? Do the workers have some sort of shoes that make them move by rail. The point I am trying to make is.

Why not require a train to move the units along rails and when you have a rail the other units besides trains move slower. Just an idea I have no idea what code would be needed.

Basically if you place a rail on the land then you are losing something. Railroads are only beneficial to trains.

Edit: Sorry just noticed this.

http://forums.civfanatics.com/showthread.php?t=255718
 
In my test mod I already have a train unit that is restricted to railroads, but the problem is restricting them to rails doesn't really mader if railroads can be built everywhere.
 
Yes but do railroads receive the same movement rate for regular units?

I mean make railroads worse than roads. I am saying like make rails count as jungles for movement. Do the workers still build them?
 
No, I removed the bonus movement for railroads. In RouteInfo.xml just set iMovement and iFlatMovement to a really high number.
 
Why not just add some penalty for railroads? -1gpt would take away the fun of having a railroad to anything that doesn't need that extra travel. -2 if you really don't want it there. I would definitely use them less if I had to pay 2g every turn for each RR tile. Or per 10, or whatever.
 
I like the idea of only having railroads between cities. this way, if the cost of movement along railroads is reduced greatly, they can be used as a kind of high capacity local airlift, moving units to cities near where they are needed and then left to use roads for the remainder.
A way to get round not having railroads for improvements is to have a second improvement, say "Mine with railroad", that can be built on top of mines etc. which have the bonus included. This can be implemented as an extra improvement for each imp. that gains from railroads rather than a route type.
I think a train unit will require too much micromanagement
 
Well, one way you can make roads more desirable than railroads is to give them some special bonus... for instance: +1 Commerce on Cottage, Hamlet, Village, Town, etc. People would only build railroads sparingly then because they wouldn't want to lose the commerce boost. That would also basically ensure that most of the tiles around a city would be railroad-free.

And, as I said, improving roads with technology/resources would make them more valuable later in the game and thus keep them competitive vs. railroads.

I think that railroads should also give a base movement to any units using it. So for example, if it gives 1/8 movement cost, that means that ANY unit would go exactly 8 tiles on a railroad. It could have 2 MP or 10 MP.. wouldn't matter because as someone pointed out, it's the train moving the units not the units moving under their own power.

I'm loathe to the creation of train units however because it would be just simply way too much micromanagement.
 
If you alter yield modifiers for improvements based on routes the AI (including automated workers) will understand it too, which is a plus. However, the AI would need some tweaking to pay attention since it was obviously written with the intention of railroads being better than roads. But that won't result in nicely connected railways, just scattered tiles with tracks on them where it was beneficial and roads otherwise.
 
If you alter yield modifiers for improvements based on routes the AI (including automated workers) will understand it too, which is a plus. However, the AI would need some tweaking to pay attention since it was obviously written with the intention of railroads being better than roads. But that won't result in nicely connected railways, just scattered tiles with tracks on them where it was beneficial and roads otherwise.

I'm not sure if I agree with that. I think if you extend the road bonus to a one improvement (or one set of improvements such as the cottage, hamlet, village, town set), you'll see roads remaining on some tiles around cities and railroads everywhere else including (and perhaps especially) between cities.
 
Except that the AI won't build roads everywhere until they have nothing else to do unless it's connecting part of the trade route regardless of any bonus assigned to having a road. Late in the game the AI will not build roads if it can build railroads, you'll have to edit the AI to change that behavior. And then there is the AI's habit of constantly changing tile improvements to deal with, what is a farm this turn may not be a farm next turn.
 
Except that the AI won't build roads everywhere until they have nothing else to do unless it's connecting part of the trade route regardless of any bonus assigned to having a road. Late in the game the AI will not build roads if it can build railroads, you'll have to edit the AI to change that behavior. And then there is the AI's habit of constantly changing tile improvements to deal with, what is a farm this turn may not be a farm next turn.

Agreed. I'm not opposed to SDK work to make this more practical. What I'm concerned about is the idea of placing a hard cap on the number of adjacent railroaded tiles. The solution to me is not a hard cap, but rather some benefits to roads (and possibly penalties to railroads) that would keep the map from becoming exclusively railroads.
 
Back
Top Bottom