/MapGenerator

A javascript cellular automata based map generator

Primary LanguageJavaScript

Cave Generator

This project is an example of the application of cellular automata concepts to procedurally generate a cave-like, tile-based, map.

Example image

Rules

The matrix is initially filled randomly with a 0 or an 1. Each value of the matrix is called a cell. A 0 value means a dead cell, and an 1 value means a living cell. Then, we iterate over each cell c, verifying the number of living cells that neighbours c vertical, horizontal or diagonally. If c is a dead cell, then it becomes alive if it has more than 4 neighbours; otherwise, it remains dead. If it is a living cell, than it becomes dead if it has less than 4 neighbours; otherwise, it remains living.

Map display

The matrix will be drawn on the screen after the iteration. You generate random maps and tweak values like the size of the map or the number of iterations to run before drawing. You can run an iteration on the existing map as well, without generating another one.

Run

Just clone the repository and open index.html on your browser. No deps needed.