• 📚 A new project from the admin: Check out PictureBooks.io, an AI storyteller that lets you build custom picture books for kids in seconds. Let me know what you think here!

Dynamic distance between cities tested with RFCE

JediClemente

Prince
Joined
Jan 21, 2004
Messages
446
Location
Madrid, Spain
This idea was originally mentioned in some discussion about RFC:Antiquity, and has the modmod in mind, that's why I post it here.

Typically, you can define the minimal distance between cities in GlobalDefines.xml. Both RFC and RFCE set that value to "1".

Now for RFC:Antiquity, all regions shouldn't have the same concentration of cities (Greece and the Levant should have a lot in a few plots; the far extenses of the Roman and Persian empires should have very few).

So I want 3 different "minimal distances" of 1, 2 and 3 for different regions of the map.

I look at Python and it doesn't seem like it can be done there. In the SDK? Yes. There are two instances in the C++ code where the variable from GlobalDefines.xml is read. I probed this for RFCE:

3 minimal distance for Northwestern Africa, 2 for Russia and 1 for the rest of the map.

You just have to look for this line
Code:
iRange = GC.getMIN_CITY_RANGE();

And change it in CvPlayer.cpp
Code:
// JediClemente start **
// dynamic CITY_RANGE (that is, allowed distance between cities dependant on position)
// will take the mininum from GlobalDefines.xml
// point is to have some places in the map crowded with cities and others not so much

if(pPlot->getX_INLINE() < 46 && pPlot->getY_INLINE() < 22){ // Northwestern Africa will have as few cities as possible
	iRange = GC.getMIN_CITY_RANGE() + 2;
	}
else if(pPlot->getX_INLINE() > 77 && pPlot->getY_INLINE() > 48){ // Russia will have less than normal
	iRange = GC.getMIN_CITY_RANGE() + 1;
	}
else{ // the usual for the rest of the map
	iRange = GC.getMIN_CITY_RANGE();
	}

// JediClemente end **
// original line here:
//iRange = GC.getMIN_CITY_RANGE();

and in CvDLLWidgetData.cpp:
Code:
// JediClemente start **
// dynamic CITY_RANGE (that is, allowed distance between cities dependant on position)
// will take the mininum from GlobalDefines.xml
// point is to have some places in the map crowded with cities and others not so much

if(pMissionPlot->getX_INLINE() < 46 && pMissionPlot->getY_INLINE() < 22){ // Northwestern Africa will have as few cities as possible
	iRange = GC.getMIN_CITY_RANGE() + 2;
	}
else if(pMissionPlot->getX_INLINE() > 77 && pMissionPlot->getY_INLINE() > 48){ // Russia will have less than normal
	iRange = GC.getMIN_CITY_RANGE() + 1;
	}
else{ // the usual for the rest of the map
	iRange = GC.getMIN_CITY_RANGE();
	}

	// JediClemente end **
	// original line here:
	//iRange = GC.getMIN_CITY_RANGE();

It's quite simple. I've tested it, and it works! :D

Don't know if the idea can be applied to RFCE or regular RFC, but I'll certainly try to use it for RFC:A if everyone's OK with that.
 
OK with me but I'd prefer to see a minimum distance between all cities of two tiles at least.
 
Interesting idea. You may or may not know that there is also a way to specify (in Python: RFCEBalance.py) how many overlapping big-fat-cross squares the AI will allow between any cities. The big difference would be that your code would apply to the human player as well. I worry that might be a bit confusing though...

As an aside, I will be setting the minimum city distance to 2 in RFC Europe. That's quite appropriate for most of the map.
 
That means that cities should now have a 3x3 tiles overlap (ie instead of the 2x2 before)?
 
Interesting idea. You may or may not know that there is also a way to specify (in Python: RFCEBalance.py) how many overlapping big-fat-cross squares the AI will allow between any cities. The big difference would be that your code would apply to the human player as well. I worry that might be a bit confusing though...

As an aside, I will be setting the minimum city distance to 2 in RFC Europe. That's quite appropriate for most of the map.

Didn't know that about RFCEBalance.py. It surely is a better option, even if the human player isn't affected.

And I agree a distance of 2 is appropiate for RFCE.
 
Back
Top Bottom