Giter Site home page Giter Site logo

conway3d.js's Introduction

conway3d.js

Conway's Game of Life, in 3D, in Javascript.

Example:

var c3d = new Conway3D(width, depth, height, lonely, crowded);

var updates = c3d.update();

The Conway3D constructor takes three integer values for the width, height, and depth of the game field, and two integer parameters governing the game mechanics - lonely and crowded. The rules work like so:

If the number of live neighboring cells <= lonely OR the number of live neighboring cells >= crowded, a cell will die if it is alive. Otherwise, it will come to life or continue to live.

Each call to the update function applies these rules to all the cells, and returns a list of changes to the field in the following format:

[x1, y1, z1, c1, x2, y2, z2, c2, ..., xn, yn, zn, cn]

Where x, y, and z are the coordinates of the change, and c is an integer representing the nature of the change: 0 if the cell dies, 1 if the cell is brought to life. These changes could be used to update a visualization of the field. I've kept the format simple here to avoid garbage collection issues when performing fast-running simulations and visualizations.

Note: The first time update is called, the field is initialized with a random walk, and the result of that walk is returned in the updates. It is not the result of applying the rules.

conway3d.js's People

Contributors

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