For example, in the Diablo series, dungeons are pseudo-randomly generated. The benefits of this are two-fold. Players never see the same dungeon twice, adding replay value, and developers didn't have to go through and setup each dungeon manually.
I wanted to experiment with this concept. I decided to start as simplely as possible, a random maze generator. Algorithms exist for this problem and can be easily found via Google, but I decide to roll my own for my first try.
My maze generator basically works like this:
- Generate an m-by-n array of #'s (#'s denote and impassable tile)
- Randomly pick 2 tiles (a start and end point) and mark them "S' and "E" respectively
- Clear a path between the start and the end (replacing the #'s with .'s). My algorithm just starts at the start point and moves around randomly until it gets to the end point.
Sometimes I generate decent mazes like:
Or:
Other times, I get something way too easy like:
So, what have I learned? Generating content purely randomly often doesn't work out too well. Also, random levels aren't that fun.
I'm going to try to implement a real maze building algorithm and see how that goes.