A terminal implementation of Conway's Game of Life, a cellular automaton created by mathematician John Conway. This program transforms your terminal into a dynamic playground for exploring various patterns and behaviors within the game.
- Customizable Patterns: Choose from a variety of predefined patterns like blinker, toad, beacon, and more.
- Dynamic Color Schemes: Personalize your experience with a selection of colors for cells and backgrounds.
- Flexible Configuration: Tailor the game's behavior with custom FPS settings and more through a configuration file or command-line arguments.
- Responsive Terminal Display: Watch the Game of Life unfold in real-time within your terminal.
- Prerequisites: Ensure you have Go installed on your system.
- Getting the Program:
- Clone the repository or download the source code.
- Alternatively, you can directly install the program using Go:
This command installs the program into
go install
$GOPATH/bin
. After installation, you can run the program usinggame-of-life
command in your terminal.
- Running the Game:
- Directly execute the binary after building:
./bin/game-of-life
- Or, if installed via
go install
, simply run:game-of-life
- Directly execute the binary after building:
- Command-Line Arguments:
- Optionally, specify a pattern and FPS:
game-of-life [pattern] [fps]
- Use
-h
for help:game-of-life -h
- Optionally, specify a pattern and FPS:
- During the Game:
- Press 'p' to pause/resume the game at the current turn. Once paused you can use 'space' to step through one turn at a time.
- The program looks for
gol-config.json
in the current directory or the default configuration location based on your system (e.g.,/Users/<username>/Library/Application Support/gol/gol-config.json
for MacOS, and/home/<username>/.config/gol/
for Linux file systems). - A sample configuration file:
{ "preset": "random", "cell-color": "gray", "background-color": "white", "scale-factor": 1, "fps": 23 }
- To find out the configuration directory path, use:
game-of-life cl
The game supports various patterns which are case-sensitive:
- blinker, toad, beacon, lwss, gosper-glider-gun, glider, block, random
You can choose from a range of supported colors for cells and background:
- black, maroon, green, olive, navy, purple, teal, silver, gray, red, lime, yellow, blue, fuchsia, aqua, white
- To compile the program:
go build -o bin/game-of-life
This command generates an executable in the bin directory.
- You can also build and run in one step:
go build -o bin/game-of-life && ./bin/game-of-life
- tcell Library: This project leverages the tcell library for managing terminal graphics and events.
- Conway's Game of Life: Learn more about the original concept on Wikipedia.
- cli Package: Command-line interactions are powered by the cli package.