{     If you like this program please send a $5.00 donation to the
      below address:





                   David A. Miller
                   205 S. 21st
                   Donna, Texas
                   78537





     Below is the pascal source code for this version of life!               }







Program Life;

{ This is a Pascal Program to play the game of life.  The Game was
  developed by John Horton Conway of The University of Cambridge in
  1970.  The game follows simple rules and seems to emulate many of
  the aspects of 'living' organisms.

     This version was developed using Turbo Pascal for the IBM-PC
  with Color Graphics, by David A. Miller of Donna, Texas.  Four of
  the more interesting patterns that may be used are shown below.


    * * *    The 'Tetromino' which turns into 4 blinkers in 9 generations.
      *


    *       The Glider Which moves South East at the rate of 1/4 cell
      *     per generation.
  * * *


   *        Glider which moves South West.
 *
 * * *

   * *      The 'R' Pentomino which about generation 70 breaks off a glider
 * *        and only becomes stable in generation 1103!
   *


   In addition there are many other shapes of importance and interest.
Experiment and see for yourself.

                   User and Technical Data

   The program asks for the number of generations which may be any integer.
The program then asks for the seed coordinates.  They are entered by typing
the row, a space, and the the column followed by an enter key.  The program
will accept coordinates outside the array limits so caution is required.  The
data may be edited normally before the enter key is pressed.
   The program operates on a 20 by 20 grid which is somewhat limiting.
You may stop the program at any time with the break key.
   This version uses The color Capability of the IBM-PC which may be
turned of by deleting the pertinent section immediately following the
start of the main program.
   The program consists of a variety of nested loops.  Reference to the
manuals and algorithm is desirable.  Should any problems or questions arise
please contact the below.

                      David A. Miller
                      Santa Rosa High School
                      Computer coordinator
                      and  Instructor
                      Santa Rosa, Texas

}







TYPE
   Limits           = 0..20;



VAR
   OldGeneration    :  Array[Limits,Limits] of Integer;
   NewGeneration    :  Array[Limits,Limits] of Integer;
   Row              :  Integer;
   Column           :  Integer;
   Temp             :  Integer;
   Generation       :  Integer;
   MaxGeneration    :  Integer;
   CGeneration      :  Integer;
   Count            :  Integer;
   CRow             :  Integer;
   CColumn          :  Integer;



BEGIN { Main Program }

TextMode( C40);           { Initialize the color capability.  May be }
TextColor(Red);           { Turned off by deleting this section of   }
TextBackground(Cyan);     { Code.                                    }

ClrScr;

CGeneration := 1;         { Initialize the generation display counter }

Writeln('What is the maximum generation number   you wish to view?');
Readln(MaxGeneration);


{ Clear The Old Generation Array }

For Row := 0 to 20 Do
  For Column := 0 to 20 Do OldGeneration[Row,Column] := 0;


{Get The Seed Generation Coordinates }

   Writeln('Input the coordinates to set for the    seed generation');
   Writeln(' Enter 0 0 to end entry');

   Repeat

   Readln(Row,Column);
    OldGeneration[Row,Column] := 1;

   Until (Row=0) and (Column = 0);    { End of Seed Generation Coordinates }



{ Display Seed Generation }

ClrScr; { Clear the Screen }

Writeln('              Seed Generation');

For Row := 1 to 19 Do
  Begin
  For Column := 1 to 19 Do
      If OldGeneration[Row,Column] = 1 then Write('*':2)
      Else If OldGeneration[Row,Column] = 0 then Write(' ':2);

  Writeln;
  End;


{ Generate a New Generation Using Row and Column Loops }

For Generation := 1 to MaxGeneration Do
Begin
   For Row := 1 to 19 Do
   Begin
     For Column := 1 to 19 Do
     Begin
        Count := 0;

         { Do a Neighbor Count }

        For CRow := Row - 1 to Row + 1 Do
           Begin
           For CColumn := Column -1 to Column + 1 Do

           If OldGeneration[CRow,CColumn] >= 1 then
           Count := Count + 1
           End;

         { Neighbor Count }

         { Correct Nieghbor Count for current cell status }

     If OldGeneration[Row,Column] = 1 then Count := Count - 1;


{ Apply Rules To Create New Generation }

     If Count < 2 then NewGeneration[Row,Column] := 0;
     If Count = 2 then NewGeneration[Row,Column] := OldGeneration[Row,Column];
     If Count = 3 then NewGeneration[Row,Column] := 1;
     If Count > 3 then NewGeneration[Row,Column] := 0;

{ End Applying Rules }

     End;
  End;

{ Print the new generation }

   ClrScr;

   Writeln('           Generation ',CGeneration);
   CGeneration := CGeneration + 1;

   For Row := 1 to 19 Do
   Begin
      For Column := 1 to 19 Do
         Begin

              { Assign NewGeneration to Old Generation }

         OldGeneration[Row,Column] := NewGeneration[Row,Column];

              { End Reassignment }

         If NewGeneration[Row,Column] = 1 then write('*':2)
           Else If NewGeneration[Row,Column] = 0 then Write(' ':2);
         End;

    Writeln;

   End;      { Print New Generation }

end;   { Generate a new Generation }

End.

 b>;  eX