The Game of Life, also known as Conway's Game of Life or simply Life, is a cellular automaton devised by John Horton Conway. It is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves in discrete time steps called generations. There is no limit to the number of generations (computational resources permitting) or win condition
The entire game takes place on an infinite(not in my implementation of course) grid of cells that are either "alive" or "dead." The universe ticks forward in discrete generations, governed by rules applied to a cell's eight neighbors:
- Underpopulation: A live cell with fewer than 2 live neighbors dies
- Survival: A live cell with 2 or 3 live neighbors lives on
- Overpopulation: A live cell with more than 3 live neighbors dies
- Reproduction: A dead cell with exactly 3 live neighbors becomes a live cell
Despite these basic conditions, the grid doesn't just devolve into static noise. Instead, it generates recognizable, moving, and interacting structures
Because you can use patterns of cells to build logic gates (AND, OR, NOT), wire intersections, and memory registers, Conway’s Game of Life is Turing Complete. This means that, given an infinite grid and enough time, the Game of Life can compute anything that a modern computer can compute :o
People have actually built functional, working simulations of 8-bit processors, digital clocks, and even Tetris entirely out of Game of Life cells
When you let the simulation run, you start noticing recurring patterns that behave in specific ways:
- Still Lifes: Blocks that become entirely stable and never change
- Oscillators: Patterns like "blinkers" or "pulsars" that cycle through different shapes and return to their original state on a loop
- Spaceships: Patterns, like the famous "Glider," that translate themselves across the grid indefinitely
- Guns and Puffer Trains: Massive configurations that continuously manufacture and shoot out other patterns (like Gliders) forever
Because it is Turing complete, the Game of Life is subject to the same fundamental limits of computation discovered by Alan Turing. If you look at a starting configuration of cells, there is no general algorithm that can predict whether that pattern will eventually die out, stabilize, or grow forever. The only way to find out what it will do is to actually run the simulation and watch it happen :)
The logic is split into two files :
-
step.awkThis file handles the heavy lifting. It calculates the next generation of the grid based on Conway's rules (Birth and Survival) and handles the toroidal wrapping -
life.shThe main executable. It handles the terminal UI, color rendering, cursor movement, user input, and timing logic. It offloads the grid generation tostep.awk
- Interactive Grid: Initially, users have the option to manually place or remove cells anywhere on the grid using the cursor and toggle key, or they can choose from several famous default presets (e.g., Gliders, Pulsars, Gosper Glider Gun)
- Dynamic Speed Control: After starting the simulation, the user has the option to increase or decrease the generation speed in real-time, allowing for slow observation or rapid evolution
- Live Editing: At any point during the game, the user can pause the simulation and has the ability to change the state of individual cells before resuming
- Toroidal Array: The grid features wrap-around edges (a torus topology), meaning shapes that travel off the right side of the screen will seamlessly reappear on the left
| Key | Action |
|---|---|
↑ ↓ ← → |
Move Cursor |
x |
Toggle Cell (Birth/Kill) |
s |
Start/Pause Simulation |
j |
Increase Speed |
k |
Decrease Speed |
r |
Reset Grid |
1 - 5 |
Load Presets |
Ctrl+C |
Quit |
- Glider
- Pulsar
- Gosper Glider Gun
- Pentadecathlon
- Small Exploder
-
Clone this repository
git clone https://github.com/Waqibsk/CLI-of-Life.git cd CLI-of-Life -
Ensure you have standard GNU tools installed (
bash,awk,tput) -
Make the main script executable:
chmod +x life.sh
-
Run the simulator
./life.sh