edmt / golife

John Conway's Game of Life simulation written in Go

Home Page:https://freshman.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Golife - A Game of Life project

Go Report Card Codacy Badge HitCount PR's Welcome

Simulate John Conway's Game of Life in your terminal. TUI is powered by tcell.

Note: This project was made as part of the Project52 challenge in order to improve my Go skills.

Demo

asciicast

Features

  • Supports the standard Game of Life rules as well as other variations such as HighLife, Amoeba, and others (see rules).
  • It can simulate preset patterns in the RLE, Life 1.06, or Plaintext formats (thanks to life).
  • Supports simulation speed increment of decrement.
  • Supports stepping through the simulation, one generation at a time.
  • Supports themes (limited for now).

Installation

If you have Go installed, you can use the following command to install Golife:

$ go get github.com/ayoisaiah/golife/cmd/...

Alternatively, precompiled binaries are available for Linux, Windows, and macOS here (only for amd64).

Usage

Basic usage:

$ golife

See demo

Preset patterns

RLE, Life 1.06 and Plaintext patterns are supported by Golife. For example, here's a huge list of Game of Life patterns in the RLE format. Very large patterns may not wwork at this time.

You can load a preset pattern from a file (example):

$ golife --file gosperglidergun.cells

See demo

Or you can load a preset pattern from a URL:

$ golife --url "http://copy.sh/life/examples/spider.rle" --input-format rle

See demo

Rules

The default GoL rules are as follows:

  • Any live cell with two or three live neighbours survives.
  • Any dead cell with three live neighbours becomes a live cell.
  • All other live cells die in the next generation. Similarly, all other dead cells stay dead.

However, Golife supports other variants as well. You can list them all using the following command:

$ golife rules
Default:
Survives: [2 3], Born: [3]

DayAndNight:
Survives: [3 5 6 7 8], Born: [3 6 7 8]

Coral:
Survives: [4 5 6 7 8], Born: [3]

2x2:
Survives: [1 2 5], Born: [3 6]

34Life:
Survives: [3 4], Born: [3 4]

Amoeba:
Survives: [1 3 5 8], Born: [3 5 7]

Assimilation:
Survives: [4 5 6 7], Born: [3 4 5]
...

Select a rule:

$ golife --rule Amoeba

See demo

Themes

List available themes.

$ golife themes
WhiteOnBlack
BlackOnWhite

Select a theme:

$ golife --theme BlackOnWhite

See demo

Help

$ golife --help

Credits

Golife relies heavily on other open source software listed below:

Contribute

Bug reports, or pull requests are much welcome!

Licence

Created by Ayooluwa Isaiah and released under the terms of the MIT Licence.

About

John Conway's Game of Life simulation written in Go

https://freshman.tech

License:MIT License


Languages

Language:Go 100.0%