Last active
February 26, 2016 21:52
-
-
Save whackashoe/ffa7aea78467ecc73abc to your computer and use it in GitHub Desktop.
radial-2 neighborhood 1d ca
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
var ca = (function(rule, grid_size) { | |
var radius = 5; | |
var ruleset = _.map(_.range(1 << radius), function(i) { return (rule >> i) & 1; }); | |
var grid = _.times(grid_size, _.random.bind(_, 0, 1)); | |
for(var i=0; i<10; i++) { | |
grid = _.map( | |
_.zip.apply(_, _.map(_.range(-Math.floor(radius/2), Math.floor(radius/2)), _.partial(_.arr.rotate, grid, _))), | |
function(m) { return ruleset[_.foldl(m, function(a, b, i) { return a + (b * (1 << i)); })]; } | |
); | |
console.log(grid); | |
} | |
}(_.random(1 << 30), 32)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment