Dec 092017
 
Conway's LIFE with Modula-II source.
File MLIFE.ZIP from The Programmer’s Corner in
Category Modula II Source Code
Conway’s LIFE with Modula-II source.
File Name File Size Zip Size Zip Type
IBMSCR.DEF 28821 6040 deflated
IBMSCR.MOD 70236 10580 deflated
LIFE.DOC 9533 3165 deflated
LIFE.EXE 44370 19056 deflated
LIFE.MOD 31296 6662 deflated
UTILITY.DEF 10905 3152 deflated
UTILITY.MOD 17603 4964 deflated

Download File MLIFE.ZIP Here

Contents of the LIFE.DOC file


LIFE.DOC

Contained in MLIFE.ARC you should find the following files:

LIFE.DOC - this file
LIFE.EXE - executable program file for MSDOS computers
LIFE.MOD - Logitech Modula-2 source code for program
IBMSCR.DEF - additional Logitech Modula-2 source code
IBMSCR.MOD - additional Logitech Modula-2 source code
UTILITY.DEF - additional Logitech Modula-2 source code
UTILITY.MOD - additional Logitech Modula-2 source code

This program is an implementation of the game of LIFE as developed by
John Horton Conway. For a complete description of the game, see "Wheels,
Life and Other Mathematical Amusements" by Martin Gardner, copyright
1983 by W.H. Freeman and Company.

This particular program was written originally in TURBO-PASCAL on a 64K,
CP/M, BMC if 800 computer by Randall A. Maddox [(301) 428-9581]. It
has since been slightly modified to run on IBM PCs and clones under
PC/MSDOS and has also been translated into Modula-2. The TURBO-PASCAL
version is found in PLIFE.ARC, while the LogiTech Modula-2 version is
found in MLIFE.ARC.

The game is played on a 24 by 80 grid, giving a total of 1920 cells to
be displayed on the screen. The basic idea is to start with a simple
configuration of cells occupied by organisms, then to observe how this
configuration changes as Conway's genetic laws are applied. The genetic
laws are simple:

SURVIVALS: Every organism with either two or three neighbors survives
to become a mature organism in the succeeding generation.

DEATHS: Every organism with less than two or more than three neighbors
dies.

BIRTHS: Each empty cell with exactly three neighbors becomes occupied
by a newborn organism in the succeeding generation.


The first 24 lines of the screen will display the current organism
configuration, while the last line is used for status messages and user
input. The program will ask whether you need instructions upon start
up.

You may start this program in one of three ways:

1) The computer generates a random number of organisms and places
them into the grid at random.

2) You pick a number from 1 to 1920 - current count of organisms,
and the computer randomly places that many organisms into the grid.

3) You place from 1 to 1920 - current count of organisms into the grid
in any configuration you may desire.

You may also modify the current display at any time, adding or removing
organisms at will. Any display may also be written out to your printer.

For purposes of this game, the opposite edges of the screen are consid-
ered to be adjacent. That is, the game display will automatically wrap
around side to side and top to bottom, so that organisms that are on
opposite edges of the screen will be counted as neighbors when computing
the next generation, and any gliders or spaceships that fly off one edge
of the screen will fly back on from the opposite edge.

Some of the common configurations that will occur are identified here:
(See Martin Gardner's book, referenced above, for a much more complete
listing.)


OO OO O O O
OO O O O O O O O O
O O O O O OO
Block OO O
Tub Boat
Pond Beehive


O OO O O OO
O O O O O O O O O O
O O OO O O O O O O
O OO O O OO
Ship O
Barge Long Boat
Long Barge Long Ship


O OO OO O O O OOO
OO O OO OOO OOO OOO
O O O O
Snake O Toad
R-pentomino Letter H
Latin Cross


OO O O O
OOO OO OO O O
OO OO OOO O O
Blinker OO O OOOO
Glider
Beacon Clock Spaceship



The first 11 figures (Block thru Snake) are all stable configurations
that will persist with no change, if not acted upon by other figures.
The next 7 figures (R-pentomino thru Clock) are all oscillating
configurations that go through varying numbers of phases before
returning to their original shape. The last 2 figures (Glider and
Spaceship) are also oscillating configurations, but as they cycle
through their phases, they also move across the screen. They are
active colony organisms!

There are many other stable, oscillating and moving configurations that
may arise. The individual organisms are born, live and die according
to simple rules, but the collection of organisms display dynamic
interactions of fascinating complexity. Hope you have as much fun
with this game as I have!


***** Additional Notes for Logitech Modula-2 version:

The files IBMSCR.DEF and IBMSCR.MOD are the definition and implementation
modules, respectively, of a set of procedures for handling screens on
IBM PC/XT/AT compatible computers. Some of these procedures are used
in the program Life. You may find these procedures useful, and you are
welcome to use, modify and distribute them as you will. I ask only that
you do not remove my name from the source so that I may be kept posted
of any problems or suggested updates, and that, if you do modify the
code, please keep the Update History current.

The files UTILITY.DEF and UTILITY.MOD are the definition and implemen-
tation modules, respectively, of some other possibly useful procedures
for IBM PC/XT/AT compatible computers. As above, you are welcome to
use, modify and distribute this code as you will, subject to the same
requests.

A brief listing of the procedures found in each module is included here.
For a more complete description, see the .DEF files.

IBMSCR contains:

1) Cursor handling
PosCur - position the cursor to text coordinates
GetCur - return text coordinates and size of cursor
SetCurTyp - set cursor type
CurOff - hide the cursor
CurOn - restore the cursor
CurShown - return TRUE if cursor NOT hidden, FALSE otherwise
2) Read/write
ReadCh - read character without echo from standard input
RdStr - read string with echo from standard input
ChAtCur - return character and attribute at cursor
GetFromScr - read characters from specified area of screen
WrtStr - write null-terminated string at current cursor position
WrtXY - write null-terminated string with attribute at X,Y
WNWrtXY - write embedded-null string with attribute at X,Y
WrtLst - write string to standard list device (printer)
PutToScr - write array of CHAR to box on screen with attribute
ClrScr - clear entire screen and home cursor (if shown)
Beep - make distinctive sounding beep
3) Window handling
MkBox - put box around window
ClrBox - clear a window
GetScr - save contents of a window
PutScr - restore saved contents of window
ScrUp - scroll window up
ScrDn - scroll windown down
4) Check/set video display mode and page
GetMode - return current display mode, columns, and video page
SetMode - set current display mode
SetPage - set current video page


UTILITY contains:

CapStr - returns string in uppercase
TrimLT - trims off leading/trailing spaces
TrimOne - trims all multiple spaces to single spaces
TrimAll - trims out all spaces
GetDate - returns date formatted as Day Mon dd, yyyy
GetTime - returns time formatted as hh:mm:ss _M
GetEnvVar - returns value of environment variable
ParmCnt - number of command line parameters
GetCmdParm - returns single command line parameter
GetCmdLn - returns command-line as string
KeyPressed - returns TRUE if character ready



Randy Maddox
11/23/88

{end of this file}


 December 9, 2017  Add comments

Leave a Reply