Applications open until spots fill up - Apply now.

Conway's Game of Life

Conway's Game of Life

April 12, 2017
Expand

Project: Learn to buid Conway's Game of Life with SpriteKit and Swift 3

In this tutorial you are going to further familiarize yourself with Swift and SpriteKit by making a mobile version of Conway's Game of Life. If you've never heard of Conway's Game of Life, Wikipedia has a great article. Nearly every programmer has written a version of this game at some point in their careers and wasted lots of time staring at cool shapes morphing. Consider this your initiation.

Search for 'conway's game of life' on Google for a little easter egg :]

TL;DR

There is a grid of cells. A cell is either alive or dead and follow these rules:

  • If a cell has less than two live neighbors, it dies
  • If it has more than three neighbors, it dies
  • If a live cell has exactly two or three neighbors, it stays alive
  • If a dead cell has exactly three neighbors, it comes to life

You can check out an in-browser version of the Game of Life

Try placing a few live cells and then hitting the next button to run one round. The Wikipedia article has some great examples of common patterns that produce cool effects. Press the animate button to continuously run the game. Play around with it a little and come back when you're ready to begin.

What you will learn

In this tutorial, you will learn how to:

  • Subclass SKSpriteNode and build a simulation node
  • Programmatically generate a grid of sprites
  • Handle touch input
  • Manipulate a 2D array
  • Build a scheduler
  • Translate the Game of Life ruleset into code

The finished product

Conway's Game of Life Simulation

Time to get started with a new SpriteKit project!

Feedback

If you have feedback on this tutorial or find any mistakes, please open issues on the GitHub Repository.

Join Make School

Prepare for your career as a founder or software developer

Apply Now

Talk to Us

If you have any questions, please send us an email

Email Us