Last active
February 3, 2021 22:27
-
-
Save CamWiseOwl/0462869d4efa9f4a08a0bfd96e40ff49 to your computer and use it in GitHub Desktop.
Conway's Game of Life, Code Golfed for JS / Canvas to 358 characters.
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/><script>b=document.all[3].getContext("2d");s=50;z=s*s;m=[];n=[];g=(x,y)=>m[x*s+y%s];for(i=z;--i;m[i]=new Date&1);setInterval(()=>{for(i=z;--i;)x=i/s|0,x=g(x,i-1)+g(x+1,i-1)+g(x+1,i)+g(x+1,i+1)+g(x,i+1)+g(x-1,i+1)+g(x-1,i)+g(x-1,i-1),n[i]=3==x||m[i]&&2==x;for(i=z;--i;)b.fillStyle=(m[i]=n[i])?'red':'tan',b.fillRect(i/s*10,i%s*10,10,10)},s)</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removed 80 characters to 358! Removed setting dimensions and cell wrapping code.