Skip to content

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

License

Notifications You must be signed in to change notification settings

eleniums/game-of-life-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.11 or later
  • Requires GCC (Windows: follow instructions here to install MSYS2 and MinGW)
  • Requires GLFW (follow instructions here to install)
  • Uses xgo for cross-compiling with CGO
  • 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
    • Left mouse button: Add a new cell to the grid.
    • Right 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.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages