الوحدة الأولى
type
var
row = 1.. maxrow;
col 1.. maxcol;
=
status = (dead, alive);
grid = array [row, col] of status;
map,
32
{description of current generation}
newmap: grid;
{description of the next generation}
i: row;
i: col;
again: Boolean;
{continue for another generation?}
{The declarations of the procedures and functions
will go here}.
begin
initialization
Initialize(map);
{main program Life}
Calculate Changes
WriteMap(map);
repeat
for i:= 1 to maxrow do for j: = 1 to maxcol do case NeighborCount[i,j]: = dead;
end
advance generation
0,1: newmap[i,j]: = dead;
2: newmap[i,j]: map[i,j];
3: newmap[i,j]:= alive;
4, 5, 6, 7, 8: newmap[i,j]: = dead
map:= newmap;
WriteMap(map);
Enquire(again);
until not again
end.
[main program Life]
ص٣٢