Code Monkey home page Code Monkey logo

conways-gol's Introduction

Conway's Game of Life

conways-gol is a Conway's Game of Life implementation using Go and OpenGL with go-gl, and was developed as part of a tutorial I wrote on OpenGL with Go.

To follow the tutorial and learn OpenGL with Go by implementing Conway's Game of Life for yourself, check out:

Conway's Game of Life

The 'Game'

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

The "game" 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, or, for advanced "players", by creating patterns with particular properties. [1]

The premise of the game is that each cell on the grid is, at any time, either dead or alive. The state of each cell is determined using the following rules:

  1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overpopulation.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

For the full rules, check Wikipedia.

Install

You can download and build directly from source like so:

$ go get github.com/KyleBanks/conways-gol

Usage

$ conways-gol

conways-gol takes a few optional parameters:

-columns and -rows

The -columns and -rows parameters dictate the size of the game board.

$ conways-gol -columns 100 -rows 100

Conways Game of Life 100x100

-seed

Each time conways-gol is launched, it uses a seed value to randomize the state of the game. The -seed parameter allows you to fix that value to replay the exact same simulation. For example, a -seed value of 9000 will always produce an identical game.

$ conways-gol -seed 9000

-threshold

In addition to the -seed, the -threshold is critical in determining the outcome of the game. The -threshold is a percentage, between 0.0 and 1.0 that dictates the chance of each individual cell starting alive or dead. For instance, if the -threshold is 0.15, it means that each cell has a 15% chance of starting the game alive.

$ conways-gol -threshold 0.1

-fps

The -fps flag allows you to configure the frames-per-second of the simulation. If you set -fps to 60, there will be sixty ticks of the game each second.

$ conways-gol -fps 60

Author

conways-gol was developed by Kyle Banks.

License

conways-gol is available under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.