Procedural map generation

LilBudyWizer

Warlord
Joined
Nov 11, 2014
Messages
174
The mods didn't like last post and moved it so I try being less detailed.

I'm thinking of changing resources generation to do it on a regional basis. The idea to give regions distinct resource flavors much like Civ V luxury resources. Not all strategic resources, just the affinity aligned ones. Not all basic resources, just those enhanced by buildings with affinity point requirements and using affinity aligned strategic resources. Not completely absent in any region like luxury resources, but far more common in some that others. That's the basic idea.

I was hoping maybe someone with experience procedurally generating maps in Civ, or familiar with the scripts that do so, could give some insight/guidance.
 
Luckily for you, I'm pretty confident you only need to work with one .lua file. Unluckily, that file is AssignStartingPlots.lua (a 4-letter word on these forums...).

The action starts at function AssignStartingPlots:GenerateGlobalResourcePlotLists() and goes through about three other very large and complex methods from there... Funnily enough, the large deposits of the three different affinity-specifics actually target specific features (Forest = Xenomass, Desert = Floatstone, Tundra = Firaxite).

There's also a second spawning of these possible from function AssignStartingPlots:PlaceSexyBonusAtCivStarts(), which is responsible for spicing up start locations. And it appears the "loose" quantities (1-3 I'd imagine) are mostly random.
 
I started revealing the map and looking at them with FireTuner. I found the Ceti Tau d map I've been mostly playing has apparently no tundra nor snow and, apparently, very little firaxite as a result. Doing that made me realize I need a map analyzer. That would likely be a better start. Before I go changing map generation I might ought to understand maps a whole lot better. Certainly understanding output makes understanding the processing easier. So that seems a good start for me. If nothing else I would need it for testing changes.
 
The printouts in the Lua console pretty much are your analyzer. There's a ton of information being conveyed there every time you spawn a map. It would be possible to edit the map script and add your own print lines should you find yourself needing data that's not already available. Alternatively it is possible to build and save datamaps as .csv files and view them in Excel/OpenOffice Calc, though that's not the most straight-forward process.
 
I'm finding it's a good introduction to FireTuner. I have counts by terrain type, feature type and resource type as well as totals for the resources. Well, sort of, apparently ocean, mountain and canyon has to be determined through GetPlotType and I haven't found how you determine miasma, hills and craters. I'm thinking maybe display everything for the tile the current unit is on. That'll make it easier to figure out what all this things are.

Is there a guide for the game states?
 
It was a thought. I found out the hard way lua scripts in FireTuner can only be 2k. It saves and loads bigger, but doesn't execute them. I was going to just put all the Get results for the plot the current unit is on into a table and display that. I generated the calls so there was no typos. I thought maybe it was failing silently due to calling a function without required parameters. So I started doing it piecemeal to find the function failing, but every function after one failed. So I checked the size of the file and when I went over 2K it failed. Perhaps just as well, without the values decode it don't give much insight.
 
GetPlotType() will also return PlotTypes.PLOT_HILLS so that covers that. Craters are, for all intents and purposes, mountains (they even say "mountain" in the tool tip for the tile when you hover over them); craters and mountains are only distinct from one another in the graphics-side of things.

plot:HasMiasma() is the method you're looking for to determine whether or not a plot "has miasma". :p

How miasma placement is handled is actually based on "Wildness", a hidden value that affects miasma, alien spawns, nests, and (as already discussed) the distribution of medium (4-7) and large (7+) quantities of the affinity-specific resources. Most of the "Wildness" code is in FeatureGenerator.lua (with the exception of "Desert Wildness" which is in TerrainGenerator.lua). When spawning miasma, the script goes tile-by-tile, gets the wildness, terrain, and feature for a given plot and then rolls a random value and compares that value to a static constant they set earlier in FeatureGenerator.lua. There's a specific static constant for almost every different combination of wildness, terrain, and feature possible.
 
I found those, but couldn't find anything for craters then noticed the tooltip says mountain. I then got distracted and spent the whole day on trying to build a tree of all the get, is and has returns. Is there a way to write a file from FireTuner? I was thinking the plot type, terrain type, feature type and resource would make a good pivot table.

Most of AssignStartingPlots seems to work on an internal table while querying the map. Since StartPlotSystem creates the object in a local variable and doesn't return it I assume it commits it to the map at some point. Do I have that wrong? If not where does it actually commit the changes?
 
So far as I know, it then goes on to use those tables within the script itself. Anywhere you see "*plot:set*" is where it is placing something. What it's placing depends on the actual method called. It may be that some things it determines never get set within the scope of the script and the C++ .dll reads from the tables the script uses to place them; I really don't know. I haven't studied ASP.lua too well as I haven't had a need to in my modding travels.
 
Back
Top Bottom