Procedural Content Generation (PCG) creates endless replayability in roguelikes, platformers, and survival games. Combining **Cellular Automata** for organic cave structures with **Coherent Simplex/Perlin Noise** for biomes enables developers to generate balanced, navigable game worlds dynamically at runtime.
1. Cellular Automata 4-5 Cave Generation Algorithm
| Step | Algorithm Rule | Visual Output |
|---|---|---|
| 1. Random Initialization | Fill 2D grid with 45% solid wall tiles and 55% empty floor. | Static noise grid. |
| 2. Simulation Step (x4) | If wall neighbors ≥ 5, tile becomes wall; else becomes floor. | Organic, smooth cave chambers form. |
| 3. Flood Fill Culling | Identify largest contiguous cavern; wall off disconnected pockets. | Guarantees 100% reachable gameplay area. |
| 4. Autotile Bitmasking | Calculate 4-bit / 8-bit neighbor flags to select corner/edge tile graphics. | Finished rendered tilemap with clean borders. |
