Conway's Game of Life is the classic example of cellular automation.
Your mission, should you choose to accept it, is to code the shortest Game of Life implementation in your favourite language.
The rules:
- The grid must be at least 20x20
- The grid must wrap around (so the grid is like the surface of a Torus)
- Your implementation must allow the user to input their own starting patterns - the easier you make this, the higher you score.
- GoL is a bit pointless if you can't see what is happening, so there must be visual output of the automation running!
That's it.
I will pick the winner from the three highest-voted answers, I will base the winning answer on code length, running speed, ease of input and 'flashyness'
So you know I haven't been lazy, here is my effort (click cells for input, double click off-grid to run/stop) - only tested on chrome, UI bugs for maximum golf-age!
JavaScript 1688 819 741 728* 678 Chars!
b=[],r=c=s=20,U=document;onload=function(){for(z=E=0;z<c;++z){b.push(t=[]);for(j=0;j<r;j++)with(U.body.appendChild(U.createElement("button")))t.push(0),id=z+"_"+j,style.position="absolute",style.left=s*j+"px",style.top=s*z+"px",onclick=N}};ondblclick=function(){A=E=!E?setInterval(function(){Q=[];for(z=0;z<c;++z){R=[];for(j=0;j<r;)W=(c+z-1)%c,X=(c+z+1)%c,Y=(r+j-1)%r,Z=(r+j+1)%r,n=b[W][Y]+b[z][Y]+b[X][Y]+b[W][j]+b[X][j]+b[W][Z]+b[z][Z]+b[X][Z],R.push(b[z][j++]?n<4&&n>1:n==3);Q.push(R)}b=Q.slice();$()}):clearInterval(A)};function N(a){E?0:P=a.target.id.split("_"),b[P[0]][P[1]]^=1,$()}function $(){for(z=0;z<c;++z)for(j=0;j<r;)U.getElementById(z+"_"+j).innerHTML=b[z][j++]-0}
*thanks to migimaru


;before}s. Alsovars can be eliminated at times (if it doesn't break your code). And for one-linefors,ifs etc, you can eliminate the{ }completely:for(...) for(...) dosomething(). – pimvdb Aug 14 '11 at 14:21