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

Parametric mapgen part 1: global random terrain selection #48529

Merged
merged 6 commits into from
Jul 9, 2021

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Apr 15, 2021

Summary

Infrastructure "New mapgen feature: maps can now select a terrain from a distribution and use that throughout the map"

Purpose of change

Interesting variable mapgen requires randomness. We currently have a fair amount of flexibility using nested mapgen that can allow for interesting variation, but it is difficult to use this to make large-scale changes to all of a map.

In particular, suppose you want to make a house layout which can use one of two different floor terrains, but is consistent throughout the house. Currently that would be possible using nested mapgen, but it would be tricky and nonintuitive. Also, nested mapgen can't extend over multiple OMTs.

Describe the solution

Add a new feature whereby a random choice can be made one time for the whole map, and the chosen value used as often as desired.

Currently this is a minimal proof of concept:

  • It only works for terrain.
  • It doesn't work across multiple OMTs.
  • It doesn't work in palettes.

I plan to lift all of these limitations in future PRs.

Apply this new feature in one map as an example: the crack house roof now chooses between three different roof terrain options.

Opening as draft because I still want to write documentation. Docs now written.

Describe alternatives you've considered

Doing a more complete version for the initial PR.

Testing

Unit tests. Game data loads. Spawning the crack house generates suitable randomization, as seen in this screenshot:
roof-randomization-screenshot

Additional context

@actual-nh actual-nh added 0.F Feature Freeze [C++] Changes (can be) made in C++. Previously named `Code` Map / Mapgen Overmap, Mapgen, Map extras, Map display <Enhancement / Feature> New features, or enhancements on existing labels Apr 15, 2021
@jbytheway
Copy link
Contributor Author

Docs written. Marking ready for review.

@jbytheway jbytheway marked this pull request as ready for review April 16, 2021 01:47
@jbytheway jbytheway requested a review from KorGgenT as a code owner April 16, 2021 01:47
Copy link
Contributor

@actual-nh actual-nh left a comment

Choose a reason for hiding this comment

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

Minor grammar/style fixes.

doc/MAPGEN.md Outdated Show resolved Hide resolved
doc/MAPGEN.md Outdated Show resolved Hide resolved
doc/MAPGEN.md Outdated Show resolved Hide resolved
doc/MAPGEN.md Outdated Show resolved Hide resolved
doc/MAPGEN.md Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg force-pushed the 0.F-dev branch 3 times, most recently from ac1984a to c8f13cf Compare June 14, 2021 15:06
@jbytheway jbytheway force-pushed the parametric_mapgen branch from fee777c to 68b6c1a Compare June 21, 2021 11:12
@jbytheway
Copy link
Contributor Author

Rebased on latest 0.F-dev.

@jbytheway
Copy link
Contributor Author

CI failures appear unrelated. I've opened #49397 and #49396 with fixes.

@jbytheway jbytheway requested a review from LyleSY as a code owner June 21, 2021 22:33
@jbytheway jbytheway force-pushed the parametric_mapgen branch from 68b6c1a to ea4fed5 Compare June 22, 2021 00:41
@jbytheway jbytheway force-pushed the parametric_mapgen branch from ea4fed5 to ce2d41f Compare July 4, 2021 12:15
@jbytheway jbytheway changed the base branch from 0.F-dev to master July 4, 2021 12:26
@jbytheway jbytheway force-pushed the parametric_mapgen branch 2 times, most recently from 66f7865 to 44bc39f Compare July 7, 2021 01:38
@actual-nh actual-nh removed the request for review from LyleSY July 7, 2021 02:58
jbytheway and others added 6 commits July 7, 2021 08:08
This is a generic function for loading a weighted_list from json that
can be used to reduce code duplication and ensure json consistency.
This function had no definition and no callers.
This is an initial implementation of parameters for mapgen, which
currently has those parameters act more like variables than parameters.

Essentially all it currently permits is to choose a terrain at random
and use that in a palette.  Thus choosing a thing at random which
applies to an entire map, rather than choosing at random on a per-tile
basis.

This is the first step towards true parameters for mapgen; hence the
currently-misleading name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants