• Skills
  • Roles
Conway’s Game of Life
Take Assessment
Note: The library is still in beta and assessments are a work in progress. Please go to https://t1.gl/assessments to view instructions on assessments.
TIME TO COMPLETE
4+ Hrs
CHALLENGE LEVEL
Basic

Conway's Game of Life is a famous simulation that demonstrates cellular automaton. It is modeled as a grid with 4 simple rules:

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies, as if by overcrowding.
4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Create a multiplayer Web app version of Game of Life, with the following functions. You can assume all users use the latest version of Google Chrome browser.

  1. Implement the Game of Life in browser. You can use any representation such as <canvas>, simple DOM manipulation or even <table> cells. The game should tick automatically at a predefined interval, at say, 1 step per second.

  2. The browser connects to an HTTP server, written in Ruby or Node.js (can be any frameworks, e.g. Ruby on Rails, Sinatra, EventMachine, Hapi or just plain listening on a socket). This server allows multiple browser to share the same, synchronized world view.

  3. Each client is assigned a random color on initialization. From the browser, clicking on any grid will create a live cell on that grid with the client's color. This change should be synchronized across all connected clients. (You can use any mechanism to achieve this, such as polling, comet or WebSocket)

  4. When a dead cell revives by rule #4 "Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.", it will be given a color that is the average of its neighbours (that revive it).

  5. To make the evolution more interesting, include a toolbar that places some predefined patterns at random places with the player's color, such as those found at here https://en.wikipedia.org/wiki/Conway's_Game_of_Life#Examples_of_patterns (not necessary to implement all, just 3 - 4 is fine).

Take Assessment