How To Program Conway’s Game of Life on #RaspberryPi #piday @Raspberry_Pi


Trevor Appleton created a tutorial to create Conway’s Game of Life in Python on Raspberry Pi

While looking through a few programming forums I kept noticing people with a slightly odd looking avatar.

I thought that for the same emblem to keep cropping up it must have some meaning, but I had no idea what that was.

It took a few attempts at googling to find the symbols meaning. Trying to describe a symbol to google is not easy! I found that the symbol was derived from Conway’s Game of Life. The symbol represents a Glider which is sometimes created during the Game of Life. The reason people use it as an avatar is because the symbol has been adopted by the hacking community in a similar way that Linux has Tux as its emblem.

Reading about the Game of Life on Wikipedia I became quite interested in the concept.

The Game of Life is in short a simulation of a group of cells. At every step in time, often referred to in the game as a tick, cells live or die depending on their surroundings.

There are four rules which are applied simultaneously to all the cells in the game.

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
2. Any live cell with two or three live neighbours lives on to the next generation.
3. Any live cell with more than three live neighbours dies, as if by overcrowding.
4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

However I made my mind up that it must be too difficult to program, so I filed it away as one of those things to try when I am a better programmer.

For various reasons I was drawn towards giving pygame a whirl. I had played around with it in the past and felt it might potentially offer a nicer way to display certain things than Tkinter, which is my default for any GUI work in Python. I felt there was some potential there other than for writing games.

I learnt to program in Python using the free book ‘Invent Your Own Computer Games with Python’ by Al Sweigart. I cannot rate this book highly enough. If you want to learn Python, use this book. It is that good.

I knew he had also written a book aimed at teaching the basics of pygame. After my great experience with his first book, I thought I could not go wrong with his book called ‘Making Games with Python and Pygame’. (These two books plus his latest book ‘Hacking Secret Ciphers with Python’ can be found on the website

I skimmed through the first few chapters of this book and knowing I learn better by doing, I thought I would crack on and write my own game. But what? Having seen that the first of the games in the pygame book revolved around a grid system, I thought I could always try and write a version of the Game of Life. I still had a feeling it would be too difficult, but I was up for the challenge.

After starting and finishing the program much quicker than anticipated, and once again astounding myself with how easy things are to do in Python, I thought it would make a great blog post.

Pygame comes as standard on the Raspberry Pi however if you are using a different platform for programming then you can download it from here:

This tutorial will lead you through my thought process for developing and creating this game. There will be a link to the code at the end for those who want to download it. 🙂

I am going to assume you know how to start programming in Python. If not I have a previous blog which should get you up to speed.

Full Tutorial

998Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!

Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here:

Join Adafruit on Mastodon

Adafruit is on Mastodon, join in!

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 36,000+ makers on Adafruit’s Discord channels and be part of the community!

CircuitPython – The easiest way to program microcontrollers –

Maker Business — “Packaging” chips in the US

Wearables — Enclosures help fight body humidity in costumes

Electronics — Transformers: More than meets the eye!

Python for Microcontrollers — Python on Microcontrollers Newsletter: Silicon Labs introduces CircuitPython support, and more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

Adafruit IoT Monthly — Guardian Robot, Weather-wise Umbrella Stand, and more!

Microsoft MakeCode — MakeCode Thank You!

EYE on NPI — Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — #NewProds 7/19/23 Feat. Adafruit Matrix Portal S3 CircuitPython Powered Internet Display!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at !

No Comments

No comments yet.

Sorry, the comment form is closed at this time.