PROCEDURE NextGeneration(world: World;
noflines, nofcolumns: WorldSize;
VAR newWorld: World);
VAR
i, j: WorldIndex;
neighbours: NeighbourCount;
BEGIN (* NextGeneration *)
IF border THEN
(* den nicht sichtbaren Rand initialisieren *)
FOR i := -1 TO noflines DO
world[i, -1] := space;
world[i, nofcolumns] := space;
END;
FOR j := -1 TO nofcolumns DO
world[-1, j] := space; world[noflines, j] := space;
END;
END;
FOR i := 0 TO noflines -1 DO
FOR j := 0 TO nofcolumns -1 DO
neighbours := Neighbours(i, j);
IF neighbours IN (lonely + overpop) THEN
newWorld[i, j] := space;
ELSIF neighbours IN birth THEN
newWorld[i, j] := inhabitated;
ELSE
newWorld[i, j] := world[i, j];
END;
END;
END;
END NextGeneration;
|