BattleMaster Community

BattleMaster => Development => Topic started by: Tom on March 28, 2012, 11:51:35 PM

Title: side-project
Post by: Tom on March 28, 2012, 11:51:35 PM
Something I'm currently doing just because it interests me:

(http://dl.dropbox.com/u/9638874/voronoi-test.jpg)


100% automatically generated, the only manual work was adding a bit of noise in photoshop so it doesn't look so clean.

This is actually a scaled-down version. What you can't see is that there are actually around 6000 plots of land on this map, individually generated and computed. With the generated data, I could store those plots in a database. Imagine having 6000 BM regions... Oh yes, I also store height data at a fairly high resolution (about 30k points), so this could easily be turned into a 3D map.

I'm still tweaking the river-generation algorithm, but I am very, very happy with my result so far.
Title: Re: side-project
Post by: Zakilevo on March 29, 2012, 12:01:34 AM
wow 6000 regions. We will probably need every single character to fill the map.

But the map itself doesn't look bad at all.
Title: Re: side-project
Post by: Anaris on March 29, 2012, 12:02:41 AM
The next step is to have settlements placed in sensible and/or game-appropriate ways.  Like not having nearly every single stronghold in the game sitting out in the middle of nowhere ;D

It sounds like the 6000 plots could be used to build complex subregions; if we were to make a continent out of a map like this, and made it, say, twice the size of Dwilight, each region could have, on average, 12 subregions. Lords could then take those subregions and divvy them up into estates.

(Or we could try and implement that BM 2.0 idea you had, where you start out at the subregion level, and agglomerate subregions together arbitrarily to make regions...but that's probably impractical ;D )
Title: Re: side-project
Post by: Foundation on March 29, 2012, 12:15:13 AM
Oh the huge manatee!
Title: Re: side-project
Post by: Perth on March 29, 2012, 12:29:39 AM
Drooling over the idea of this as a BM continent.
Title: Re: side-project
Post by: Zakilevo on March 29, 2012, 12:42:41 AM
Drooling over the idea of this as a BM continent.

It will certainly be better than having copies of EC and Atamara.
Title: Re: side-project
Post by: Tom on March 29, 2012, 02:05:37 AM
Sorry to burst it, but this is a side-project, it's not for BM. Sorry.
Title: Re: side-project
Post by: Zakilevo on March 29, 2012, 03:01:42 AM
Aww... :( Too bad. That map would have made me giggle for days.
Title: Re: side-project
Post by: Chenier on March 29, 2012, 04:25:30 AM
Seems like a good tool for RPGs like D&D.
Title: Re: side-project
Post by: De-Legro on March 29, 2012, 04:46:28 AM
Seems like a good tool for RPGs like D&D.

There already exists tons of map generation software for RPG games.
Title: Re: side-project
Post by: Penchant on March 29, 2012, 05:21:52 AM
Sorry to burst it, but this is a side-project, it's not for BM. Sorry.
If its not for BM, what is it for? I am just curious.
Title: Re: side-project
Post by: Perth on March 29, 2012, 05:27:24 AM
Sorry to burst it, but this is a side-project, it's not for BM. Sorry.

Why not!
Title: Re: side-project
Post by: Tom on March 29, 2012, 11:24:17 AM
Why not!

Because even though it eats my time like nothing else, my life does not revolve around BM and I do other things, too.
Title: Re: side-project
Post by: Tom on March 29, 2012, 01:38:35 PM
Here's another island from my current version, slightly improved river generation and added a coastline:

http://dl.dropbox.com/u/9638874/voronoi-936002642.png
 
This is full-size (2048x2048 pixels) with the region centers marked (these would be villages, mills, towns, strongholds, etc) just to show how many there are (5458 in this one, to be precise).


Next thing I'm thinking about is adding moisture calculations so I can generate terrain types (the current one might look nice, but it's basically just a heightmap). A lot of inspirations are from http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/ - but I didn't use any of his code.

Title: Re: side-project
Post by: Chenier on March 29, 2012, 01:49:44 PM
There already exists tons of map generation software for RPG games.

True, but by the looks and sounds of what he's doing, it sounds like I could manipulate it with my GIS software for nice results. ^.^
Title: Re: side-project
Post by: Tom on March 29, 2012, 07:31:30 PM
I think I'm done for today. Here is the current status:

(http://dl.dropbox.com/u/9638874/voronoi-experiment/biomes-37342257-thumb.png)(http://dl.dropbox.com/u/9638874/voronoi-experiment/moisture-37342257-thumb.png)(http://dl.dropbox.com/u/9638874/voronoi-experiment/voronoi-37342257-thumb.png)



The first map is the new map that takes biomes into consideration. The dark green is forests. The light green is grassland, the brownish is scrubland, the yellowish is desert. The grey is bare mountains and the white snow-capped mountains. The brown/greenish you find at some water mouths is marshland. There are also two shades each in forests, grassland and scrubland indicating density.

The second map shows the distribution of moisture on the map. As you can see, rivers are a primary source of moisture as is closeness to the coast. The two factors add up.

The third map is a topological map showing height (lighter colour means higher) as well as treacherous (yellow) and impassable (red) region borders due to large height differences. This can include coastlines, which means cliffs (impossible to land with a ship there). There are a few at the southern coast. This map also marks the individual regions with tiny borders. You can probably not see them well in the scale-down version, but I have the full-size versions here:
What is all this for? To be honest, I don't have a clue. I'm experimenting. I have a few thoughts running around my head, but nothing final so far.



Title: Re: side-project
Post by: Anaris on March 29, 2012, 07:35:42 PM
Extremely cool.

This is done completely with software you wrote, right? (excluding libraries) Not done with a separate software package?

How long does it take to do this generation, for a map of the size you just showed? That looks like it's probably another one of around 4000 subregions, yes?
Title: Re: side-project
Post by: Tom on March 29, 2012, 08:07:17 PM
Yes, it's all done by a script I'm currently building.

This one is actually half resolution, so it has around 1500 or so regions. Takes a few minutes to calculate. The problem is quadratic increases in time and memory, especially in the voronoi calculations, preventing me from going much higher. I tried 4096x4096 but it doesn't work out. Crashed with a segfault after about 15 minutes of calculation.


Title: Re: side-project
Post by: JPierreD on March 29, 2012, 08:09:13 PM
Thinking BM-wise the dangerous and impassable terrains are extremely interesting, as useful bases for where to naturally place strongholds and the likes.

Really, really cool.
Title: Re: side-project
Post by: Tom on March 29, 2012, 08:18:00 PM
I lied when I said I was done for the day. Experimenting with non-square layouts - works great. And the results can be tiled nicely:

(http://dl.dropbox.com/u/9638874/voronoi-experiment/islands.jpg)


This map has again received a bit of photoshop treatment for purely visual effects. The contents are entirely generated automatically.
Title: Re: side-project
Post by: Anaris on March 29, 2012, 08:20:09 PM
Yes, it's all done by a script I'm currently building.

This one is actually half resolution, so it has around 1500 or so regions. Takes a few minutes to calculate. The problem is quadratic increases in time and memory, especially in the voronoi calculations, preventing me from going much higher. I tried 4096x4096 but it doesn't work out. Crashed with a segfault after about 15 minutes of calculation.

That sounds like reducing it a bit further would make it fully viable for on-the-fly random generation of rather large-scale environments, which could work as a basis for something resembling a roguelike.
Title: Re: side-project
Post by: De-Legro on March 29, 2012, 11:36:32 PM
That sounds like reducing it a bit further would make it fully viable for on-the-fly random generation of rather large-scale environments, which could work as a basis for something resembling a roguelike.

Some of the newer rogue likes I've seen use voronoi calculations as the base for their world generation. It has a lot of advantages as a base for more complicated stuff like biodomes.
Title: Re: side-project
Post by: fodder on March 29, 2012, 11:39:33 PM
.... bmfortress?

dwarfmaster?
Title: Re: side-project
Post by: Tom on March 30, 2012, 01:21:28 AM
I'm not even trying to copy the complexity of DF. It goes way, way beyond this. But it also works on a square grid, which makes a ton of things easier, but also less realistic-looking. It has a certain charme that is currently a hype (see Minecraft), but I'm a big fan of non-square grids or no grids at all.

Though there is a jittered grid behind this project here for the initial seeds of region centers (voronoi points). I've decided on that approach because it is computationally simple and yields a good mix of randomness and even distribution while the simple addition of a margin value guarantees a minimum distance between settlements.
Title: Re: side-project
Post by: Tom on March 30, 2012, 01:26:47 AM
And a final update (hey, it's the next day over here, technically speaking!):

The script now generates metal deposits and calculates wood and food yields. Metal depends on some perlin noise and the terrain height (i.e. much more common in mountains). Wood depends on some noise and the biome, mostly (obviously, forests yield lots of wood, the other types not so much). Food depends on the biome, some noise and the moisture.

In addition, the script now stores which places are on a coast and which ones are on a river, so it knows which ones have access to the sea, or could build a harbor, etc. I don't yet incorporate fishing into the food calculations.
Title: Re: side-project
Post by: Foundation on March 30, 2012, 01:30:34 AM
Definitely an interesting side-project.  How are you writing this script in terms of language and libraries? :)
Title: Re: side-project
Post by: Tom on March 30, 2012, 09:53:29 AM
PHP is my language of choice if I want to quickly whip up something, because I know it best.

I'm using a library for the whole Voronoi stuff and one for Perlin noise, and that's it. Everything else is my code.

Title: Re: side-project
Post by: Solari on March 30, 2012, 05:15:09 PM
Side project or not, I saw this and immediately thought of a single-continent BM game world.  Epic.
Title: Re: side-project
Post by: egamma on March 30, 2012, 08:59:04 PM
Can you use Hexes instead? There are several gameplay advantages to hexagons.
Title: Re: side-project
Post by: Foundation on March 30, 2012, 09:22:46 PM
Really like the choice of Voronoi for boundaries and high quality noise.  I've never used PHP as a scripting language apart from web applications. :)

Looking forward to what this side-project results in.
Title: Re: side-project
Post by: Gustav Kuriga on March 31, 2012, 12:23:55 AM
This may be a side-project, but there's no reason it shouldn't also benefit BM without you going out of your way.
Title: Re: side-project
Post by: Chenier on March 31, 2012, 01:01:02 AM
This may be a side-project, but there's no reason it shouldn't also benefit BM without you going out of your way.

Perhaps for random WI maps?
Title: Re: side-project
Post by: Tom on March 31, 2012, 10:58:38 AM
Can you use Hexes instead? There are several gameplay advantages to hexagons.

Hexagons are still regular, and thus don't make up a natural/realistic landscape. Plus the voronoi approach makes it possible to have areas of different sizes. I might be experimenting with that, e.g. reducing the number of regions depending on region type, e.g. desert regions would be larger. But that requires re-calculation of the mesh and I'm not sure I want to go there (because everything else like moisture, etc. is based on that). Would need to experiment and see if it gives me something worth the while.

Title: Re: side-project
Post by: Chenier on April 03, 2012, 01:57:37 AM
Hexagons are still regular, and thus don't make up a natural/realistic landscape. Plus the voronoi approach makes it possible to have areas of different sizes. I might be experimenting with that, e.g. reducing the number of regions depending on region type, e.g. desert regions would be larger. But that requires re-calculation of the mesh and I'm not sure I want to go there (because everything else like moisture, etc. is based on that). Would need to experiment and see if it gives me something worth the while.

If your hexes are small enough, they can still give smooth natural-like results.

Probably demands a lot more juice, though.
Title: Re: side-project
Post by: De-Legro on April 03, 2012, 02:11:52 AM
If your hexes are small enough, they can still give smooth natural-like results.

Probably demands a lot more juice, though.

If they are small enough to give natural results, they are probably too small to be visibly useful for game play functionality. You could then combine the smaller ones into larger ones, but then you end up with hex's crossing borders etc.
Title: Re: side-project
Post by: Chenier on April 03, 2012, 02:46:42 AM
If they are small enough to give natural results, they are probably too small to be visibly useful for game play functionality. You could then combine the smaller ones into larger ones, but then you end up with hex's crossing borders etc.

Depends what you need the hexes for, I guess.
Title: Re: side-project
Post by: De-Legro on April 03, 2012, 02:53:31 AM
Depends what you need the hexes for, I guess.

Well there is very little advantage if you are only using them for map creation. Most advantages stem from unit movement I believe.
Title: Re: side-project
Post by: Foundation on April 03, 2012, 04:37:08 AM
Even then, Euclidean distances and travel paths are easy to calculate on Voronoi diagram. :)

Interesting read: http://en.wikipedia.org/wiki/Voronoi
Title: Re: side-project
Post by: egamma on April 03, 2012, 05:32:14 AM
Well there is very little advantage if you are only using them for map creation. Most advantages stem from unit movement I believe.

Correct--check out this neat little game to see why hexes are so cool: http://gamesbyemail.com/Games/Viktory2 (http://gamesbyemail.com/Games/Viktory2)
Title: Re: side-project
Post by: Tom on April 03, 2012, 09:43:08 AM
If your hexes are small enough, they can still give smooth natural-like results.

Only on a large scale, at which every shape gives smooth results, even squares (heck, the pixels on your screen are squares).

But I need a map that looks natural even if zoomed in a lot. Voronoi cells do that. At very large zoom levels I may have to add some noise to the lines seperating the cells, but that's easily done.
Title: Re: side-project
Post by: Tom on April 03, 2012, 09:49:14 AM
Even then, Euclidean distances and travel paths are easy to calculate on Voronoi diagram. :)

Exactly. I did my research. Delauney triangulation and you have all your paths, and they have some nice properties, too (guaranteed to only ever cross exactly one border, guaranteed to be the shortest distance, border guaranteed to be exactly halfway between the origin points, etc. etc.).

Right now, though, I'm stopped because the PHP implementation of Fortune's Algorithm that I use is broken. At more then 16k cells, it takes forever and sometimes goes into an endless loop. :(
Title: Re: side-project
Post by: Charles on April 03, 2012, 03:38:30 PM
How were your rivers generated?  It looks to me like the rivers were generated first and then the precipitation was figured out using them.  It would be nice to see (and I am sure much harder to do) the rivers generated from the precipitation.  Come up with some other algorithm for deciding how much precipitation occurs in any plot.  Then see where the water would run (you may need to add slope to each plot).  Once enough water is accumulated, streams and rivers form.  If water is trapped, that plot (or two depending on the size of the river?) would become a lake. 
This would add the posibility of a river running through a desert, and posibly forming a lake there.
Title: Re: side-project
Post by: Tom on April 03, 2012, 03:58:09 PM
I'm not happy with my river generation algorithm. In fact, not happy at all. I will probably end up completely rewriting it.

Title: Re: side-project
Post by: Charles on April 05, 2012, 04:33:33 PM
Well, if you are looking for a different algorithm, it would be neat to see precipitation done first and then form the rivers.  It makes the place more of a living thing, rivers are not just bodies of water that exist but change.  Where potential droughts could make rivers into streams, and torrential rains could flood out towns and crops.  And rivers could be damed and diverted. 
As a side note, I would like to say that I am very excited that I am not the one attempting to code these ideas.  They sound like far more work than they would be worth, but as I am not the one coding, I will continue encouraging and giving unrealistic ideas!  Good luck!  I really like what you are doing Tom, even if you disregard all my suggestions.
Title: Re: side-project
Post by: Tom on April 05, 2012, 05:03:57 PM
I'm not looking for a simulation, so I won't do precipitation models, because that is much more complex than I care about.