<- Back to home page

Efficient Memory-Free Approach for Conway's Game of Life

May 3, 2024

This paper introduces a straightforward method for transitioning between generations in John Horton Conway's Game of Life by directly manipulating the matrix representing the cell environment.

This approach, devoid of any additional memory allocation during grid manipulation, proves advantageous in scenarios where memory constraints pose limitations.

Method

To initiate, consider a matrix filled with values denoting at least four distinct states, typically represented as 0, 1, 2, and 3. These values correspond to dead, alive, just born, and just died states, respectively. For each cell within the matrix, the number of its neighbors is determined, and its value is updated according to the prescribed rules:

  • If the cell is alive and its neighborhood is either less than 2 or exceeds 3, assign it the value corresponding to the just died state.
  • Conversely, if the cell is dead and its neighborhood count equals 3, assign it the value corresponding to the just born state.
  • In cases where the cell neither dies nor is born, its state remains unchanged.

Furthermore, during neighborhood calculation, both currently alive cells and those just died are considered alive.

Lastly, a concluding pass is requisite, which may be executed seamlessly as an independent step. This involves substituting just died cells with dead cells and just born cells with alive cells, as these states merely signify promises regarding their subsequent status.

Motivation

The initiation of my search for such a method stemmed from the desire to emulate the Game of Life on my Numworks calculator, integrating user-adjustable cell dimensions. However, I faced a practical challenge — the calculator's 320x222 screen lacked the memory capacity to store even a small portion of the desired cell count. Hence, I began shaping an approach that obviated the need for memory allocation.

You can find an implementation of this method here.



© 2024 Lokasku
Licensed under CC BY-NC 4.0 DEED.