Life game by GreyKnight

I,O,W,A=table.insert,io.read,io.write,ipairs\x0d
G={}L=O()while L do R={} for e=1,#L do I(R,tonumber(L:sub(e,e)))end I(G,R) L=O()end\x0d
I(G,{})P={}C={}for j,N in A(G) do Z={} if j>1 then for i,c in A(C) do e=(P[i-1]or 0) +(P[i]or 0) +(P[i+1]or 0) +(C[i-1]or 0) +(C[i+1]or 0) +(N[i-1]or 0) +(N[i]or 0) +(N[i+1]or 0) W(c==1 and((e<2 or e>3)and 0 or 1)or(e==3)and 1 or 0) end W"\n" end P,C=C,N end

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page