radiosparks
Well-known member
[ Introduction ] What inspired me. 
It's about the code. This forum is long lived and is a great resource for just about anything you could dream up. Seems like all the fun has already been created. I just wanted to add my version of fun coding.
Recently featured on Codepen's "SPARK"
was a themed collection of various versions of Conway's Game of Life.
To find inspiration I searched the Forum and found a long, very old, thread of the "Masters" showing off their coding designs. The most advanced coding techniques from @PaulRB
by using parallelism via bitwise logic and created a fast 2-bit adder tree. Far too advanced for my old brain, but impressive to study.
[ Hardware Setup ] PICAXE + MAX7219
For fun, I put together my own version of Life … using the PICAXE 08M2 and a MAX7219 with a 8X8 Matrix display using my previous post of a bargraph setup.

[ Display Concept ] TORUS topology
The matrix display is set up as a TORUS which has a single surface with no edges or boundaries — you can travel along it forever without hitting an edge. This also allows the Life form patterns to interact with themselves and run over each other.
[ Rule Variation ] Simplified Life Rule Errors
A happy coding accident produced this alternate version of Life by simplifying the rules: 3 or 4 neighbors create Life; everything else Dies. On an 8×8 LED matrix this generates rich behavior — sometimes longer-running patterns, fewer stagnant ponds, and plenty of motion (think swirling loops, drifting blobs, and generally lively feel).
A small snippet of the Life logic is included below due to the forum’s file-size limits; the full program can be downloaded at the end of the post.
The original Conway rules are still in the code — simply REM the MARS line and un-REM the LIFE line to switch between them.
[ Adding Entropy with Light ]
One challenge with microcontrollers like the PICAXE is that their random number generators aren’t truly random. To inject a bit of unpredictability, I added my Ambient Light Sensor (see my post
).
Depending on the light levels in the room, the sensor feeds entropy into the system and seeds the random number generator with a fresh start value. This makes each generation of Life feel unique and creates a continuous action. Although, a lot of patterns will still repeat.
[ VIDEO ]
The video demonstrates version 2b of the project. Version 2c, described above, includes speed improvements and runs the patterns more smoothly.
[ Links & Resources ] Code and Life References
I won't go into a long tutorial of how it works, see references below will give you plenty of rabbit holes to explore.
Conway's Game of Life, has anyone done it with a PICAXE?
Wikipedia Description of Conway's Game of Life:
en.wikipedia.org
Rosettacode.org
contains almost every version of code for any level of computer language. Very interesting to see all the other ways people have coded this simple function.
Rosettacode Game of Life Variations:
Smallest Physical Implementation of Conway's Game of Life... Probably? Utilizes a Microchip PIC10F320
microcontroller in a 6-pin SOT-23 package! Written in assembly code (source available) and generates it's own analog video signal. A must read!
Worlds Smallest Life:
Universal Engineering Meme : "Can it play DOOM?"

It's about the code. This forum is long lived and is a great resource for just about anything you could dream up. Seems like all the fun has already been created. I just wanted to add my version of fun coding.
Recently featured on Codepen's "SPARK"
To find inspiration I searched the Forum and found a long, very old, thread of the "Masters" showing off their coding designs. The most advanced coding techniques from @PaulRB
[ Hardware Setup ] PICAXE + MAX7219
For fun, I put together my own version of Life … using the PICAXE 08M2 and a MAX7219 with a 8X8 Matrix display using my previous post of a bargraph setup.

