Saturday, February 28, 2015

Experiments with Procedural Generation, Part 3

Cave Level Generation: The 4-5 Rule 

Tools: LUA, Love2D, ZeroBrane Studio

I was playing around with my Game of Life project a few weeks ago and I decided to put this together really quick. This is just a quick implementation of the 4-5 rule, often used for procedural cave-like level generation. It was a quick change and only took a few minutes to put together, but the effect is interesting so I figured I'd share it here.

 

The 4-5 Rule
At the start the entire grid is filled with noise. In this example every tile has a 53% chance of being white.

Every step two simple rules are applied to every tile:
- If the tile is black: If 5 or more of the adjacent tiles are white, it becomes white.
- If the tile is white: If 4 or more of the adjacent tiles are white, it stays white.

More work would need to be done to generate any real levels from the result due to all of the disconnected rooms that are generated from this, but there are several solutions which are all pretty easy to implement.

No comments:

Post a Comment