-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In-depth map generator documentation #2336
Conversation
Here is a link to the html generated page - https://longturn--2336.org.readthedocs.build/en/2336/Coding/mapgen.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great page! The only other thing I would add is try to link to the actual code when discussing algorithms.
docs/Coding/mapgen.rst
Outdated
|
||
If not done earlier, resources are then added to the map with at least one tile | ||
between them. For each tile that gets a resource, one is picked at random from | ||
the list of allowed resources for the terrain. Huts are added in a similar way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we note the huts
parameter also effects placement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many other things affect placement that are not described here. Maybe I could describe the main ideas of the placement algorithm?
The first fraction to be computed is the amount of polar terrain, decided based | ||
on the average temperature and the size of the map (larger maps get less). Since | ||
poles count towards the total landmass but have quite boring terrain, the | ||
fractions of all other terrains on the rest of the land is increased to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/terrains/terrain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I'm referring to terrains (terrain types?) as discrete objects (and thus countable) so I think the plural form is more appropriate. But I don't fully understand when terrain should be with or without s...
Terrains are placed in a similar way: tiles are picked at random and terrain is | ||
assigned to them until reaching their expected number. This is done by groups of | ||
terrains, starting with forest-like, then desert-like, mountain-like, and | ||
finally swamp-like. The gaps are then filled with ice, tundras, plains, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Tundra ever is plural, like terrain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
National Geographic uses it on this page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I stand corrected! It just sounds weird to me as plural.
After this step, the map of tile values is smoothed out using a Gaussian filter | ||
of width 1 and the value of ocean tiles is set to zero as they cannot be used as | ||
starting positions. The total value of every island is computed by summing over | ||
all tiles. Finally, tile values are normalized to the range [0, 1000). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have a [ and a ). do you want to use an open ( instead of a [?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the common mathematical notations for an open-ended interval, along with [0, 1000[. I could also change to 0-999 but I prefer to keep 1000 since it's easier to remember.
There are a few more semicolons in the text, are these fine? |
This is technical documentation explaining how maps are generated. It follows the code rather closely but I didn't include references, as this is spread across many functions and it would make reading harder. The following pieces of code are documented: * The overall sequence of map_fractal_generate() in mapgen.cpp and "easy" functions called from there; * All of startpos.cpp.
This involves a lengthy discussion of how terrain is chosen, which I hope will serve for most generators.
The island-based generators are very different from the height-based ones and it is thus more logical to have a full-blown section for them.
I copied a significant fraction of the text from the code comments, which seem to have been authored by Erik Sigra in the early 2000's. I am thus adding his copyright with his last known email.
* The docs still lack the Fair Islands generator and I do not intend to read the code now as it is fairly convoluted. * The docs are probably a bit involved if you have never played with generator settings.
* Style fixes * Add code references
50580b2
to
3b769ef
Compare
The other ones IIRC were lists, which is appropriate. |
Nice work! |
This is a big one, but hopefully an interesting read. I went through the code of the map generators (except FAIR, it's awful) and tried to explain how they work in words. Some of this information could make its way into other parts of the docs, but this is left for later.
@hugomflavio @wieder-fi you may find this interesting.