Playing with map generator

Hello!

I am making the map generator. Unfortunately the first thing i found out is that it is slow. Just populating 8k*8k byte array takes a long time, and that without any actual generating. At least you can make a coffee before playing.

So now to my ideas, what I already tried and what it will look like. First i tried Making random colors with Voronoi diagram. The brute-force edition. I couldn’t figure out an elegant algorithm so I just ran through all nodes(random points distributed around the picture) for all the pixels and picked the closest. If you don’t know what Voronoi diagram is, check here. This is what it looks like:

Kinda nice, very random, but really, the slowness had to go.

Next I tried putting few points randomly into the picture and make them grow. That turned out looking really good, but the performance still isn’t something I want to have.

Then I returned back to Voronoi, but deformed it a bit. I split the picture into chunks and put one point randomly into every chunk. Then I had to check only 9 chunks for each pixel, instead of all nodes. So less randomness, but way better performance. Note that the generation for 8k*8k map still takes…*10 minutes later*well i let it run for two minutes, it was maybe 5% complete and then it crashed the whole PC. What idiot could’ve want that big map? What will players do on map so unnecessarily big? Oh I did and I have no idea why.

//TODO: Scale the map down

Now to the next Voronoi. I set a color palette representing the biomes(grassland, desert etc.) and this is how it looks like:

Nothing epic, but hey, it will get better..right? Maybe with more randomness..

Anyway I think it will look OK with all the ingame tiles.

These are biomes. What next? I will make each biome its own specific generator. Grass will have some trees and flowers, rocks and whatever, villages will have houses with roads, evil lairs will have evil..lairs and so on. I am also considering making one biome a dark dungeon completely filled with stone, tight hallways and dangerous traps.

Thanks for reading, have a nice day!

Leave a comment