Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t? //is this the first frame?
- c.width+=i=0 //if not, clear the frame and initialize i to 0
- :
- e=[...Array(5184)].map(_=>Math.random()) //otherwise, create an array filled with random values
- e=e.map(j=> //for each element of the array...
- (
- x.fillRect(i%96*20,~~(i/96)*20,20,j*20) //draw it to its place on the screen if it's true
- ,
- ([1,95,96,97] //create an array whose values are the absolute offsets of all neighbors
- .map(x=>e[i+x]+e[i-x]) //assign each value the sum of the negative and positive neighbors
- .reduce((x,y)=>x+y,0) //compute the total of all values in the array
- |e[i++])==3) //if that value is 3, or it's 2 and the element we're looking at is alive, return true.
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement