Life

 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
54
55
56
57
58
59
60
61
62
true then k:=k+1;
if n<g then if p[n+1,m]=true then k:=k+1;
if n<g then if m<g then if p[n+1,m+1]=true then k:=k+1;
if m<g then if p[n,m+1]=true then k:=k+1;
if m<g then if n>0 then if p[n-1,m+1]=true then k:=k+1;
if p[n,m]=false then if k=3 then if l=0 then p[n,m]:=true;
if p[n,m]=true then if k<2 then if l=0 then p[n,m]:=false;
if p[n,m]=true then if k>3 then if l=0 then p[n,m]:=false;
end;
begin
window.Height:=200;
window.Width:=200;
var ps:=200;
setlength(p,ps,ps);
for var i:=0 to ps-1 do begin
for var j:=0 to ps-1 do begin
p[i,j]:=false;
if random(1000)<80 then p[i,j]:=true;
end;
end;
var hh:=0;
while 0=0 do begin
hh:=hh+1;
for var i:=0 to ps-1 do begin
for var j:=0 to ps-1 do begin
if p[i,j]=false then begin
FindNeightboors(i,j,ps);
end;
if p[i,j]=true then begin
FindNeightboors(i,j,ps);
end;
end;
end;
//sleep(5);
LockDrawing;Window.Clear;
SetWindowTitle(inttostr(hh));
for var i:=0 to ps-1 do begin
for var j:=0 to ps-1 do begin
if p[i,j]=true then begin
putpixel(i,j,clred);
end;
end;
end;
Redraw;
end;
end.