Conway's Game of Life in Javascript
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hi,

I'd like a simple version of Conway's game of life in Javascript.

Specifications:

  • Parameters: turn speed, board length, board width, size of "game pieces" in pixels (they're square)
  • No need to make it pretty (it's fine if it looks like a qr code)
  • It should not have any buttons; it should run when it loads, starting with a random configuration.
  • Please provide a complete working example (html + js).
  • jQuery is fine

Let me know if you have any questions. Thanks!

awarded to dystroy
Tags
javascript

Crowdsource coding tasks.

1 Solution

Winning solution

You may test and download my version there.

Two files to download :

You can start it like this :

var gol = new Gol({
    boardWidth: 50,
    boardHeight: 40,
    cellSize: 5,
    canvasId:'gol_canvas',
    period: 400
});
gol.randomize();
gol.start();

Or, if you want a glider (or more), like this :

var gol = new Gol({
    boardWidth: 50,
    boardHeight: 40,
    cellSize: 5,
    canvasId:'gol_canvas',
    period: 400
});
gol.addGlider(5, 5);
gol.start();

Note that :

  • it doesn't use jquery
  • it's easy to customize, for example to adapt the size to the screen, resize event handling is included
@dystroy Thanks, this is just what I was looking for.
bevan 9 years ago