A simple implementation of Conway's Game of Life in C.
- Compile the program with
gcc -o run run.c
- Run the program with
./run
The program uses a 2D array to represent the grid of cells. Each cell is
either alive (represented by a #
character) or dead (represented by a
space character). The program then iterates over the grid, applying the
rules of the Game of Life to determine the state of each cell in the next
generation.
The rules of the Game of Life are as follows:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
The program can be configured by modifying the following constants at the top of the file:
WIDTH
: the width of the gridHEIGHT
: the height of the gridITERATION
: the number of iterations to run the program forSPEED
: the number of milliseconds to wait between each iteration
This program was written by MUCKA & comment by Codeium AI. The Game of Life was invented by John Conway.