, , , , ,

Game of Life

Reading Time: 3 minutes

John sadly passed away in April this year but his creation lives on, not only in memory but in different manifestations. One of the most intriguing – from our perspective at least – is a version run on a Raspberry Pi. It has been produced by software engineer Nick Kelly, and it uses the same fixed set of rules that has served the simulation well over the years.

Nick is a software engineer living in San Francisco whose life changed when a friend introduced him to Python and web development.

See the GitHub page for this project and follow Nick Kelly on Twitter.

“It started as a C# assignment for one of my engineering classes at university, so I had a lot of direction and criteria for what was expected,” Nick tells us. “In terms of architecture, I usually take a very object-oriented approach, but since Python was new to me at the time, I went down the functional route.”

To allow the changes to be observed, John Conway originally used a program written by MJT Guy and SR Bourne for a PDP-7 computer with a screen (Credit: Tore Sinding Bekkeda, CC SA 1.0)

Game of Life Fast Facts

  • It will run using any Raspberry Pi computer

  • The code could work in an infinite space

  • The game is governed by four defined laws

  • It’s about overpopulation and evolution

  • Once run, it needs no further interaction

That’s life (on Raspberry Pi)

The project consists of a Raspberry Pi 2 computer, four 8×8 Adafruit LED grids, and the code. The panels each use Adafruit’s FadeCandy, a NeoPixel driver that has built-in dithering and connects to a Raspberry Pi over USB. This allows the LEDs to illuminate or switch off depending on the Game of Life’s set of rules.

But what are they? Well, the simple premise is that you have a set of cells, some alive and some dead, behaving in accordance to what is going on around them in the adjoining eight squares. This leads to very complex behaviour and patterns. If there is a live cell with either one or fewer live neighbours, or if there are more than four live neighbours, then that cell will die. If there are two or three neighbours present, then it will remain alive. Dead cells become alive when there are three live neighbours around them, otherwise they remain in a deceased state.

“Designing it wasn’t a challenge, but there were plenty of challenges during development,” Nick says. “Along with Python, I was also getting a very intense primer to web development and networking. Remote environments, monkey patching, GPIO – these were all foreign terms to me.”

Controlling LEDs in Python

Delving into a real-world project, he says, provided a perfect way to familiarise himself with a new language. “My boss at work helped me out quite a bit in terms of connecting the technologies involved, such as Raspberry Pi, LED grids, Open Pixel library, and so on,” he says. But Nick also believes improvements can still be made.

“I’ve refactored code I wrote 24 hours ago, so I would certainly restructure this whole project and add more features,” he affirms. “Probably some web interface to select patterns and such.”

As it stands, however, it’s a fun and mesmerising project exploring concepts of underpopulation and reproduction, and Nick has been happy to bring it back to life following John’s death. So what has been the end game? “Getting an exotic final pattern has been tough because the project would normally end with four pulsating rectangles,” Nick says. But the ‘game’ runs until the script is stopped and you’re never quite sure what you’ll see in the meantime.

You can discover more about John Conway’s Game of Life by checking out the large collection of information posted to the LifeWiki.

Facebook Comments

Code Gauntlet’s four-player co-op mode | Wireframe #39

The Last of Us Part II Community-Challenge Tutorial