#302 TheMatrix/GameOfLife
A simple implementation of Conway’s Game of Life on the Boldport Club Matrix.
Here’s a quick video showing it in action..
Notes
This is a quick and dirty implementation of Conway’s Game of Life on the Boldport Matrix, mainly to learn a bit more about using the AS1130 LED driver.
I’m using a Boldport Cuttle as the controller (Arduino compatible).
Game Play
I’m using the classic rules and a random seed:
- Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
If all cells die, the game automatically restarts.
If the game reaches a still life or oscillating endpoint, it will just carry on and needs a reboot to restart!
Algorithms
GameOfLife.ino uses the AS1130Picture24x5
class from the LRAS1130 library
to represent to frames: the current “tick” (round) of the game, and the next one.
Processing a game round evaluates the cells in the current AS1130Picture24x5
page,
and writes the next stage of life to the next AS1130Picture24x5
page.
The AS1130 driver is asked to switch pages on the Matrix display and then the process repeats.
It is a pretty naïve implementation of the game, and certainly not optimised.
It spends a lot of time reading pixels from a AS1130Picture24x5
page, and each time that involves
decoding the “virtual” LED/cell address into the page address.
But as it is, it runs perfectly fast enough - I even needed a delay between each game round to keep things at human speed!
Construction
Credits and References
- Conway’s Game of Life - wikipedia
- AS1130 datasheet and info
- LuckyResistor/LRAS1130 - A library to control the AS1130 LED driver chip.
- LEAP#298 TheMatrix
- ..as mentioned on my blog