[ Display Concept ] TORUS topology
The matrix display is set up as a TORUS which has a single surface with no edges or boundaries — you can travel along it forever without hitting an edge. This also allows the Life form patterns to interact with themselves and run over each other.
[ Rule Variation ] Simplified Life Rule Errors
A happy coding accident produced this alternate version of Life by simplifying the rules: 3 or 4 neighbors create Life; everything else Dies. On an 8×8 LED matrix this generates rich behavior — sometimes longer-running patterns, fewer stagnant ponds, and plenty of motion (think swirling loops, drifting blobs, and generally lively feel).
A small snippet of the Life logic is included below due to the forum’s file-size limits; the full program can be downloaded at the end of the post.
The original Conway rules are still in the code — simply REM the MARS line and un-REM the LIFE line to switch between them.
Code:
' ---[ Core Function ]---
Game_Of_Life:
'// Do Bit-Flip for RAM cell array offsets
read_Offset = read_Offset XOR %00001000
write_Offset = read_Offset XOR %00001000
numCells = 0
for y = 0 to Cells ; used as MAX7219 Digit/BYTE Register (Y)
'// Calc Read_Buffer addresses for Row BYTE Offsets
addressT = y + 255 // 8 + read_offset
addressC = y + read_offset
addressB = y + 1 // 8 + read_offset
'// Peek/Poke Write_Buffer Current Cell address
addressW = y + write_offset
'// Set current BYTES for testBIT
peek addressT, i
peek addressC, j
peek addressB, k
for x = 0 to Cells
countCELLS = 0
'// IF:ELSE faster than SELECT:CASE
if x = 0 then ; Handle edge wraparound Cells
testBIT = i : countCELLS = bit31 + bit25 + bit24
testBIT = j : countCELLS = countCELLS + bit31 + bit25
cell_State = bit24
testBIT = k : countCELLS = countCELLS + bit31 + bit25 + bit24
else if x = 1 then
testBIT = i : countCELLS = bit26 + bit25 + bit24
testBIT = j : countCELLS = countCELLS + bit26 + bit24
cell_State = bit25
testBIT = k : countCELLS = countCELLS + bit26 + bit25 + bit24
else if x = 2 then
testBIT = i : countCELLS = bit27 + bit26 + bit25
testBIT = j : countCELLS = countCELLS + bit27 + bit25
cell_State = bit26
testBIT = k : countCELLS = countCELLS + bit27 + bit26 + bit25
else if x = 3 then
testBIT = i : countCELLS = bit28 + bit27 + bit26
testBIT = j : countCELLS = countCELLS + bit28 + bit26
cell_State = bit27
testBIT = k : countCELLS = countCELLS + bit28 + bit27 + bit26
else if x = 4 then
testBIT = i : countCELLS = bit29 + bit28 + bit27
testBIT = j : countCELLS = countCELLS + bit29 + bit27
cell_State = bit28
testBIT = k : countCELLS = countCELLS + bit29 + bit28 + bit27
else if x = 5 then
testBIT = i : countCELLS = bit30 + bit29 + bit28
testBIT = j : countCELLS = countCELLS + bit30 + bit28
cell_State = bit29
testBIT = k : countCELLS = countCELLS + bit30 + bit29 + bit28
else if x = 6 then
testBIT = i : countCELLS = bit31 + bit30 + bit29
testBIT = j : countCELLS = countCELLS + bit31 + bit29
cell_State = bit30
testBIT = k : countCELLS = countCELLS + bit31 + bit30 + bit29
else if x = 7 then ; Handle edge wraparound Cells
testBIT = i : countCELLS = bit31 + bit30 + bit24
testBIT = j : countCELLS = countCELLS + bit30 + bit24
cell_State = bit31
testBIT = k : countCELLS = countCELLS + bit31 + bit30 + bit24
end if
'// Once the code above finishes we find out if the test Cell lives or dies
read x, BITmask ; fast bit mask lookup for test Cell
'// Write Buffer Cell State
peek addressW, result
'// Life on MARS!
if countCELLS = 3 or countCELLS = 4 then
'// Conway's Game of Life Rules
'if countCELLS = 3 or cell_State <> 0 and countCELLS = 2 then
'cell_State = 1 ; "It's alive! Boris"
result = result or BITmask
inc numCells
else
'cell_State = 0 ; always DEAD
result = result andnot BITmask
endif
'// Store result in Write Buffer
poke addressW, result
next x
next y
inc Generations
'// Seed Random 4X4 Cell Area if still life or oscillator running too long
if Generations > 31 or numCells < 5 then
'call Preset_Life
call random_GEN
'call show_Life
'pause 5000
Generations = 0
end if
return
[ Adding Entropy with Light ]
One challenge with microcontrollers like the PICAXE is that their random number generators aren’t truly random. To inject a bit of unpredictability, I added my Ambient Light Sensor (see my post
Depending on the light levels in the room, the sensor feeds entropy into the system and seeds the random number generator with a fresh start value. This makes each generation of Life feel unique and creates a continuous action. Although, a lot of patterns will still repeat.
[ VIDEO ]
The video demonstrates version 2b of the project. Version 2c, described above, includes speed improvements and runs the patterns more smoothly.
[ Links & Resources ] Code and Life References
I won't go into a long tutorial of how it works, see references below will give you plenty of rabbit holes to explore.
Conway's Game of Life, has anyone done it with a PICAXE?
Wikipedia Description of Conway's Game of Life:
Conway's Game of Life - Wikipedia
Rosettacode.org
Rosettacode Game of Life Variations:
Smallest Physical Implementation of Conway's Game of Life... Probably? Utilizes a Microchip PIC10F320
Worlds Smallest Life:
Universal Engineering Meme : "Can it play DOOM?"
Attachments
Last edited: