Created
October 24, 2012 21:56
-
-
Save ebonneville/3949171 to your computer and use it in GitHub Desktop.
Basic cellular automata algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Scatter wall blocks across the level at a 30-40% saturation level (I've found that 39% is ideal). | |
2. Iterate through all the tiles on the map four times: | |
- For each tile in each iteration, set the tile to be floor. | |
- Then, calculate the number of wall tiles within both one square of the original tile (these are neighbors) and two squares (these tiles are nearby). Store these numbers. | |
- If the number of neighbors for the tile is greater than or equal to 5, or there are less than two wall tiles nearby, set this tile to be a wall. | |
- If it is not a wall already, leave this tile as a floor tile. | |
3. Iterate through all the tiles on the map three more times: | |
- For each tile in each iteration, set the tile to be floor. | |
- Calculate the number of wall tiles within both one square of the original tile. | |
- If this tile has five or more neighboring walls, make it a wall. Otherwise, leave it as a floor tile. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment