An adaptation of Conway's Game of Life created with Go for a hackathon at work.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
cmd/game
game
scene
scripts
sprites
testdata
tools
ui
vendor
.gitignore
.travis.yml
Gopkg.lock
Gopkg.toml
LICENSE
Makefile
README.md

README.md

game-of-life-go

Build Status Go Report Card GoDoc License: MIT

An adaptation of Conway's Game of Life created with Go for a hackathon at work.

To see the code as it was when the hackathon finished, see Release 1.0.0.

Installation

go get -u github.com/eleniums/game-of-life-go

Run

go run ./cmd/game/main.go

Prerequisites

  • Requires Go 1.8 or later
  • Uses dep for dependencies
  • Uses pixel for graphics and input

Explanation

Conway's Game of Life is a zero player game, meaning the player sets an initial state and then sits back as the simulation is run. The simulation consists of a grid of cells that exist in one of two states, alive or dead. These cells are governed by 4 rules, based on the 8 neighboring cells surrounding any given cell:

  • If there are less than 2 living cells surrounding a living cell, it will die, as if by underpopulation.
  • If there are 2 or 3 living cells surrounding a living cell, it will continue to live.
  • If there are more than 3 living cells surrounding a living cell, it will die, as if by overpopulation.
  • If there are exactly 3 living cells surrounding a dead cell, it will become alive, as if by reproduction.

This leads to many interesting patterns and is fascinating to mess around with. Interestingly enough, it is also Turing complete, meaning it can simulate a computer. The Game of Life itself has been built with the Game of Life!

Instructions

  • Input
    • Right mouse button: Add a new cell to the grid.
    • Left mouse button: Remove an existing cell from the grid.
    • Arrow keys: Scroll around the grid.
    • Spacebar: Reset the scroll position to the default.
  • Menu
    • Start/Stop: Start or stop the simulation.
    • Store: Store current grid state in memory.
    • Reset: Reset the grid to the state saved in memory.
    • Clear: Clear the grid completely.
    • Save: Save the current grid state to a file named "saved".
    • Cells: Select the cell type to place on the grid.