Sunday, September 25, 2011

Cave generation

After FOV, the next big aspect of the game to tackle was level generation.
For Ronin, the entirety of the game is intended to take place in underground caves, and hence I chose to adopt the most popular method for doing so, i.e. cellular automata, as described here and here.  The latter link even includes a ready implementation in Python, though I chose to write one from scratch, both because I felt I could do some things better, and because I would otherwise need to adapt it to a hex grid and use my own level structures anyway.  Furthermore, I needed the practice.
One side effect of generating levels using cellular automata is the possibility of forming "pockets", or areas of the dungeon that are disconnected from the rest.  These are typically found using the disjoint-set structure, and this is what I did as well.  The ready implementation mentioned also included a way for joining these pockets together, but for now I decided to just fill the pockets and regenerate the level with a new seed if the size of the dungeon is too small.

In other news, I may have finally ironed out all the bugs in the FOV code, caused by floating point inaccuracies.  As a bonus, the FOV implementation now includes unit and regression tests, as well as an animated demo.

No comments:

Post a Comment