Skip to content

raphaelsenn/gameoflife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game Of Life

gif

  • Note: GIF with 10fps (not accurate to real simulation in terminal)

The universe of the Game of Life is an infinite, two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead (or populated and unpopulated, respectively). Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

Rules

  • 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.

Initial state is random (you can choose probability for: cell alive)

Dependencies

  • C compiler (gcc or clang, or everything that compiles C code)
  • Ncurses libary (retro 1990's C libary for terminal plotting)

Install ncurses

Linux (debian based)

sudo apt update
sudo apt install libncurses-dev

Mac (apple sillicon)

brew install ncurses

Usage

Commands in Simulation

  • Press q to quit
  • Press 'space' to start or pause the simulation
  • Press r to create random cells

Compile and link

gcc -c simulation.c
gcc -c main.c
gcc -o main simulation.o run.o -lncurses

Execute

./main

About

Game Of Life inside the terminal using C and ncurses libary.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages