Map generation with voronoi diagram

Oct 8, 2016 9:29 PM

SirButcher

Views

2554

Likes

118

Dislikes

3

First step

Generate 200 randomly distributed point. These will be the starting points for our map.

Second step: voronoziation (is this a word?)

Use the voronoi algorithm to create polygons around the previously generated points. This looks kind of awful right now.

Third step: Lloyds relaxation

It use the same algorithm - first we calculate the center of the polygon, then use the new centers to generate the new voronoi cells. Do this multiple times, until the results looks okay.

Lloyds relaxation #2

Points look more uniform now: the middle of the map getting better.

Lloyds relaxation #3

And even more better. Running the relaxation more hardly change anything, so we stop now.

Fourth step: creating the island

Fill everything which touch the border. Then fill every neighbor with decreasing chance farther away we get from the border of the map.

Fifth step: distance calculation

Calculate the distance of the ocean fields from the shore (they start at 2 for no reason, I forgot to update it) and calculate the distance of the land from the ocean.

Sixth step: height calculation

The ocean is getting deeper as we get farther away from the land, so we can use it as a depth. Then randomly generate mountain peaks (marked with brown number) - farther it is from the ocean, taller the mountain can be.

Seventh step: colored depth map

Using the same data, but colors instead of numbers. Looks better!

This will be used for a city building game (hopefully) - this map generator developed in C#, it take about 2 seconds to reach the final step. Not yet done, but looks promising!

Btw, if anybody want to join a c# - SlimDX (yes, no unity, I know, don't start) game developing, feel free to write me! It hard to do alone!

gaming

Can you redo this + formulas/code explanation? It looks interesting

9 years ago | Likes 3 Dislikes 0

Yes, as soon as I finish it I want to release it so others can use it as well!

9 years ago | Likes 1 Dislikes 0

[deleted]

[deleted]

9 years ago (deleted Oct 2, 2017 11:09 PM) | Likes 0 Dislikes 0

Actually, I thought about it - if you randomly fill the cells it look really nice :D

9 years ago | Likes 2 Dislikes 0

Any chance you might be releasing this program at some point? I'd love to use it.

9 years ago | Likes 3 Dislikes 0

Yes, as soon as I finish it I want to release it so others can use it as well!

9 years ago | Likes 2 Dislikes 0

Sweeet.

9 years ago | Likes 2 Dislikes 0

Which voronoi algorithm are you using?

5 years ago | Likes 1 Dislikes 0

It was based on Lloyd's algorithm - https://en.wikipedia.org/wiki/Lloyd%27s_algorithm

5 years ago | Likes 1 Dislikes 0

Ahh I meant what did you use to compute the voronoi cells themselves? Fortunes algorithm or delaunay triangulation flipping etc.

5 years ago | Likes 1 Dislikes 0

Sorry, brain not working today. Yeah, I used the fortunes algorithm if I remember correctly, but this was like 4 years ago :D

5 years ago | Likes 1 Dislikes 0

Cool! It looks like a fun project.

5 years ago | Likes 1 Dislikes 0

Also I totally didn't realize I had dug this up from the grave.

5 years ago | Likes 1 Dislikes 0

It was, but sadly life arrived and I never had time to properly do anything with it, and the scope was too big... Eh.

5 years ago | Likes 1 Dislikes 0