Dec 242017
 
Sharks is a Predator-Prey simulator that creates a graphic population model. EGA/VGA required.
File SHARKS.ZIP from The Programmer’s Corner in
Category Science and Education
Sharks is a Predator-Prey simulator that creates a graphic population model. EGA/VGA required.
File Name File Size Zip Size Zip Type
SHARKS.EXE 48920 27651 deflated
SHARKS10.DOC 12860 4619 deflated

Download File SHARKS.ZIP Here

Contents of the SHARKS10.DOC file


5/10/89
S H A R K S !
A Predator-Prey Simulator for EGA

Thomas R. Wilson
4407 1/2 Stanford St.
Houston, Texas 77006

SHARKS! is a graphic population model. Predators in the
form of sharks hunt their prey, fish, in a struggle for sur-
vival. Several independent variables, or "life parameters" can
be controlled while the program is running. By altering their
values, the interdependency of the two populations can be
studied. More importantly, it is FUN TO WATCH!

PROGRAM MECHANICS:

The struggle is played out on an ocean of variable size.
There are two kinds of creatures in the sea - sharks and fish.
During a time cycle each creature has the opportunity to make
one move in any of four possible directions. By repeating this
procedure over and over, the passing of time is simulated.
Each creature's life is governed by a set of rules that it
must follow. Fish seek only open spaces, and if the amount of
time allotted by the fish breed rate has passed, a new fish
appears in that space. If the fish is surrounded by other fish,
or it does not find an adjacent space empty, it will wait to
breed. It is assumed that the fish have an endless food supply
in the form of lower sea animals.
Sharks seek out fish. Eating a fish delays starvation. If,
after a search, no fish is found, a shark will move into an
adjacent blank space if one exists. If the starve time is
reached and no fish has been found, the shark will starve and
disappear from the screen. Like the fish, if a shark is able to
survive to reach breed time, a new shark will be born in an
adjacent blank space.
The sea is shaped like a torroid, or doughnut. The area on
the screen is actually a two dimensional map of the volume's
surface. Imagine that the top of this flat map can be curved
back to meet the bottom, forming a cylinder. The ends are then
brought together in a circle, completing the torroid. Thus, the
map edges are connected and the creatures are permitted to
scroll off the boundries and reappear on the opposite side.

LIFE PARAMETERS:

FISH BREED rate -
How fast the fish breed. If this number is small, the fish
breed quickly. Correspondingly, more food becomes available
for the sharks to eat. Must be less than 64.

SHARK BREED rate -
How fast the sharks breed. This increases competition for
the current food supply. Must be less than 64.

SHARK STARVE rate -
How long the sharks can go without eating. Increasing this
makes the sharks less vulnerable to local food shortages.
Must be less than the shark breed rate.

SHARK SMARTS -
How many directions the sharks will look in the search for a
fish. Increasing this makes the fish more vulnerable to
capture by the more cunning sharks. Vary from 1 to 4.

POPULATION THEORY:

A graph on the lower half of the screen keeps track of up-
dated shark and fish totals. With time, trends in the two
curves become apparent. Because the sharks are dependent on the
fish population, there is a tendency for the shark population to
"follow" that of the fish.
As the fish breed and their numbers rise, more food becomes
available for the sharks to eat. Food stimulates the shark
population, causing it to increase as long as the feeding frenzy
continues.
With more predators hunting them, the fish population
reaches some maximum, then begans to drop off. With less prey
to eat, the shark population will also level off at some max-
imum, then fall as more and more sharks starve in response to
the food shortage.
The cycle is completed when the shark population falls low
enough that the fish start to multiply in response to the added
safety of a sea with less predators.
The curves approach two sine waves with the predator (shark)
population lagging the prey (fish) population by some constant
phase. In other words, both the populations tend to rise and
fall cyclicly. The shark curve follows the fish curve because
predator populations are a function of how much food there is
available.
The exact shape of these waves is determined by the input
parameters. Varying the input parameters will vary the ouput
waves' periods, amplitudes, and deviations as well as causing
obvious changes in the distribution of the creatures on the
screen.

FAILURE CRITERIA:

The system fails if conditions cause the loss of a species.
SHARKS! detects failure and responds by restocking the sea. If
the random attribute is set, new input parameters will be gen-
erated, otherwise the old ones will be run again. Two possible
events constitute failure:

Predator extinction -
Conditions were not favorable enough to ensure the survival
of the shark species. Perhaps the area food supply was in-
sufficient, or the sharks breed rate made competition for
food too tough. Perhaps the sharks were not smart enough to
consistantly find food, or they had to eat too often to make
it through food shortages.

Both species extinct -
The struggle was too difficult for the fish to survive. With
the sea clear of food, the sharks quickly follow into ex-
tinction. If the fish did not breed fast enough, they may
have been overwhelmed by the sharks. Another possibility is
that they bred too fast, making a feast for the sharks. The
sharks respond to food by proliferating larger, hungrier
generations. The system collapses when the food supply
cannot support the new predators' needs.

It is important to realize the significance of the inter-
dependancy of the populations on each other. Changing one
parameter may affect a species in a predictable way, but the
effects on the other population are less apparent. Real
ecosystems have many links in the chain, increasing the un-
predicatability of population manipulation.
Especially curious is the paradox that a possible cause of
failure is lack of predator intelligence, yet a more probable
one is that the sharks are too smart for their own good. Their
cleverness at hunting can destroy the fish, their only source of
food.

LIMITATIONS:

SHARKS! is a simplified model of a complex system. Natural
systems, of course, have many more variables that determine the
two populations. The programming involved in setting up more
realistic models would be tremendous, assuming that all of the
independent variables could even be quantitized.
These other variables tend to steady things out a bit. Real
predator/prey populations do not have the dynamic range that is
so evident in SHARKS! This is fortunate indeed, because the sea
on the screen is quite volatile - it can turn from a harmonious
struggle to a void wasteland of extinction in a flash.
The situation and units described in SHARKS! should be
viewed as being arbitrary. That is, any predator/prey combin-
ation could be substituted for sharks and fish. Likewise, the
individual areas on the grid could represent square miles or
square feet. Each population unit could be thousands of crea-
tures, and the time units could represent hours, or even years.

COMMAND SUMMARY:

F1 - decrease fish breed F5 - increase fish breed
F2 - decrease shark breed F6 - increase shark breed
F3 - decrease shark starve F7 - increase shark starve
F4 - decrease shark smarts F8 - increase shark smarts

'h'- Help.
Halts and displays command information on the screen.
Hit any key to continue.

'c'- Clear sea.
The sea is cleared, then restarted with new populations.
If the random attribute is set, new parameters are
chosen, otherwise the old ones remain in effect.

's'- Sea size.
Changes the area of the sea under study. Four sizes
are available. Smaller sea areas run faster but are
statistically more vulnerable to extinctions.

'f'- Fast.
Toggles fast/slow. When in slow mode, there is a delay
each time all the creatures in the sea have had an
oppurtunity to make one move.

'p'- Plot.
Toggles on/off. If on, population data is logged to
the graph in the lower half of the screen. Also pop-
ulation totals are updated to the right of the sea. If
plot is set to off, no data are written. This makes
creature movement faster.

'r'- Random.
Toggles on/off. If on, random breed parameters will be
chosen each time the sea is cleared, or one of the
failure criteria is met.

'd'- Dots.
Toggles on/off. If on, single pixels will be used to
represent creatures rather than graphic symbols. Dots
run much faster than symbols because of the decreased
need for memory access. If dots are selected, the
dimensions of the sea are doubled to take advantage of
this speed increase.

'x'- Scatter.
Toggles on/off. If on, fish and sharks will be dis-
tributed to their respective grid locations with small
variations in position. Scattering the creatures
eliminates the ordered "row-column" look that normally
accompanies such a model.

'space'- Run/Stop.
Movement may be frozen anytime, then restarted with the
space bar.

'ESC'- Quit.
Returns to DOS.

REFERENCE:

- "Computer Recreations", A. K. Dewdney, Scientific American,
12/84, pp. 14-22.

- SHARKS! was created using Turbo-C 2.0 from Borland Internat'l.

IMPORTANT:

SHARKS! may be copied and distributed freely about the
planet. SHARKS! is one of thousands of programs created by
thousands of programmers that is available to you, the user,
free of charge. We create these programs out of some specific
need, or out of sheer love for programming, then pass them along
to the rest of the world.
However, if you appreciate excellence in software, and the
fantastic network we have for its distribution, you should
support those involved. If you enjoyed SHARKS! please send $10
to the above address. It won't break you and can only help your
karma.

ALSO by Thomas R. Wilson...

PETE the Amazing Negro - this colorful character comes to
your EGA screen to dazzle you and your friends for hours (or
days!) on end. His talent for exciting the senses is sure
to please.

EGA_LSD - Take a "trip" into the psychedelic world of the
infamous hallucinogen LSD...without leaving your seat or
even taking the drug!

PRISM - An animation from Pink Floyd's Dark Side of the
Moon. Spinning rainbows and sparkling light for the easily
amused.

S O F T W A R E F O R T H E P E O P L E
O F T H E U N I V E R S E !


 December 24, 2017  Add comments

Leave a Reply