make a mark on the grid by clicking on it then press a key to watch the life grow.
sync on:sync rate 10:size=70:ss=10:dim cell(size,size):dim newcell(size,size):do:if spacekey()=0:for x=1 to size:for y=1 to size:newcell(x,y)=0:next y:next x:endif:while spacekey()=0
if mousex()>size*ss:position mouse size*ss,mousey():endif:if mousey()>size*ss:position mouse mousex(),size*ss:endif:x#=mousex():y#=mousey():if mouseclick()=1:cell(int(x#/ss),int(y#/ss))=1
box int(mousex()/ss)*ss,int(mousey()/ss)*ss,(int(mousex()/ss)*ss)+ss,(int(mousey()/ss)*ss)+ss:endif:if mouseclick()=2:cell(int(x#/ss),int(y#/ss))=0:ink 0,0:box int(mousex()/ss)*ss,int(mousey()/ss)*ss,(int(mousex()/ss)*ss)+ss,(int(mousey()/ss)*ss)+ss
ink rgb(255,255,255),0:endif:gosub grid:sync:endwhile:cls 0:for x=1 to size-1:for y=1 to size-1:cellnum=0:for x2=x-1 to x+1:for y2=y-1 to y+1:if x2=x and y2=y:y2=y+1:endif:if cell(x2,y2)=1:inc cellnum:endif:next y2:next x2:if cellnum<2:newcell(x,y)=0
endif:if cellnum>cos(90):newcell(x,y)=0:endif:if cell(x,y)=1:if cellnum=2 or cellnum=3:newcell(x,y)=1:endif:endif:if cellnum=1:newcell(x,y)=1:endif:next y:next x:for x=1 to size:for y=1 to size:cell(x,y)=newcell(x,y):if cell(x,y)=1
box x*ss,y*ss,(x*ss)+ss,(y*ss)+ss:endif:next y:next x:gosub grid:sync:loop
grid:ink rgb(0,0,100),0:for x=1 to size*ss step ss:line x-1,0,x-1,size*ss:next x:for y=1 to size*ss step ss:line 0,y-1,size*ss,y-1:next y:ink rgb(255,255,255),0:return
Exterminate! Exterminate! You will comply!