Coder Social home page Coder Social logo

game_of_life_js's Introduction

The Game of Life

This repo currently contains 2 different implementations capable of calculating a cycle in the game of life:

  • One that is more appropriate as the core of the system that runs the game
  • One that is more appropriate as a component in a larger system (it does the calculation and gets out)

Core Implementation

This was the original implementation its reason for existing is to make displaying the actual game simpler. LifeCell can be extended to initiate events or to understand how to update a UI (I plan to do this as I find time).

I also implemented an optional world-wrapping feature in this version as that's how most versions I've played with work. With wrapping turned on, a cell at the top of the grid/world is adjacent the the same cell at the bottom and similarly for the sides.

Core Files:

  • lib/js/GridFactory.js
  • lib/js/LifeCell.js
  • lib/js/LifeGrid.js

Example: index.html (user facing interface -- feel free to play with it)

Component Implementation

This is the piece that more accurately solves the problem as stated. It uses algorithms lifted from the core implementation but doesn't do anything to make it simpler to iterate through multiple cycles like the core implementation does. This allows for a slightly more efficient run through a single iteration with the given input and output (for multiple iterations, the core implementation is better though).

Component File: lib/js/SimpleLifeCycle.js

Example: tests/spec/SimpleLifeCycleSpec.js (it will be run with the rest of the tests if you open tests/SpecRunner.html in a browser)

game_of_life_js's People

Contributors

akrikos avatar

Watchers

 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.