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 http://inventwithpython.com/)
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.
Each 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!