Sorry for the clickbait title, it was low hanging fruit.
Today I’ll be adding Conway’s Game of Life to VoxyGen. If you’re not familiar, it is a zero-player simulation “game” with simple rules, but it has been studied extensively by mathematicians and scientists for decades.
“Life” takes place on a two dimensional grid. Each “turn”, all of the “cells” are evaluated to generate the next iteration. This can repeat indefinitely.
Here’s an example of a famous structure, dubbed Gosper’s Glider Gun, that creates knots of traveling cells:

Life operates by a simple set of rules:
- If a cell is ON and has fewer than two neighbors that are ON, it turns OFF
- If a cell is ON and has either two or three neighbors that are ON, it remains ON.
- If a cell is ON and has more than three neighbors that are ON, it turns OFF.
- If a cell is OFF and has exactly three neighbors that are ON, it turns ON.
From this, there are many possibilities for patterns and structures, with interesting new ones being discovered all the time.
The implementation is pretty straightforward:
def life_layer(old_layer, color):
x_size = len(old_layer)
y_size = len(old_layer[0])
new_layer = np.zeros((x_size, y_size), dtype=int)
for x in range(x_size):
for y in range(y_size):
neighbors = count_neighbors(old_layer, x, y)
if old_layer[x][y] != 0: # alive
if neighbors < 2:
new_layer[x][y] = 0
elif neighbors == 2 or neighbors == 3:
new_layer[x][y] = color
elif neighbors > 3:
new_layer[x][y] = 0
elif neighbors == 3:
new_layer[x][y] = color
return new_layer

Wow, that’s pretty interesting. Right away, we can see some of the classic formations.
Front and center, you can see a static beehive:
Way off to the right, you can see a simple blinker:

And a bit to the left you can see the formation of a stable block:

There’s a lot of creative potential here for injecting some nice, organic randomness into your generated models.
What about some fun stuff? Lets make a glider shape, which you can see being emitted from Gosper’s Gun earlier in this post. This shape will repeat itself forever, flying away into the void.

Cool, but lets try a pulsar

Sweet. The pattern injection code is against the spirit of generative art… but in the spirit of the game of Life, I’ll let it slide.
Next time I’ll experiment with further parameterizing the game to allow greater flexibility in rules.
As always, this is available on the VoxyGen Gitlab.
Happy lifing, yall.



