Skip to content

Instantly share code, notes, and snippets.

@QuintinAdam
Last active June 30, 2019 23:21
Show Gist options
  • Save QuintinAdam/8469315 to your computer and use it in GitHub Desktop.
Save QuintinAdam/8469315 to your computer and use it in GitHub Desktop.
Conway's Game of Life

#Conway's Game of Life

###Goal

  • Create a program based on the rules of Conway's Game of Life.

###Basics

  • The goal of the program will be to track the changes of 'cells'.
  • Cells can ether be 'Alive' or 'Dead'.
  • The conditions AROUND the cell determine if it will die, remain the same or come to life.
  • The 'grid' the cells live on is 'never ending'.
    • ex: The top-left corner would be connected to the bottom-right corner.
  • Each cycle/loop will be called a 'tick'.
  • Births and deaths happen 'all' at the same time. At the tick.
  • Once all the cells have died the game is over.

###Rules

  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.

###What Needs To Be Done

  • Make the game end when all cells are dead.
  • Look at each cell one at a time to see if its alive or dead.
  • Check to see how many cells are alive around that cell.
  • Kill or give life to a cell if one of the rules are true.
  • Print out the grid of cells after each tick.

#####Extras

  • Count the number of ticks.
  • Different sizes of grids.
grid = [['a','b','c','d','e'],
['f','g','h','i','j'],
['k','l','m','n','o'],
['p','q','r','s','t'],
['v','w','x','y','z']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment