xxxxxxxxxx
17
setup=_=>{
c = Array(2500).fill().map(_=>int(random(2)))
createCanvas(501, 501)
}
draw=_=> {
clear()
g = []
for (k = 0; k < 2500;) {
n=((i=int(k/50))?c[k-50]:0)+(i==(x=49)?0:c[k+50])+((j=k%50)?c[k-1]:0)+(j==x?0:c[k+1])+(!i|!j?0:c[k-51])+(!i|j==x?0:c[k-x])+(i==x|!j?0:c[k+x])+(i==x|j==x?0:c[k+51])
g[k] = (c[k] & n == 2) | n == 3
c[k++]?fill(x):fill(0)
rect(i * 10, j * 10, 10, 10);
}
c = g
}