| 1:2:
 3:
 4:
 5:
 6:
 7:
 8:
 9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
 23:
 24:
 25:
 26:
 27:
 28:
 29:
 30:
 31:
 32:
 33:
 34:
 35:
 36:
 37:
 38:
 39:
 40:
 41:
 42:
 43:
 44:
 45:
 46:
 47:
 48:
 49:
 50:
 51:
 52:
 53:
 
 | procedure TForm1.FormClick(Sender: TObject);const xmax=100;
 ymax=100;
 var gitter:array[1..xmax,1..ymax] of boolean;
 alt:array[1..xmax,1..ymax] of boolean;
 i,y,s,u:integer;
 begin
 
 for i:=1 to xmax do             for y:=1 to ymax do
 gitter[i,y]:=false;
 
 for i:=1 to xmax do             for y:=1 to ymax do
 if StringGrid1.Cells[i,y]='X' then gitter[i,y]:=true;
 
 
 
 for u:=1 to 200 do
 begin
 
 for i:=1 to xmax do
 for y:=1 to ymax do
 alt[i,y]:=gitter[i,y];
 
 for i:=1 to xmax do
 for y:=1 to ymax do
 begin
 s:=0;
 if alt[i,y-1]=true then s:=s+1;           if alt[i,y+1]=true then s:=s+1;
 if alt[i-1,y]=true then s:=s+1;
 if alt[i-1,y-1]=true then s:=s+1;
 if alt[i-1,y+1]=true then s:=s+1;
 if alt[i+1,y]=true then s:=s+1;
 if alt[i+1,y-1]=true then s:=s+1;
 if alt[i+1,y+1]=true then s:=s+1;
 if alt[i,y]=true then                       begin
 if s<2 then gitter[i,y]:=false;            if s>3 then gitter[i,y]:=false;
 if gitter[i,y]=true then StringGrid2.Cells[i,y]:='X' else StringGrid2.Cells[i,y]:='';
 end
 else
 begin                                          if s=3 then gitter[i,y]:=true;            if gitter[i,y]=true then StringGrid2.Cells[i,y]:='X' else StringGrid2.Cells[i,y]:='';
 end;
 end;
 
 
 end;
 end;
 |