Skip to content
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

Merged
merged 14 commits into from
Aug 12, 2024

Conversation

lmoureaux
Copy link
Contributor

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.

@lmoureaux lmoureaux requested review from blabber and jwrober August 6, 2024 17:03
@jwrober
Copy link
Collaborator

jwrober commented Aug 6, 2024

Here is a link to the html generated page - https://longturn--2336.org.readthedocs.build/en/2336/Coding/mapgen.html

Copy link
Collaborator

@jwrober jwrober left a 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 Show resolved Hide resolved

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
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

docs/Coding/mapgen.rst Outdated Show resolved Hide resolved
docs/Coding/mapgen.rst Show resolved Hide resolved
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/terrains/terrain

Copy link
Contributor Author

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...

docs/Coding/mapgen.rst Outdated Show resolved Hide resolved
docs/Coding/mapgen.rst Outdated Show resolved Hide resolved
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
Copy link
Collaborator

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

Copy link
Contributor Author

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

Copy link
Collaborator

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.

docs/Coding/mapgen.rst Outdated Show resolved Hide resolved
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).
Copy link
Collaborator

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 [?

Copy link
Contributor Author

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.

@lmoureaux
Copy link
Contributor Author

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
@lmoureaux lmoureaux force-pushed the feature/mapgen-docs branch from 50580b2 to 3b769ef Compare August 11, 2024 23:21
@lmoureaux lmoureaux mentioned this pull request Aug 11, 2024
@jwrober
Copy link
Collaborator

jwrober commented Aug 12, 2024

There are a few more semicolons in the text, are these fine?

The other ones IIRC were lists, which is appropriate.

@jwrober jwrober self-requested a review August 12, 2024 13:59
@jwrober
Copy link
Collaborator

jwrober commented Aug 12, 2024

Nice work!

@jwrober jwrober merged commit 81a6932 into longturn:master Aug 12, 2024
21 of 22 checks passed
@lmoureaux lmoureaux deleted the feature/mapgen-docs branch August 12, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants