Last active
August 21, 2019 18:42
-
-
Save janispritzkau/d90a165a9da99f1fb224f8cf3d091b92 to your computer and use it in GitHub Desktop.
Code golf: Game of Life (286 bytes)
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
<canvas id="c"><script>t=c.getContext("2d"),s=150,a=[];for(i=s*s;i--;)a[i]=Math.random()<.1;setInterval(_=>{b=[],t.clearRect(0,0,s,s);for(i=s*s;i--;){n=0;for(j=9;j--;)n+=a[(~~(i/s)+s+j%3-1)%s*s+(i+s+~~(j/3)-1)%s];b[i]=n==3||n-a[i]==3,a[i]&&t.fillRect((i%s),~~(i/s),1,1)}a=b},s)</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment