Hacker News new | past | comments | ask | show | jobs | submit login

I was working some time ago on a 4X with an hexagonal map (not only made of hex tiles, but the overall shape was an hexagon rather than a rectangle, no wrap-around).

Using a noise function alone does not let you choose how many landmass you want to generate.

Using "wave function collapse"/constraint solvers is too slow for large maps when the amount of constraints increase (please don't put a mountain in the middle of the ocean, or a snow tile in the middle of a desert). My implementation took almost 8h to generate a single map, and the result was not even good.

In the end, I used a combination of multiple techniques:

  - voronoi to split the map into regions
  - use a noise function to make the regions boundaries a bit more natural
  - fill the map with water tiles, place randomly some island seeds
  - grow the islands from their seeds using a cellular automata
  - to create continents, simply put a lot of island seeds in the same area, to generate a bigger one
  - place mountains or rifts on region boundaries to simulate "tectonic plates"
  - generate a heat map (influenced by position of the north/south poles and equator of the map), a humidity map (influenced by leftover ocean tiles), a height map (which is influenced by the already placed mountains/rifts) using a noise function
  - using the previous heat/humidity/height maps, generate a wind map
  - using the wind map, modify the humidity map (wind carries humidity over the land)
Then, choose randomly some tiles that fit some criteria to place biomes:

  - desert on hot/dry land
  - forest on temperate land
  - swamp on temperate/wet land
  - jungle on hot/wet land
  - ...
Then a bunch of different cellular automata to grow the biomes naturally.

The result was quite nice, but it still wasn't on par to the map gen in Civilization games. I still want to continue this project, but I think in my heart I gave up.

EDIT: Some formatting because i always forget HN does not support markdown lists






> but it still wasn't on par to the map gen in Civilization games.

Which makes me wonder... do we know how map gen in Civilization works so well?


This is pretty cool! As someone with virtually no experience in this area I’d love to read the source code, is it open source?

A fantastic resource for this kind of generation is here:

http://www-cs-students.stanford.edu/~amitp/game-programming/...


This really brought me back.

I first came across Amit's page in middle school 20 years ago, and studied it religiously until I built a hexagonal grid with A* in Game Maker (which taught me programming from the ground up by studying Mark Overmars' amazing manual).

Today I'm directing an indie game with a team of 10 under me.


The code is not opensource but I've written a few articles about it:

  - Part 1: https://david-delassus.medium.com/procedural-map-generation-in-c-part-1-the-slow-the-bad-and-the-ugly-4445fb15e43a?sk=2ff2c19dc5fe4c706092e83c79c72f56 (perlin noise, then wfc = fail)
  - Part 2: https://david-delassus.medium.com/procedural-map-generation-in-c-part-2-a-new-hope-with-cellular-automata-and-gpt4-6b3b52c6b357?sk=96ab3bb234c28d9f5dc2dca8f2f19f97 (cellular automata, and let's try to use GPT to write the code = GPT is nice, but not perfect I had to refactor the code a lot)
  - My own noise function: https://david-delassus.medium.com/i-made-my-own-noise-function-9e6ce4b95a9c?sk=26c5bdd7687445016216cc0b7cb10fa7
NB: Yes it's on medium, my bad :p The `sk` token in the URL is the friend link to bypass the paywall.

Thank you!

"You know, Hexagons are the Bestagons!"

https://www.youtube.com/watch?v=thOifuHs6eY




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: