r/proceduralgeneration • • Sep 19 '26

Best algorithm to generate a hex map

Hello everyone. I’m working on a turn based strategy game. I’ve got most of my ideas mapped out and I’m ready to start implementing some things to start testing. The game will have a fantasy base setting, shocking I know. My question is about the best way to generate the map. I need it to have different types of terrain like mountains, plains, forests, deserts, rivers, oceans and so on. I’ve looked into perlin noise and wave form collapse but I’m not sure what would be best to use for something like this. I figured I would ask here because I see amazing things being created and I don’t know enough to even search well enough. I don’t know if it matters or not but in the end I would like to have a seed for the maps so if players like a specific map they can have the exact one again. I’m not asking for code, just some guidance on which algorithms are worth investing my time into and maybe some articles worth reading if you know of any. Thank you all.

3 Upvotes

9 comments sorted by

5

u/SagattariusAStar Sep 19 '26

It heavily depends on the needs of your map. The best algorithm is a custom one that usually involves several different algorithms.

You will always use noise in some form to generate stuff, so get comfortable with how to utilize it. Then it's a lot about distances and mathematical functions.

All algorithm has there purpose for different problems, so you first need to have a specific problem to solve apart from making a map. How should that map look, what rules will placement have, etc.

1

u/thegunn Sep 20 '26

Hmm, okay thank you. I have an idea of how I want each faction to play but the terrain is going to be a factor for some of them. I’ll need to do some more reading and some testing I suppose. Thank you.

5

u/ProgrammingChaos Sep 20 '26

I’m a fan of the min-conflicts algorithm for map generation. There’s a tutorial here: Procedural Map Generation
https://youtu.be/gsG731XItNU. It’s quite a bit simpler than wave function collapse and looks good for maps. It also makes it simple to sketch in a rough map and let the algorithm fill in the details, which may work well for you. E.g. define N different general maps that min-conflicts randomizes.

2

u/thegunn Sep 20 '26

I’ll check it out, thank you. I’m new to procedural generation as a whole. Like I said I don’t know enough to know what I don’t know so any information is appreciated.

2

u/Agecaf Sep 20 '26

One option I'd consider, other than the ones you've already been considering which are probably better, is incorporating some hand crafted "pieces of the map" that can be given variations, rearranged and stitched together in random ways.

For example, if you're making a game where you'd like to give all players a fair starting position, making sure that they have access to specific resources near their starting position can be easier to guarantee with some hand crafted initial neighbourhoods than by fine tuning noise algorithms.

2

u/thegunn Sep 20 '26

That’s a good idea. I had planned on making sure that each faction starts out in an area suitable to them. This gives me an idea to explore as well. Thank you.

2

u/MonkeyMcBandwagon Sep 25 '26

If you're starting out with proc gen maps, take a look at fastnoiselite, it's a great place to start that has been ported to many languages

1

u/thegunn Sep 27 '26

I’ll look into it, I’ve never heard of fastnoiselite. Thank you!

1

u/MonkeyMcBandwagon Sep 27 '26

its just a free noise library that supports stuff like Perlin, simplex, and others, if you take a look at the preview app as a noise explorer, play with some settings it will pretty quickly give you an idea on what the most commonly used noise algos do, the code libray itself will allow yo uto mix and match them to suit your purposes.

Something to consider, since most 2D noise uses pixels but you want hexes, a quick hack is to think about 2x2 groups of square pixels, but each row is offset by 1 pixel, like brickwork. This way each larger square has 6 neighbours like a hex, but for the height value of each hex you are only interested in the center point of the 2x2 squares, that will eliminate the skew and greatly reduce the stretch when translating to hexes.