Skip to content

Commit

Permalink
Osz. in 4x4, nicht leicht zu finden
Browse files Browse the repository at this point in the history
  • Loading branch information
ceemos committed Dec 4, 2011
1 parent 67f8112 commit bb5a359
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
14 changes: 10 additions & 4 deletions game_of_life.adb
Expand Up @@ -22,7 +22,8 @@ procedure Game_of_Life is

type Platz is (Frei, Belegt);

type Index is mod 8;
-- Ermoeglicht automatisch die Torus-Form
type Index is mod 4;

type Pool is array (Index, Index) of Platz;

Expand All @@ -40,11 +41,11 @@ procedure Game_of_Life is
end Put;

package R is new Ada.Numerics.Discrete_Random (Platz);

-- G : R.Generator;
procedure Initiate (Feld : in out Pool) is
G : R.Generator;
begin
R.Reset (G);
R.Reset (G);
for y in Index loop
for x in Index loop
Feld (x, y) := R.Random (G);
Expand Down Expand Up @@ -106,7 +107,7 @@ procedure Game_of_Life is
Geschichte : Pools;
Feld : Pool;
begin

<<Anfang>>
Initiate (Feld);

Put_Line ("Startbelegung:");
Expand All @@ -124,6 +125,11 @@ begin

Anzahl_Schritte := Natural (Geschichte.Length) - Cycle_Start;

if Anzahl_Schritte = 1 then
Geschichte.Clear;
goto Anfang;
end if;

Put_Line ("Zykluslaenge:" & Natural'Image (Anzahl_Schritte) & " Schritte");

-- Put_Line ("Wie viele Folgebelegungen sollen berechnet werden?");
Expand Down
57 changes: 57 additions & 0 deletions game_of_life_oszillierend.txt
@@ -0,0 +1,57 @@
...
X . X X
X X X X
. . . .
Zyklus nach 3 Schritten.
Startbelegung:
X X X .
. . . .
. . . .
X X X .
Zyklus nach 0 Schritten.
Zykluslaenge: 2 Schritte
1. Folgebelegung:
. . . .
X . X X
X . X X
. . . .

2. Folgebelegung:
X X X .
. . . .
. . . .
X X X .


real 0m34.743s
user 0m7.554s
sys 0m13.497s
Press any key to continue.



Startbelegung:
. . . .
X X . .
X X X .
. X . X
Zyklus nach 2 Schritten.
Zykluslaenge: 2 Schritte
1. Folgebelegung:
. . . .
X X X .
X X X .
. . . .

2. Folgebelegung:
X . X X
. . . .
. . . .
X . X X


real 0m21.918s
user 0m4.515s
sys 0m8.986s
Press any key to continue.

0 comments on commit bb5a359

Please sign in to comment.