Skip to content

Conway’s Game of Life on the Video Game Shield

by Wayne on January 1, 2011

We’ve had an implementation of Conway’s Game of Life on the Video Game Shield since day one, and we’re pretty proud of it. It’s got just about all the features we want. It’s controllable by a Wii controller which lets you pause or single step through the cellular automata. We also have a menu system, where you can randomise the field, or load a saved pattern out of the flash memory. It comes with 7 patterns already built in.

Today, we’re releasing an open source webapp (and some Python CLI stuff) called Lifeconvert that lets you take a Life 1.06 file and convert it to be copy-and-pastable into the Arduino sketch, in order to add your own patterns to the program.

If you wanted a turn-key Game of Life to display on anything that takes NTSC or PAL input, the Video Game Shield is it!

How to put custom patterns into the Video Game Shield Game of Life Arduino Sketch

What we’re going to do is take a Life 1.06 file, convert it through http://lifeconvert.wayneandlayne.com into the form of our Pattern struct, paste it into the right place in Patterns.h of our tv_life sketch, and then update the patterns[] array to point to the struct we just added.

Go to http://liveconvert.wayneandlayne.com. Upload a new pattern or use an example. You can also find plenty of Life 1.06 files in the LifeWiki’s Pattern category. They’re usually available for download in the sidebox of a given pattern article.

Lifeconvert Webapp

The website draws the pattern, and puts the converted struct data at the bottom.
output of lifeconvert

Copy everything after the image.

Start the Arduino program on your computer. Open up tv_life from the VideoGameHelpers example directory. Save it with a new name, maybe in your sketchbook. This way, when you make changes, if you mess something up, or just want to go back to the original, you can go back to the examples and the original will be there.

Go to the Patterns.h tab.
Patterns.h in the Arduino interface

The file will be pretty long! If you scroll down, you’ll notice that the bulk of the file is comments and structs. These structs are the life pattern data, and they’re stored in Flash memory. They don’t use up your RAM, which is limited to 2kB on most Arduinos (the ‘328 ones), but instead are stored in the program memory, which is limited to around 30kB on the Arduinos that use the ‘328 chip.

To replace one of the built-in patterns with your own, click below the line that says

#define NUM_OF_PATTERNS 7

and paste your clipboard. You should see a bunch of new stuff, which is what you copied from the Lifeconvert web page.

At the top of what you pasted in, you should see a line like

const Pattern big_s PROGMEM = {

The part “big_s” is the name, and it should be related to the pattern name you put into the lifeconvert site.

Scroll down to the bottom of the Patterns.h file.
Bottom of Patterns.h

Edit patterns[] array to have the name of your pattern in it. Make sure to make it look like the rest of the array, with the (const Pattern*) &. Remove one of the patterns you don’t want to keep, and you’re done!

Upload to your board. Press the C button to enter the menu, scroll to “Load Saved Pattern”, and the name of your pattern should show up! Select it, and sit back and enjoy.

As always, we’d like to hear any comments, concerns, rants, or ransom demands you may have.

From → Uncategorized

No comments yet

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS