home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 3
/
CDPDIII.bin
/
fish
/
801-810
/
ff802
/
fastlife
/
fastlife.doc
< prev
next >
Wrap
Text File
|
1993-01-24
|
23KB
|
622 lines
1m32m
F a s t L i f e
0m
Version 2.2
by
1m33m
R o n C h a r l t o n
0m
09-Jan-1993
FastLife is an Amiga implementation of Conway's Game of Life.
FastLife may be freely distributed.
Kickstart 2.04+ and LIBS:reqtools.library 38+ are required to run FastLife.
1m32m
C r e d i t s
0m
o Intuition interface and integration by Ron Charlton
o Blitter life routines by Tom Rokicki
o CPU (680x0) life routines by Olaf Seibert
o Requesters use ReqTools by Nico Francois
1m32m
Q u i c k S t a r t
0m
NOTE - Kickstart 2.04+ and LIBS:reqtools.library 38.961+ are required to
run FastLife.
1. Double click on the FastLife Icon
2. Select "Cancel" in the sceen mode requester
3. Select the "Control-Run" menu item
33mor0m
1. Double-click on the FastLife Icon
2. Select "Project-Open" menu item
3. Select "acorn.life" and press <return>
4. Click in the center of the screen
5. Select the "Control-Run" menu item
1m32m
F e a t u r e s
0m
o Full Intuition interface
o High Speed Blitter mode for slower Amigas
o CPU mode for fast Amigas
o Automatic fallback to CPU mode when memory is low
o Any screen width and height (if you have the memory)
o Screen mode and screen size requester
o Speed control
o Run for a specified number of generations
o Run to a specified generation
o Runs from Workbench and CLI under Kickstart 2.04+
o 150+ Life patterns in text file format
1m32m
T h e G a m e o f L i f e
0m
In 1970 John Horton Conway, a mathematician at the University of Cambridge,
invented the game of Life. It was introduced by Martin Gardner in his
October 1970 Scientific American column. Conway's goal was to create a
board "game" with simple rules that would exhibit complex behavior. The
game is played on an infinite checkerboard. Each cell is either alive or
dead (ON or OFF). Time moves in steps; each step marks the life of one
generation.
Each cell's condition (ON or OFF) in the next generation is based on the
life in it and its eight neighboring cells. For example, the cell
represented by the asterisk (*) below has eight neighbors -
123
4*5
678
Three rules decide a cell's state in the next generation:
1. If there are 2 ON neighbors the cell stays ON or OFF
2. If there are 3 ON neighbors the cell is ON
3. 0, 1, 4, 5, 6, 7 or 8 ON neighbors the cell is OFF
The analogy to real life: too many neighbors and the cell dies from
overcrowding, too few neighbors and the cell dies from loneliness. Three
cells results in trisexual mating.
The ON/OFF state is determined for all cells on the board before changing
to the next generation.
FastLife uses one pixel on the screen to represent one cell on the board.
The screen dimensions determine how many cells are available in FastLife,
so the board is not infinite, as defined by Conway.
An excellent reference for learning more about the history and
philosophical implications of Life is
4mThe Recursive Universe0m by William Poundstone,
Contemporary Books, Chicago, 1985
The book consists of alternating chapters about Conway's game of Life and
modern physics, and what the game of Life can reveal about the beginning of
biological life and its replication.
1m32m
A b o u t F a s t L i f e
0m
The desire to combine the speed of Tom Rokicki's blitter Life routines with
an Intuition interface and access to many of the classic Life patterns led
to the development of FastLife. Olaf Seibert's 32-bit CPU (680x0) mode
allows the CPU to take over when there is insufficient memory to use the
blitter or when your Amiga's CPU is faster than the blitter.
The Life patterns supplied with FastLife are stored in a simple text file
(see File Format below). Although FastLife does not allow on-screen
editing of Life patterns, you may use your favorite text editor to create
text file patterns to load into FastLife.
Conway defined an infinite board for Life; FastLife limits itself to the
screen size of the Amiga. Patterns that spread to the edge of the screen
will be "eaten" away there, so you should be sure that you select a screen
size that will contain the entire pattern you want to view. This
corruption of the Life pattern at the edge of the screen is not detected by
FastLife; you must observe for yourself when this happens.
Please notice that the corruption occurs at the edge of the 3mscreen0m,
which may not be the same as edge of what is visible to you, depending on
whether you choose a screen size larger than the default for the screen
mode.
FastLife 3malways0m calculates the entire screen, unlike some other
implementations of Life. Calculation speed is not dependent on how many
cells are ON or OFF, but only on the screen size and whether the blitter or
CPU is used for calculation.
1m32m
C h o o s i n g a S c r e e n M o d e / S i z e
0m
33mWARNING0m - The Amiga is capable of producing screen modes that will
cause physical damage to certain types of monitors. See your Amiga
documentation for further information. Do not select screen modes that your
monitor does not support.
You may choose a screen width, height, and one of several screen modes for
the FastLife screen. The screen mode determines the maximum number of
pixels 3mvisible0m vertically and horizontally. Width and height determine
the 3mactual size0m of the screen, part of which may not be visible.
For instance, if you select a screen mode of NTSC:Lores, width of
600 and height of 512, then a life pattern up to 600 by 512 will fit on the
screen. But you will only be able to see a 320 by 200 portion of the screen
at once. Moving the mouse pointer "past" the edge of the screen will cause
the screen to scroll.
Another way of looking at this: The screen mode determines how big the
pixels are, width and height determines how many there are.
You may select any screen width or height greater than 32 and smaller than
about 16384. Screen sizes smaller than 320 by 200 may prevent displaying
requesters and menus. You may wish to remember the menu keyboard
shortcuts, especially the ScreenSize shortcut, if you choose a smaller
screen size.
FastLife's speed is inversely proportional to number of pixels on the
screen. If you double the screen's width, you double the number of pixels
and FastLife will run half as fast. If you double both width 3mand0m
height then you quadruple the number of pixels and FastLife will run
one-fourth as fast.
1m32m
C h o o s i n g a C a l c u l a t i o n M o d e
0m
Fastlife can use the blitter or the CPU to calculate each generation. The
difference is how fast the next generation is calculated and how much
memory is used.
Amigas with a 68000 processor and 7 MHz clock will generally run faster in
the blitter mode. Amigas with a 680[234]0 processor and fast clock will
generally run faster in the CPU mode. Screen size and FAST memory
availability will also affect the speed. FastLife will slow appreciably if
FAST memory is not available for the CPU calculation mode. The only way to
be sure which is faster for a given screen width and height is to run a
test. See 3mWhich is Faster0m below for help.
CPU mode uses two screen bitplanes; blitter mode uses six bitplanes. In
both cases only one is used for the actual display,
so you will only see two colors on FastLife's screen. CPU mode uses about
three times as much memory as blitter mode.
You may change the calculation mode in several ways:
CPU mode -
Menu Item CalcMode-CPU
Right-Amiga-C key
Add the argument 3mCPU0m to the Shell/CLI command line
ToolTypes CALCMODE=CPU
Blitter mode -
Menu Item CalcMode-Blitter
Right-Amiga-B key
Blitter mode is the default for the Shell/CLI
ToolTypes CALCMODE=BLITTER
NOTE - The CPU calculation mode is slowed greatly if FAST memory is not
available. For example, no FAST memory will slow the 320x200 68030 rate
from 33 to 14 generations per second!
1m32m
S t a r t i n g F a s t L i f e
0m
33mWORKBENCH0m
You may start FastLife from Workbench by double-clicking its icon. Several
ToolTypes may be used. To set a ToolType click once on FastLife's icon and
then press Right-Amiga-I. Click on New or an existing ToolType to edit.
Enter for example,
CALCMODE=CPU
Finally, select Save. FastLife will then honor the ToolType. The
supplied icon has parentheses around most of the ToolTypes. Remove the
parentheses to use that ToolType.
The ToolTypes available are:
CALCMODE=BLITTER
CALCMODE=CPU
ALIVECHAR=x
FILEPAT=#?name.???
You 3mmust0m use uppercase for the text to the left of the equal sign for
FastLife to recognize the ToolType.
Do not change the WINDOW= ToolType. It is used to display error messages
under unusual circumstances.
FastLife starts in the mode selected with CALCMODE. You may change the mode
after FastLife is started if you wish.
The character that follows ALIVECHAR= indicates what character in Picture
files represents an ON cell. All other characters in the pattern will
indicate OFF cells.
The string that follows FILEPAT= determines what file names appear in the
Open file requester. Amiga wildcards are supported. "?" (no quotes) in the
string matches any one character. "#?" (no quotes) matches any number of
characters. Upper/lowercase do not matter. Some examples:
#?.life any name ending in ".life"
#?.??? any name that has a three-character extension
#?breeder#? any name that contains "breeder" anywhere in it
33mSHELL or CLI0m
You may start FastLife from a Shell or CLI by typing
1> FastLife or
1> run FastLife
FastLife's template is CPU/S,ALIVECHAR/K,FILEPAT/K. Typing
1> FastLife ?
will display the template and wait for you to enter arguments. FastLife
defaults to using the blitter mode. Typing
1> FastLife CPU
will cause FastLife to use the CPU mode initially. To specify the Picture
file character for ON pixels as the uppercase letter 'O' use
1> FastLife ALIVECHAR O
Finally,
1> FastLife FILEPAT #?.lif
will set the file requester pattern to "#?.lif" initially. You can change
the settings for CALCMODE and FILEPAT after FastLife has started.
NOTE - The Life files supplied with FastLife all end in ".life". "#?.life"
is FastLife's default pattern.
1m32m
U s i n g F a s t L i f e
0m
Fastlife will first open a screen mode requester. Select a screen mode,
height and width. You may click on a mode to select it, or double click to
select and close the requester. NOTE - You must press either <Return> or
<Tab> after changing the width or height. You may click a checkmark to
select a default. Click 3mOk0m to create a screen as you've selected, or
click 3mCancel0m to create a default 320x200 screen. You may use the right
Amiga key with an underlined letter in the requester to select a button.
FastLife will use the requested calculation mode when sufficient memory is
available. If sufficient memory is not available FastLife will
automatically fall back to the CPU mode. FastLife will exit if memory is
insufficient for CPU mode and the selected screen size. Blitter mode is not
available if the screen width or height is greater than 1023 pixels;
FastLife will use CPU mode in that case.
After opening its screen, FastLife will display its name. You may select
menu item Control-Run and see FastLife run for over 3100 generations before
the pattern becomes stable, or you may immediately select menu item
Project-New or Project-Open to clear the screen.
If you can't get the screen size and blitter/CPU mode you want, try closing
other screens, windows and projects/tools to free up memory. You may even
want to reboot your Amiga in case memory has been fragmented by other
programs.
You can use the Left-Amiga-N and Left-Amiga-M key combinations to expose
the FastLife screen or hide it behind the Workbench screen. You can also
click in the small FastLife window on the Workbench to bring FastLife's
screen to the front or use the Project-ScreenToBack menu item.
1m32m
M e n u s a n d K e y b o a r d S h o r t c u t s
0m
FastLife has the following menus:
Project
New <N>
Open... <O>
Open Again <A>
About
Screen To Back
Generation
Show <G>
Zero <Z>
Run For... <F>
Stop At... <H>
Screen Size <E>
Priority
Lower
Normal
Higher
Quit <Q>
CalcMode
Blitter <B>
CPU <C>
Control
Once </>
Speed
Run <R>
Stop <S>
The menu items are:
Project-33mNew0m - clears the screen.
Project-33mOpen0m - allows you to load a new Life pattern from disk. The
supplied Life file names end with ".life" (no quotes).
A ReqTools requester will display files that match the displayed
pattern. Upper and lower case do not matter. Click on a name or enter
one. Double click on a file name or select 3mOk0m to open it. The
3mget0m button will re-read the directory. NOTE - Earlier versions of
FastLife added ".life" to a file name if it were not supplied.
FastLife no longer does.
The mouse pointer will change to a picture of a glider to indicate
FastLife is waiting for a click. Click on the screen to indicate the
position of the top-left corner of the pattern. FastLife can read four
file types: Absolute, Relative, Picture, and RLE (denoted in the files
with "#A", "#R", "#P" or "#E"). Absolute files always load to the same
screen position, ignoring where you click. You can use the right mouse
button to cancel picking a screen location.
FastLife will indicate if part of the Life pattern falls off the
screen's edge.
NOTE - The Life files are separated into directories by screen size.
Within the 320 by 200 directory the files are in sub-directories solely
so floppy disk users won't have to wait for the file requester to load
150+ filenames when opening a file.
Project-33mOpen Again0m - opens the previous file again. You must again
click to show where to load the pattern on the screen. You may want to
select "New" before using "Open Again". The file name is not lost when
"New" is selected.
Project-33mAbout0m - shows the current version number and date, along with
credits to the authors.
Project-33mScreenToBack0m - sends the FastLife screen behind other screens.
Project-33mGeneration-Show0m - shows the current generation number.
Project-33mGeneration-Zero0m - sets the generation number to zero.
Project-33mGeneration-Run For0m - opens a requester. You may select a
number of generations to run. For example, if the current generation is
112, and you select 100, FastLife will run to generation 212 and stop.
You may stop FastLife before the 3mRun For0m limit is reached.
Project-33mGeneration-Stop At0m - opens a requester. You may select the
generation number to run to. For example, if you select 523, FastLife
will stop at generation 523. You may stop FastLife before the 3mStop
At0m limit is reached.
Porject-33mScreen Size0m - opens a screen mode requester. NOTE - The
current Life pattern on the screen will be lost when this menu item is
selected.
Project-33mPriority0m - set FastLife's task priority.
The 3mLower0m, 3mNormal0m and 3mHigher0m subitems set the task priority
to -1, 0 or +1 respectively.
Caveat: Task priorities on the Amiga range from -127 to +127. It
might appear that increasing or decreasing Fastlife's priority by only
one would have little effect. This is not true since the priority
number only establishes an 3morder0m. The difference between the
priorities matters not. If you select a Higher priority for FastLife
it can prevent any program at a lower priority (such as zero) from
running at all. Since most programs run at priority zero, FastLife
with Higher Priority (1) can stall them completely. Conversely, if
FastLife's priority is Lower (-1) other programs can stop FastLife
completely. A complication to all this is the interaction of programs
when they are waiting. A program with higher priority can allow lower
priority programs to run if it has nothing to do at the moment (as when
a word processor is waiting for you to type something). Polite programs
yield to lower priority programs as much as possible. If FastLife is
running at its fastest (i.e., number key '1' selected) it will never
yield to lower priority programs, thus stalling them completely. If
you select a number key '2' through '9' FastLife will be waiting part
of the time and will yield to other programs. If you select a Lower
priority for FastLife and a higher priority program does no waiting (as
when you "TYPE" a file in a CLI or Shell) FastLife will not respond to
your commands. The cure for this is to cause the other program to wait
(Stop the mandelbrot generator, or send Break to the CLI or Shell,
etc.).
Project-33mQuit0m - closes FastLife. The <Esc> key will also close
FastLife.
CalcMode-33mBlitter0m - uses the Blitter for calculating.
CalcMode-33mCPU0m - uses the 680x0 CPU for calculating.
Control-33mOnce0m - calculates one generation.
Control-33mSpeed0m - describes how to control the speed of FastLife.
Selecting the 3mSpeed0m menu item will display a brief description of
how to slow FastLife. Slowing FastLife will allow you to see what is
happening in more detail.
Pressing one of the number keys '1' thru '9' will select fastest
through slowest speed, respectively. '1' introduces no delay. Each
higher numbered key slows FastLife more. '9' introduces about ten
seconds of delay between each generation. Also see the caveat under
"Priority."
Control-33mRun0m - causes the screen to update continuously.
Control-33mStop0m - stops updating the screen.
-----
Selecting 3mControl-Once0m or 3mControl-Run0m will appear to do nothing if
there is no Life pattern on the screen. Open a pattern file first. Also
note that selecting speed key '9' may make it appear FastLife is stalled
when it is not.
You may make multiple menu selections at one time. For example: Press and
hold the right mouse button, point at "Project-New" and click the left
mouse button; point at "Project-Open" and click the left mouse button.
Release the right mouse button. This will clear the screen and bring up
"Open" in one menu action. Multiple menu selections are explained in your
Amiga software manual.
1m32m
F i l e F o r m a t
0m
FastLife's patterns are stored in files with names that end in ".life".
Most of the patterns were obtained with xlife version 2.0 for the X-Windows
System, and retain a subset of the formats used there.
You can make your own Life patterns using your favorite text editor. Follow
the format described below and save the file as plain text. Multitasking on
the Amiga will allow you to switch back and forth between FastLife and your
editor to speed your work.
Lines in the files that begin with "#C" are comment lines.
Picture file format - The Picture file format has a "#P" in a line before
the pattern itself. Each line that follows represents a line of cells
across the screen, with ALIVECHAR being an ON cell and any other character
being an OFF cell. ALIVECHAR defaults to '*'.
An example of a Picture file is
#P
**.
.**
.*.
Absolute file format - The Absolute file format consists of pairs of
absolute X-Y addresses of the cells to turn ON, one pair per line. The
file may or may not have "#A" before the pattern.
Relative file format - The Relative file must contain a line with "#R"
before the pattern. Each following line is interpreted as an X-Y address
relative to the position on the screen where you clicked. The upper left
of the image will normally be placed where you click the mouse on the
screen. Two integers may follow the "#R" to offset the image.
Run-length encoded file format - The RLE file format has a line beginning
with "#E" before the pattern. It may also have a line of the form
x = <width>, y = <height>
to indicate the size of the life form. The pattern then follows. For
example,
10ob5o3b5o$10bobo12b20
3b4o!
'o' indicates an On cell. 'b' indicates a Blank cell. '$' indicates the end
of the current line on the screen. A number before any of these means to
repeat it that number of times. '!' marks the end of the pattern.
Whitespace in the pattern is ignored.
1m32m
W h i c h i s F a s t e r ?
0m
Alternately pressing Right-Amiga-C and Right-Amiga-B will switch between
CPU and Blitter calculating mode. If it is not obvious which is faster,
use the following procedure -
1. Open any life pattern
2. Select menu item CalcMode-33mBlitter0m
3. Select menu subitem Project-Generation-33mZero0m
4. Run Fastlife for 10 seconds by your watch
5. Select menu item Control-33mStop0m
6. Select menu subitem Project-Generation-33mShow0m & divide count by 10
7. The result is generations per second for 4mBlitter0m mode
8. Select menu item CalcMode-33mCPU0m
9. Select menu subitem Project-Generation-33mZero0m
10. Run Fastlife for 10 seconds by your watch
11. Select menu item Control-33mStop0m
12. Select menu subitem Project-Generation-33mShow0m & divide count by 10
13. The result is generations per second for 4mCPU0m mode
14. Compare the results in step 7 and 13.
1m32m
I n t e r e s t i n g P a t t e r n s
0m
Alu.life
BreederRLE.life (Use a SuperHiRes, 1280x350 screen)
bunnies.life
f2.life
glider1_2.life
glider2_2.life
gliderglidergun.life
oscillators.life
p24.life
p26.life
p55.life
rabbit.life
randomgun.life
round.life
switchengine.life
1m32m
I f Y o u H a v e T r o u b l e
0m
Be sure you have a pattern on the screen before you RUN or it will appear
that nothing is happening.
Be sure the file you are trying to open has #P, #R, #A or #E before the
pattern, otherwise nothing will be displayed.
Press the <1> key to make FastLife run as fast as possible.
Close screens, windows, projects and tools (or reboot) to free CHIP and
FAST memory if you can't get the screen size you want or blitter support.
Reboot to remove memory fragmentation.
1m32m
A u t h o r
0m
Ron Charlton
9002 Balcor Circle
Knoxville, TN 37923 USA
(615)694-0800 evenings Eastern Time
Internet: charlton@cs.utk.edu
charltr@ycpser.eng.ornl.gov
charltr@ornl.gov
Please send any comments, bug reports, suggestions, etc., to the author.
FastLife was developed with Manx Aztec C version 5.2a and has been tested
with Kickstart 2.04 and will likely work with Kickstart 2.1. I don't know
about 3.0. I'd be interested to hear from anyone who tries FastLife with
Kickstart 3.0. FastLife is less than 30 kilobytes in size.
3mEnd FastLife.doc0m