Colonial Expenses Calculation

Alekseyev_

Warlord
Joined
Jul 18, 2014
Messages
259
So after playing a fair share of Realism Invictus recently, there was an idea:
I had one other feature idea, idk if is at all doable but when my brother suggested it to me I was dumbfounded why Firaxis did it any different: since Beyond the Sword, when you have an island with at least two cities none of which is not your capital, you begin incurring extra maintenance costs and get the option to release these cities as a colony. Meanwhile, speaking in world map terms, owning capetown or Lisbon on the world map while otherwise playing as Korea with land in Korea, you will not pay any extra cost for sheer luck of sharing a land connection still. What would make a lot more sense in our eyes is that colonial costs should be based on whether you have a coherent cultural connection. Meaning that for example if the Vikings conquer England that is not a colony due to the culture being an uninterrupted area with your main country. But founding or conquering a city farther away, e.g. Athens, would be a colony despite the same landmass, due to being so far away that it forms its own "blob" of culture, not connected to the capital's one.

Does anyone here know by chance where (likely in DLL, hopefully not in some closed source code) the colonial costs calculation is done? And if it is at all possible to check whether a city has a continuous cultural connection to the capital's culture?

If it is possible, I might try my hand at it.
 
The calculation is here: CvCity.cpp#L5478
To check for an uninterrupted path of owned tiles, you could implement a simple depth-first search. Hopefully that would be fast enough to check for colony status each time that colony maintenance gets computed. I don't think the original code uses depth-first search anywhere; they throw the A* algorithm at everything. The implementation of that (class FAStar, "F" presumably for "Firaxis Game Engine", i.e. not meant to be exclusive to Civ 4) is in the EXE, but there's a (clumsy) interface for using it from the DLL. Actually the m_borderFinder instance of FAStar seems to already look almost for the paths that you need. I think it'll treat tiles owned by the same team as adjacent (borderValid function that gets passed to the border-finder by CvMap); you'd probably want the same player. Might also be too slow, but perhaps at least useful for an initial attempt. I don't know what the border-finder is even used for; only the EXE seems to use it, so probably for something (border) graphics-related.
 
Top Bottom