Giter Site home page Giter Site logo

hlife's Introduction

hLife

This is a simple implementation of Conway's Game of Life. Mostly it's just me playing around with Haskell again after a while away. The original motivation is to develop some code that's a goal for teaching my kids some programming. I remember learning about and writing an implementation of Life in the mid-80s and hope my kids might be similarly fascinated by it. We'll see how that goes... Also, it's a chance to play with the Gloss library.

Building

If you have a reasonably complete Haskell installation, you can probably get away with just simply building the main file as follows:

ghc --make hLife.hs

This will produce hLife as an executable which gives a console version of Life complete with a simple menu.

Or, you can use the spiffy cabal file which probably needs some love, but works for me for the moment:

cabal install --prefix=$SOMEWHERE --user

No guarantees I've done this right as I've not done it before...

Running

The console version has a simple menu to drive its operation. To quit the Gloss version, try the escape key ;)

Usage

hLife [OPTION...]
  • -s SIZE --size=SIZE board size as x. Default size 50x50
  • -g --gloss use the Gloss graphical interface
  • -f FILE --file=FILE read the supplied input file (will center in SIZE)
  • -q SQUARE-SIZE --square=SQUARE-SIZE the size, in pixels of a square (assumes -g). Default 10

The file option is not supported yet, but will read a file of the following format:

! This is a comment
....O
.....O
...OOO
! the above is a glider

The idea is that the input as read from the file will be centered in the specified board size. So if the above was read in with a specified height of 5, then there would be two complete empty lines, one above and one below the glider. Similarly for the width, the longest line will be used to determine the placement horizontally within the specified size.

Future

Hopefully I'll implement some more features soon, like choosing the board size, or perhaps loading a file. We'll see. Also, I'd like to rewrite the code in Literate Haskell as a teaching tool, time and motivation permitting.

All comments welcome.

hlife's People

Stargazers

Michael Lange avatar

Watchers

Andrew Sackville-West avatar James Cloos avatar

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.