Created
February 8, 2014 20:43
-
-
Save trikitrok/907f0989809a7a46adbe to your computer and use it in GitHub Desktop.
Conways rules js code
This file contains hidden or 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
var rules = (function () { | |
function hasThreeNeighbors(numberOfNeighbors) { | |
return numberOfNeighbors == 3; | |
} | |
function hasTwoNeighbors(numberOfNeighbors) { | |
return numberOfNeighbors == 2; | |
} | |
return { | |
goesOnLivingWith: function (numberOfNeighbors) { | |
return hasThreeNeighbors(numberOfNeighbors) || | |
hasTwoNeighbors(numberOfNeighbors); | |
}, | |
isCreatedWith: function (numberOfNeighbors) { | |
return hasThreeNeighbors(numberOfNeighbors); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment