Giter VIP home page Giter VIP logo

game-of-life's Introduction

John Conway's Game of Life

The game of life is a simulation of cellular automaton. Each cell is arranged in a 2-D grid and has 8 neighboring cells. The life cycle of a cell is dictated by a simple set of rules.

  • If a cell is alive and has fewer than 2 neighbors, it dies as if by loneliness.
  • If a cell is alive and has more than 3 neighbors, it dies as if by starvation due to over-crowding.
  • If a cell is alive and has 2 or 3 neighbors it remains alive.
  • If a cell is dead and has exactly 3 neighbors it spawns, as if by reproduction.

A further description of the game of life can be found at Wikipedia.

I've written a short paper on the process I went through to optimize this program. I hope it helps out anyone looking to learn how to make Haskell software fast.

Build Instructions

Requires GHC 7.6 and Haskell Platform 2013. Additional dependencies are listed in gameoflife.cabal.

  • cabal install -j

Instructions

Instructions for using the life program once installed.

The life program
  
life [OPTIONS]
  
Common flags:
  -w --width=INT      The number of cells across the game board.
  -h --height=INT     The number of cells tall.
  -c --cellwidth=INT  The number of pixels across a single cell.
  -g --genpersec=INT  The number of generations per second.
  -? --help           Display help message
  -V --version        Print version information

For example, if you wanted a game of life where the board was 100x100 and the 20 generations occurred every second, you would enter life -w 100 -h 100 -g 20 in the command line. The cell width modifier allows you to change the scale of each cell in pixels so that you can keep the whole game board on screen.

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.