Thursday, December 27, 2012

Cave Generation

And just like that...


Cave generation.

I basically did the following from this link:

"The basic idea is to fill the first map randomly, then repeatedly create new maps using the 4-5 rule: a tile becomes a wall if it was a wall and 4 or more of its nine neighbors were walls, or if it was not a wall and 5 or more neighbors were. Put more succinctly, a tile is a wall if the 3x3 region centered on it contained at least 5 walls. Each iteration makes each tile more like its neighbors, and the amount of overall "noise" is gradually reduced."

This was done with cellular automaton, similar to the game of life simulation.  Cool stuff.

You can get the source here.

No comments:

Post a Comment