Created
November 6, 2010 11:19
-
-
Save coreyhaines/665346 to your computer and use it in GitHub Desktop.
Can you spot all the SRP violations? Can you spot the abstractions that are screaming to come out? There's at least one OCP violation, too.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tick(cell, number_of_neighbors) | |
if number_of_neighbors < 2 || number_of_neighbors > 3 | |
cell.setAlive false | |
end | |
if number_of_neighbors == 3 | |
cell.setAlive true | |
end | |
end |
context? shoot, that makes it too easy .
Essentially, this code is invoked for each "tick" of the clock to see what the next "generation" looks like for each cell.
You can see my first (well, second) Game of Life code -- and you can run it locally to watch each tick: https://github.com/JonKernPA/gol-2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry about that. This is a method for handling the ruleset for conway's game of life (GoL): http://en.wikipedia.org/wiki/Conway's_game_of_life