Conway's Game of Life is a classic cellular automaton devised by mathematician John Conway. It is a zero-player game, meaning that its evolution is determined by its initial state, with no further input from users. The game involves a grid of cells, each of which can be either alive or dead.
The algorithm for Conway's Game of Life involves the following key steps:
-
Initialization:
- Create an initial grid of cells with each cell in either an alive (1) or dead (0) state.
-
Rules for Evolution:
- For each cell in the grid, count the number of alive neighbors (cells in adjacent positions).
- Apply the following rules to determine the new state of each cell:
- If a cell is alive and has 2 or 3 alive neighbors, it survives; otherwise, it dies.
- If a cell is dead and has exactly 3 alive neighbors, it becomes alive; otherwise, it remains dead.
-
Update:
- Replace the current grid with the newly computed grid based on the rules.
-
Rendering:
- Visualize the grid, where alive cells are typically represented by filled squares, and dead cells are represented by empty squares.
-
Repeat:
- Repeat the process for each generation, creating an animation that shows how the state of the grid evolves over time.
To run Conway's Game of Life, follow these steps:
- Open the HTML file in a web browser.
- The game will start running, and you will see the evolution of the grid based on the rules.
Feel free to experiment with different initial configurations and observe the patterns that emerge over time.
This project is licensed under the MIT License - see the LICENSE file for details.