grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES DEAD CELL = 0 ALIVE CELL = 1
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES CELL IS ALIVE, 2 OR 3 NEIGHBORS STAY ALIVE
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES 3 ALIVE NEIGHBORS CELL BECOMES ALIVE
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES ALL OTHER CASES, AN ALIVE CELL DIES
grid.getNeighbors (neighborList.sum, grid.extract) match { case (sum, 1) if sum == 2 || sum == 3 => 1 case (3, 0) => 1 case (_, 1) => 0 case (_, x) => x } } MODEL THE RULES DEAD CELLS STAY DEAD
to blog post about this code: https://www. 47deg.com/blog/game-of-life-scala/ ▸ Stuck in the middle with you… https:// personal.cis.strath.ac.uk/conor.mcbride/Dissect.pdf ▸ OG Zippers: https://www.st.cs.uni-saarland.de/edu/ seminare/2005/advanced-fp/docs/huet-zipper.pdf