GithubHelp home page GithubHelp logo

gogameoflife's Introduction

Conway's Game of Life

GO implementation of "The Game of Life", also known simply as Life, devised by the British mathematician John Horton Conway in 1970.

You can read about the rules at Wiki

Naive approach used with two arrays for storing current and next generation states.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for testing purposes.

Prerequisites

To be able to run the game locally you should have

linux machine
git tool
docker or golang installed

Quick start with Docker

cd ~
git clone https://github.com/spaiz/gogameoflife.git && cd gogameoflife
docker build --rm -t golife .

To play the game in RANDOM mode, run:

docker run -it --rm --name="game_of_life" golife -random=50 -density=4 -delay=100

To play the game in MANUAL mode, you must provide path to the file with input data:

docker run -v $PWD/data/:/data -it --rm --name="game_of_life" golife -file=/data/input.txt

Running the tests

cd ./tests
go test -v

Game modes

Random mode:

You can start the game in "RANDOM" mode by providing an "-random" parameter as a positive non zero integer, that will be used as desk size.

This command will run the game with generated 100x100 desk and initial data with live cells population density level 3. New generation will be created every 500 milliseconds.

golife -random=100 -density=3 -delay=500

Manual mode:

Text file may be used as initial data source. Please see test data in the file "./data/input.txt". An valid file is a text file, where the number of symbols in each line equals the number of lines. (NxN matrix). A live cells represented by big "O".

By default, application will look for "input.txt" file in the current working directory.

Example:

cd ./data/
golife -delay=1000

Or with a custom file path:

golife -file=/path/to/your/file/input.txt -delay=1000

Install

If you have GO installed locally, you can compile and run the game locally. All dependencies are already included in the repository.

cd ~
git clone https://github.com/spaiz/gogameoflife.git && cd gogameoflife
cd ./cmd/golife
go install
golife -random=100 -density=3 -delay=200

Command Line parameters

Please, use the next command to see all available flags and their default values.

golife -h

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.