Conway's Game of Life 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.
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 neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- 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.
Explanations are taken from Wikipedia and further explanation can be found here.
Default mode for the implementation is random mode. Basically it initializes the board with randomly selected live cells. It is good for having different combinations each time you start the game.
A glider looks like the following:
A glider is a combination that game rules enables it to move like a living object. Basically, it is a pattern that travels across the board. Gliders are the smallest spaceships, and they travel diagonally at a speed of one cell every four generations.
This mode starts the board with a glider.
The Gosper glider gun is the first known gun, and indeed the first known finite pattern with unbounded growth, found by Bill Gosper in November 1970. It consists of two queen bee shuttles stabilized by two blocks. Its 36 cells remained the smallest size of any known gun until the discovery of the double-barreled Simkin glider gun in 2015 which overtook this record with only 29 cells.
This mode starts the board with a Gosper glider gun.
The Simkin Glider Gun is a glider gun found by Michael Simkin and it is the smallest known gun.
This mode starts the board with a Simkin glider gun.
Get the source with the following commands.
go get -u github.com/safakozdek/Game-of-Life
go install github.com/safakozdek/Game-of-Life
- Build the code.
go build game-of-life
- Run by using completely optional flags.
./game-of-life [flags] Flags: --mode=0 Sets the game mode. Default value is 0. --fps=20 Sets the frame per second. Default value is 10. Suggested range: 6-60
This is my first project in Go. My aim was to getting familiar with a go project in general. That's why I have written this completely unnecessary code and readme. If you are reading this, then my job in here is done.
Pull-requests, issues, comments and stars are always appreciated!