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

Fix: for arctic and tropic, make sure we have at least a few hills #8513

Merged
merged 1 commit into from Jan 8, 2021

Conversation

TrueBrain
Copy link
Member

@TrueBrain TrueBrain commented Jan 7, 2021

Fixes #6337

Motivation / Problem

With the default configuration, creating arctic and tropic maps are not working as intended: on flat there are no hills to generate any of the hill-only industries. In the case of arctic this generate an error; one a new user would have no idea how to solve.

In general, on these two landscapes hills are .. not really hilly with the default height-level and snow-line level. If you drop them by 50% (15 / 7), it becomes more like what we were used to before 2014 (before the higher max-height-level was introduced).

Description

Solving this is far from easy, as the TGP became a patch on a patch on a patch on a patch, often by people who did not understand the full scope. For example, the max_height table is now just terrible, as it is not a fluent increase of values (sometimes + 7, next step + 2); this makes no sense.

While solving this problem I got told multiple times that a rewrite of the map generator is the only true solution, but that is not helpful to anyone, especially new players. So I have been looking for a stopgap solution, that is not perfect, but gets the job done. This is the result.

In essence, it boils down that TGP uses a max-height based on map-size and "hilliness", which is clamped to "max-height-level" of the settings. By default, a 256x256 map can never generate any hill above 25 (this is independent of the "max-height-level"!). For "Very flat", "Flat", and "Hilly" it doesn't even come above the default snow-level, in arctic. This is pretty bad, and is the reason industries cannot be placed.

For tropic, the solution is picked is this:

  • Make sure the allowed height-level for TGP is at least the level required to generate tropical forest. This is hardcoded to max-height-level / 4. To compensate for the additional increase in height-level, we reduce it with the hilliness of the setting lower, just to dampen the effect of increasing the height-level.

For arctic, I went for a 2-part solution:

  • Similar to tropic, increase the height-level TGP works with with the snow-line-height. This means there is at least some hill somewhere above the snow-level. Also here we reduce the height-level again with the hilliness of the setting lower, to dampen the effect again.
  • Reduce the default snow-line-height to 10, to make sure "flat" can still be flat-ish. With the default on 15, it becomes extremely hilly, even for "flat". This is a bit of a compromise between still allowing somewhat flat landscapes and making sure maps generate properly.

Limitations

  • For arctic and tropic, "Very flat" is not so flat again. Because of some other non-sense I am not going into, on tropic this is not that bad. On arctic this is more noticeable. But from my perspective, this is not a bad thing. I do not expect a full flat map on arctic, as that would make the landscape hard to play (you are missing industries). And it is called arctic .. would you expect a full flat map there? :D But, this is simply a compromise between two evils.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@TrueBrain TrueBrain added the preview This PR is receiving preview builds label Jan 7, 2021
@DorpsGek DorpsGek temporarily deployed to preview-pr-8513 January 7, 2021 11:13 Inactive
@TrueBrain TrueBrain added this to the 1.11.0 milestone Jan 7, 2021
@andythenorth
Copy link
Contributor

Works for me.

I didn't hunt for pathological cases, but the following worked as expected with default settings, test across multiple 'newgame' maps of 256x256and 2048x2048 (and relevant climate):

  • temperate maps look fine in all ways
  • arctic maps
    • snowline is sensible
    • terrain looks fine
    • all industry types are placed, including forests
  • tropic maps
    • rainforest is placed sufficiently ('good enough')
    • all industry types are placed

64x64 maps are fine in temperate; in arctic and tropic industry chains generally have missing industry types. Truebrain thinks thats a pre-existing issue and can be ignored.

LordAro
LordAro previously approved these changes Jan 7, 2021
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

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

Sure

Without hills, not all industries can be generated, which means
that with a default configuration you get errors. This is far from
optimal, of course.

This now forces that there is at least some hills, even when you
are using very-flat. This is a stopgap solution, but a proper
solution requires a full rewrite of the terrain generator, which
is not a 2 minute (or even 2 week) job.

To make sure flat is still flat-ish, reduce the default
snow-line-height to 10, making it look a lot better on smaller maps.
This is a compromise between being able to have flat maps and
still having all industries on arctic.
@DorpsGek DorpsGek temporarily deployed to preview-pr-8513 January 8, 2021 10:19 Inactive
@TrueBrain TrueBrain merged commit 7463c46 into OpenTTD:master Jan 8, 2021
@TrueBrain TrueBrain deleted the better-terrain-generation branch January 8, 2021 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview This PR is receiving preview builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mapgen: no tropical trees and no snow with default world generation settings
4 participants