Coder Social home page Coder Social logo

hashislife's Introduction

hashislife

C implementation of the Hashlife algorithm


Usage

Use the make command in the src/ directory to compile hashlife:

Usage:

./hashlife (filename) (t:integer) [h:integer]

where t, and optionally h, are integer arguments. (t can be arbitrarily big, while h must hold on 32-bit)

This will simulate the game of life (with Conway's b3/s23 rule) for t time steps, and display the final state with a (de)zoom level h where one character represents a 2^h by 2^h area. (using hex to show density when h > 0)

Currently this displayed area is limited to a 32x80 grid, and the top-left corner is at the same position as in the input file.

The currently supported input formats are:

  • raw text matrices (.txt), using 'o' and '.' to denote respectively alive and dead cells. The file can start with any number of comment lines beginning with an '!', and is limited to 80 columns overall;

    Example glider.txt file:

      ! Glider example
      .....
      ..o..
      ...o.
      .ooo.
      .....
    
  • run length encodings (.rle).


Project composition

  • hashtbl: Hashtables implement quad tree "smart constructor".

  • hashlife: Hashlife algorithm, supports arbitrarily large numbers of steps.

  • bigint: Big integers.

  • darray: Dynamic arrays.

  • parsers: Parsin utilities. Currently just parsing a rule.

  • runlength: Run Length Encoder / Decoder.

  • matrix: Raw text format.

  • conversion: Converts to and from quad trees.

  • lifecount: Counting cells in a quadtree.

  • slowlife: Naive cellular automaton simulation. (old)

  • definitions: Misc. declarations (currently just one typedef)

  • main, Makefile ...


Example

$ cd src
$ make
(...)
$ ./hashlife
usage: ./hashlife (filename) (t:integer) [h:integer]
$ ./hashlife ../patterns/glider_gun.txt 1789
................................................................................
............................O...................................................
...........................OOOO.................................................
..........OO..............OO.O.O...OO...........................................
..O.......O..O...........OOO.O..O..OO...........................................
.O...OO.......O...........OO.O.O................................................
.O.....O......O............OOOO.................................................
..OOOOO.......O.......O.....O...................................................
..........O..O.........O........................................................
..........OO.........OOO........................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
..............................O.................................................
............................O.O.................................................
.............................OO.................................................
................................................................................
................................................................................
................................................................................
................................................................................
.....................................O..........................................
......................................O.........................................
....................................OOO.........................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
.............................................O..................................
...........................................O.O..................................

TODO

  1. Garbage collecting ? Mark and sweep ? Stop & copy ?

  2. Graphical display (SDL)

hashislife's People

Contributors

lysxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dalarios lu4

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.