how to avoid grassland and forest?

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
I have just started modifying mapscripts. I am aiming for a particular feature distribution: very low percentage of grassland and forest. This is for a post-apocalyptic desert war feel.

The operative part of the python is this (assume the indentation is right)

def generateTerrainTypes():
terraingen = TerrainGenerator(iDesertPercent=50, iPlainsPercent=50)
terrainTypes = terraingen.generateTerrain()
return terrainTypes

def addFeatures():
featuregen = FeatureGenerator(iJunglePercent=10, iForestPercent=20)
featuregen.addFeatures()

def normalizeAddFoodBonuses():
"Disable default routine"

def normalizeAddGoodTerrain():
"Disable default routine"

def normalizeAddExtras():
"Disable default routine"

But I still get grassland, and I still get a *bunch* of forest.

I think the grassland is due to some fixup done by the civilization placer. I have overridden normalizeAddFoodBonus and normalizeAddGoodTerrain to be empty, but still each starting civ has a few squares of grassland around it. Once I get the map working, I will allow a little bit of grassland, but first I want to understand where it is coming from.

Of course the forest generation depends on a fractal, so it is a little random and hard to measure exactly. But, I have tried a few values for iForestPercent. When I try 0, I get a huge amount of forest, as if it has decided to ignore the threshold altogether. Same thing for 10. At 20, it "seems" like there is less forest than the default, but still way more than 20%. So the variable seems to have some effect, just not the effect I want.

I'd like to get no grassland to prove I understand where it's coming from, and only a small amount of forest. Any suggestions?

EDIT: added script and example output in attachment. Put the map script into My Games\Beyond the Sword\Public Maps; select "Fury_Road" in the map list when you start a game.
 
For forest, you can probably either change the xml file for features or subclass FeatureGenerator and replace addForestsAtPlot to do nothing.
If you get prairies only around the starting locations, then redefine normalizeRemoveBadTerrain and normalizeAddGoodTerrain
 
I think forest generation isn't obeying the threshold.

I also think with iDesert=50 and iPlains=50 and all eight of the normalize functions stubbed, I shouldn't be getting any grassland at all. I want *some* grassland, I just want control over it, so I would like to know where else grassland could be getting generated.

I can limp along with a loop that eliminates 50% of the forest and converts 50% of the grassland to plains. But that doesn't seem like the best solution.
 
Keep in mind you can do anything you want with a map script. Since you are trying to create a very different setting than a normal world, I don't think the established tools are going to give you what you want.

Download the SDK and check out the functions called on the CvPlot class, like setBonus and setTerrain, all you have to do is eventually call all those kind of functions that need to be called.

The CvMapScriptInterface file has a rundown of what needs to be done. You might find it far simpler to do things your own way than to try and use the fractal stuff from CvMapGeneratorUtil.
 
Thanks for the information. It's nice to be able to get a map with some terrains and features with basically two lines of my own code, just overriding parameters to FeatureGenerator and TerrainGenerator. I was hoping to understand the unexpected results and maybe tweak something a little further.

In your experience, can you tweak the thresholds to those generators and get the results you expect?
 
In your experience, can you tweak the thresholds to those generators and get the results you expect?

Those things did nothing that I wanted, so I started from scratch. I would suggest that you take a long look at your map needs though. That's your game setting! What could be more important to the whole atmosphere than the map? That's what the player is looking at 95% of the time. Can any mod be successful with a map that sorta, but not really, fits the subject matter?

:goodjob:
 
Thanks for the advice. I want to write new code to put ruined cities and a whole bunch of resources, so I think I will leave the grassland and forest "random removal" for now.

In related news, I am confused about how to set the calendar when using a map script. Most of the scenarios that come with BTS have set maps, and the WBS file contains a calendar keyword. But I cannot figure out how to set it in the mapscript. Do you know how to do that offhand? Or in python? I can set each player's era in python with setCurrentEra. But my game starts in 2100 AD and keeps going ahead by a hundred years at a time due to the ancient era calendar. I want to set it to CALENDAR_YEARS, but I can't see how.
 
I think you can do that kind of thing in your custom event file in the onGameStart function. You can also modify the GameSpeed xml file.
 
I wasn't able to find a python call to change the calendar. However, after sleeping on it and then searching again, I found the calendar and default era are set in GlobalDefines.xml and the size of the increment is found in GameSpeed.xml. Thanks!
 
Back
Top Bottom