Hey Clint, didn't you mention somewhere that there's a random map generator for OSARE? How's it working out thus far, and what language is it written in?
Bart
Written by OGA user Tartos in Python.
See info in this thread: http://opengameart.org/forumtopic/osare-v010-released
It's interesting so far. He's got it currently generating a 5-level deep dungeon.
From a rough perusal of the code, the general algorithm is like this:
I'll ask Tartos if he can stop by and talk about his algorithm in-depth.
Hi,
Clint has summarized it well, so I have nothing more to say :D. Here is the algorithm:
- I use a matrice with integers to generate the map. 0 for full wall, 1 for full ground and -1 for undefined. At initialization, the matrice is filled with 0. Numbers from 2 to 15 corresponds to tiles with ground and wall.
- Create X rooms with a random position, width = 3, height=3
- Keep enlarging rooms in the 4 directions. When a room meet another room, stop enlarging it.
- Remove impossible patterns : cells are put to -1 according to neighborhood conditions (e.g. 0 near 1)
- Replace all -1 with number from 0 to 15 according some rules. Using sets here to simplify the task. When the background layer is written, tiles of the corresponding class (among the 16) are taken at random
- The starting point is put as far as possible from the center of the map. The exit is put as far as possible of the entrance : usually the entrance is in a corner and the exit at the opposite corner.
What else do you want to know ? :)
This is really cool. I just recently downloaded OSARE and while playing I thought: "How difficult would it be to procedurally generate randomized levels."
I am looking forward to seeing this in action.
I was playing with Clint's town tileset. Here is the result with the same algorithm that the one I used for dungeons.
It needs some improvement as there is no diversity for roofs. For the moment I see two kinds of algorithm :
- Have some classes (e.g. grass, water, roof) and define the rules for the transitions between those tiles. For the house's tile, this would involve the creation of a third class, and define the transition between this third class and the two first (or only the second).
- Have a biased random walker (the bias is for closing houses) and define the tiles that can be used to go from one tile to another neighbor.
The first solution could be used to generate dungeons with void though.