Is it possible to move a city one square with the help of Python?

Pumabear

Chieftain
Joined
Oct 25, 2004
Messages
62
Just noticed that I, by mistake, built one of my cities on the wrong square. Extremely annoying. I won't load an earlier save because it was over 200 turns ago I built the city. Is it possible to move the entire city one square with the help of python?
 
No. The DLL has no ability to set (x,y) other than with reset and load savegame. If the DLL can't do it, then there is nothing for python to call in the DLL to do it, so I didn't bother to look through the list of options presented to python.

In theory it can be coded into the DLL, but it's not trivial to do so as there is more to it than just setting which plot the city is on. For starters the plot itself needs to know which city is on it and there could be more data to set up to make it work correctly.
 
You could delete the city, place a new one and give it all the characteristics of the old city. I think WorldBuilder should be able to handle the bulk of this task. Laborious and error-prone though, and probably won't get the tile culture values and some details right through WB. Python could help with that (still laborious, or all the more so). CvPlayer::acquireCity in the DLL could be a guide for all the data that may need to be copied when recreating a city. (Just as cities can't change their location, they also can't change their owner, so the DLL deletes the old city and creates a new one when a city gets conquered, flipped or traded.)
 
Just as cities can't change their location, they also can't change their owner, so the DLL deletes the old city and creates a new one when a city gets conquered, flipped or traded.
Doesn't this mean that the city can be recreated somewhere else?
 
The copying of a city isn't in a separate function though, It's all stuffed into acquireCity, i.e. the function that changes a city's owner. So one way to implement a move-city function could be to split up acquireCity. Hard to say if that would be easier than what Nightinggale outlined. But with the Python interface and WorldBuilder commands that we have, one could only mimick the essential parts of the copying performed in acquireCity.
 
I never thought of that. If moving/ copying a city were properly implemented in the DLL, perhaps something like this would've become a significant feature in one of the fantasy/ sci-fi mods. Funny, how the creative direction of mods can be driven by random technical limitations/ opportunities.
 
Just noticed that I, by mistake, built one of my cities on the wrong square. Extremely annoying. I won't load an earlier save because it was over 200 turns ago I built the city. Is it possible to move the entire city one square with the help of python?
You can use Platybuilder to move a city as far as you want.
 
Interesting. Judging by the code, PlatyBuilder takes the copy/delete approach with a helper function copyCityStats. Can't say if this covers everything that acquireCity in the DLL does, but it looks quite thorough, may well work correctly. A Python programmer could try moving Platy's code to a more widely included module and implement those traveling cities that way.
 
Top Bottom