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

Hidden threshold in the map generator? #2468

Open
Corbeau-1 opened this issue Dec 26, 2024 · 8 comments
Open

Hidden threshold in the map generator? #2468

Corbeau-1 opened this issue Dec 26, 2024 · 8 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@Corbeau-1
Copy link
Contributor

Corbeau-1 commented Dec 26, 2024

When I set temperature = 0, amount of hills/mountains = 0 and wetness =100, I am still getting a number of hills and deserts.

When I set wetness = 0, I still get forests. See image. (No deserts and hills in the image because I removed them from the ruleset.)

I have a feeling there is a hidden threshold. If not, I'm looking for a way to exactly control the amount of some types of terrain, going from zero to all.

I tried playing with property-wet and property-mountainous, setting them to 0 or 100, but it didn't work.

Generators I used were Pseudo random height and Fractal height.

image

@Corbeau-1 Corbeau-1 added enhancement New feature or request Untriaged This issue or PR needs triaging labels Dec 26, 2024
@lmoureaux
Copy link
Contributor

I don't see a hidden threshold for mountains. For forest, you can't go below 5%. You may be interested in the algorithm description if you want to achieve specific results.

@lmoureaux lmoureaux added question Further information is requested and removed Untriaged This issue or PR needs triaging labels Dec 26, 2024
@Corbeau-1
Copy link
Contributor Author

Corbeau-1 commented Dec 26, 2024

Thanks, I'm checking it out.

So, the 5% for the forests is the threshold. However, I'm seeing more forest than expected:
image

Here it's 32 tiles where I'd expect 10.

@Corbeau-1
Copy link
Contributor Author

Ok, I checked the code. Code for percentage of forests is an absolute mess. I've seen messes in my life, but this one literally outmesses them all. I am not exaggerating. I will append a summary.

As for mountains, right, it's this:
mountain_pct = mount_factor * wld.map.server.steepness * 90;

Indeed, as you say, if steepness is set to zero, there should be no mountains on the map. Any idea why they are there?

Theoretically, the fact that I removed all other terrain types except mountains and forests could mess things up. But I don't see how.

And the mess with forest_pct:

#define MAP_INDEX_SIZE (wld.map.xsize * wld.map.ysize)

sqsize = sqrt(MAP_INDEX_SIZE / 1000);

#define MAX_COLATITUDE 1000

#define COLD_LEVEL
  (MAX(0, MAX_COLATITUDE * (60 * 7 - wld.map.server.temperature * 6) / 700))

ice_base_colatitude = 
(MAX(0, 100 * COLD_LEVEL / 3 - 1 * MAX_COLATITUDE) + 1 * MAX_COLATITUDE * sqsize) / (100 * sqsize);

#define ICE_BASE_LEVEL ice_base_colatitude

int polar =
2 * ICE_BASE_LEVEL * wld.map.server.landpercent / MAX_COLATITUDE;

factor = (100.0 - polar - wld.map.server.steepness * 0.8) / 10000;

forest_pct = factor * (wld.map.server.wetness * 40 + 700);

@lmoureaux
Copy link
Contributor

I think you're seeing the effect of terrain assignment in the gaps between the normal mountains. This proceeds according to Table 11 (also see the text above). I'm afraid there is no way to produce an all-grass map with this algorithm (a single terrain can always be in the required or preferred set and never in the avoided set).

This being said, you could change the forest terrain to make it identical to grassland.

@Corbeau-1
Copy link
Contributor Author

Well, I could always simply remove it from the ruleset altogether. But I'd like to have one or two different types of terrain that appear as rare patches here and there, but then again, it's not that crucial. If it's that difficult to do, I'll think of something else. Thanks.

@XHawk87
Copy link
Contributor

XHawk87 commented Dec 26, 2024

If you want to tweak how the map generation worked, it's relatively straightforward to do so in lua. For example:

function customise_map()
  for tile in whole_map_iterate() do
    if tile.terrain:rule_name() == "Mountains" then
      tile.change_terrain("Grassland")
    end
  end
end

signal.connect("map_generated", "customise_map")

This will replace all mountains on the map with grassland.

@Corbeau-1
Copy link
Contributor Author

Again, I can remove all mountains by removing "Mountains" from the ruleset. I want to retain some.

@XHawk87
Copy link
Contributor

XHawk87 commented Dec 26, 2024

If you want to randomly retain some, you could use something like this: https://github.com/longturn/Sim/blob/266b88ce6f822745fabe10d754586accfd97b3a7/Sim06/script.lua#L124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants