Skip to main content
⠀⢀⣤⣤⣤⣤⣀ ⠀⠀⢸⣿⣿⣿⣿⣿⣷⡀ ⠀⠀⠘⠉⠉⠙⣿⣿⣿⣷ ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣧ ⠀⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣆ ⠀⠀⠀⠀⠀⣼⣿⣿⣿⣿⣿⣿⡀ ⠀⠀⠀⠀⣴⣿⣿⣿⠟⣿⣿⣿⣷ ⠀⠀⠀⣰⣿⣿⣿⡏⠀⠸⣿⣿⣿⣇ ⠀⠀⢠⣿⣿⣿⡟⠀⠀⠀⢻⣿⣿⣿⡆ ⠀⢠⣿⣿⣿⡿⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⡇ ⢀⣾⣿⣿⣿⠁⠀⠀⠀⠀⠀⠈⠿⣿⣿⣿⡇
Background image

Real-time collaborative Game of Life

A never-ending, real-time collaborative simulation of Conway's Game of Life.

Open project
  • Experimental
  • JavaScript
  • WebSockets

About This Demo

I have always been fascinated by cellular automata, in particular by Conway's Game of Life. I have seen many versions, but I had never seen a real-time collaborative one. In this small project, I bring the magic of RTC (real-time collaboration) to the Game of Life so that every user who loads the game interacts with the same board.

The Game of Life was created by the late British mathematician John Horton Conway in his pursuit of a set of rules that could create life-like patterns. The game is a zero-player game, meaning that its evolution is determined by its initial state and requires no further input. Conway drastically simplified an earlier automaton by John von Neumann, which contained several complex rules.

Conway's model appeared on page 120 of the October 1970 issue of Scientific American and contributed to his widespread recognition in mathematics.

Game of Life Rules

Let's say we have a chessboard-like grid and a bunch of pawns that we will call *living cells* from now on. If there is a *living cell* on the board, that square is considered alive. If it's empty, that square is considered dead. These two states can be represented easily on a computer using the binary system, where **1 represents a living cell** and **0 represents a dead cell**. Now imagine that you randomly place 5 living pawns on an 8x8 board and end up with the following pattern. This is called generation 0. To compute the next generation, we follow these 4 rules:

The rules are as follows:

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

These rules, albeit simple, can create "life-like" patterns that can evolve in very complex ways. For example, the following pattern is called a glider and it moves diagonally across the board. Starting with the cells,

[0010101001100000] \begin{bmatrix} 0 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix}
the next generation would be,
[0100001101100000] \begin{bmatrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 1 \\ 0 & 1 & 1 & 0 \\ 0 & 0 & 0 & 0 \end{bmatrix}
and then,
[0010000101110000] \begin{bmatrix} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 1 & 1 \\ 0 & 0 & 0 & 0 \end{bmatrix}
then,
[0000010100110010] \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix}
and finally,
[0000000101010011] \begin{bmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 1 \\ 0 & 0 & 1 & 1 \end{bmatrix}

This last pattern is the same as the first one, but it has moved one square to the right and one square down. Therefore, this pattern travels diagonally across the board. This pattern is stable and dynamic at the same time.

Not all patterns are stable and dynamic; some are simply stable and do not move. These are also interesting because they can act as the "heartbeats" of more complex patterns.

Here is another stable example that appears to be formed by the meeting of two distinct patterns. Unlike the typical outcome where two patterns collide and destabilize each other, often leading to their collapse and eventual disappearance, these two patterns defy expectations.

Here is another interesting glider that partially cancels out travel along the Y-axis, making it move only along the X-axis. This phenomenon occurs through the careful manipulation of the glider's trajectory, where its inherent vertical motion is counterbalanced by a temporary pattern.

In this other configuration, four stable patterns come together to form a captivating flower-like design. Each pattern, stable on its own, is positioned in such a way that they collectively create a symmetrical and visually striking arrangement. The Game of Life is full of surprises.

The Demo

In this demo, I implemented the Game of Life using JavaScript and WebSockets. The board is shared among all users in real-time, so every change is reflected immediately for everyone. The server keeps track of the board state and applies the rules to compute the next generation every second. Users can click on any square to toggle between alive and dead, and that change will be visible to all other users.

Further Steps

A few additional ideas about where I want to take this project are the following:

  • Making a spherical topology so that there are no boundaries.
  • Making a non-discrete version (i.e. like a fluid simulation).
  • Adding different races of cells that interact with each other.
  • Adding a reinforcement learning reward/punishment system so that the rules can evolve.