Randomly generated maps

Feb 19, 2019 6:48 AM

victorsj

Views

1494

Likes

3

Dislikes

0

My first version was simple. Iterate over a grid. if I roll a d10 below a 7 it's water, otherwise it's land. I hope it's obvious that I chose those odds because the surface of the Earth is about 70% water.
The outcome is very spotty, It looks like noise, not like a map.

After doing my research I heard about the diamond-square algorithm (https://en.wikipedia.org/wiki/Diamond-square_algorithm) for generating random heightmaps. You can see above each cell shaded according to it's height value between 0 and 255. I must generate a map that is square and the dimensions are a power of two plus one.

I declare sea level at a value of 127 and get much more map like patterns. As I start with seed values near 128 my maps pretty consistently turn out like the one above, some have more land, some have more water. I don't influence the 70/30 ratio in this version. We'll see about that in a later version.

If let my seed values start in the full 0-255 range my maps become much less consistent.

My attempt at Perlin noise is has met with some hard fought success but my results have been less than ideal.

The noise my perlin noise implementation produces before adding water.

Perlin noise after a bit of tweaking, and I like it a bit more, although the islands are too round.

After a suggestion from my roommate and then separately from a commenter on a previous version of this post, I took the #1 and gave it a second pass using game of life rules (all but the overpopulation rule, where a cell is land and empty is water), the result is what you see above. It actually produces very consistent, very game worthy maps. One thing I dislike is it makes very sprawling spotty single land masses. Like island archipelago's that connect with small isthmuses.

programming

nodejs

maps

gamedev

javascript

Looks like pretty good progression, tbh! I used to play with this idea in my spare time at work. It's fun.

6 years ago | Likes 2 Dislikes 0