SirButcher
2554
118
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!
tschallacka
Can you redo this + formulas/code explanation? It looks interesting
SirButcher
Yes, as soon as I finish it I want to release it so others can use it as well!
[deleted]
[deleted]
SirButcher
Actually, I thought about it - if you randomly fill the cells it look really nice :D
darearkin
Any chance you might be releasing this program at some point? I'd love to use it.
SirButcher
Yes, as soon as I finish it I want to release it so others can use it as well!
darearkin
Sweeet.
Eniff
Which voronoi algorithm are you using?
SirButcher
It was based on Lloyd's algorithm - https://en.wikipedia.org/wiki/Lloyd%27s_algorithm
Eniff
Ahh I meant what did you use to compute the voronoi cells themselves? Fortunes algorithm or delaunay triangulation flipping etc.
SirButcher
Sorry, brain not working today. Yeah, I used the fortunes algorithm if I remember correctly, but this was like 4 years ago :D
Eniff
Cool! It looks like a fun project.
Eniff
Also I totally didn't realize I had dug this up from the grave.
SirButcher
It was, but sadly life arrived and I never had time to properly do anything with it, and the scope was too big... Eh.