Git Product home page Git Product logo

game-of-life's Introduction

game-of-life

Conway's Game Of Life with multiple species

usage

php gol.php inputfile.xml

explicit rules

  • square world nร—n
  • m species
  • 8 surrounding cells (straight and diagonal)
  • organism surrounded by <2 same-species organisms: dies
  • organism surrounded by 2-3 same-species organisms: survives
  • organism surrounded by >3 same-species organisms: dies
  • empty cell surrounded by 3 same-species organisms: new organism
  • two organisms at one cell: random one survives, other dies

implicit rules

  • species do not influence each other (except when conflicted)
  • coordinates are 0-based, increasing (e.g. n=10 gives a 100-cell grid from [0,0] to [9,9])
  • invalid data (e.g. outside grid) are rejected with the whole import (dropping them is another option, I don't think either of these is universally applicable)

internal workings

  • GolApp checks the XML filename passed as argument
    • instantiates XmlBoardImporter, which imports the XML into a LifeBoard
    • instantiates LifeBoardCalculator
      • passes it the LifeBoard of current generation
      • LifeBoardCalculator goes through the LifeBoard and calculates what lives and what dies
      • returns new LifeBoard with new generation back
      • repeat calculation until LifeBoard->maxGenerations elapsed
    • calls XmlExporter->export() of LifeBoard to write the result to a XML

game-of-life's People

Contributors

piskvor avatar

Watchers

 avatar  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.