home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
- WA-TOR
- A Predator-Prey Simulation
-
- This program is an implementation of the Wa-Tor world
- simulation described by A. K. Dewdney in his "Computer Recre-
- ations" column in the Scientific American, December, 1984, pp.
- 14-22. For a more complete discussion, you should see that
- article. Essentially, it simulates the behavior of a simple
- system of two species, predators ("sharks") and their prey
- ("fish").
-
- According to Dewdney, the simulation was originally imple-
- mented by David Wiseman on a VAX, using an "ocean" of 80-by-23
- points. Dewdney's own version for a PC used five arrays to keep
- track of the positions and properties of the sharks and fish in a
- "humbler, 32-by-14 ocean," and he reports it to be "rather
- slow." Late in the article, Dewdney suggested that it might be
- made to run faster if it were built on linked lists instead of
- arrays. Wanting an exercise in the use of pointers and lists in
- Turbo Pascal, that is how I made it. It uses a 50-by-25 ocean,
- and writes directly to the screen for speed.
-
-
-
-
- What it Does
-
-
- There are three parts to the program.
-
- 1. Some introductory information appears, and you are then
- asked to specify certain parameters. Here they are (with
- my suggestions for values to use in the first run):
-
- - Fish breeding time (try 2)
-
- - Shark breeding time (try 7)
-
- - Shark starvation time --how long they can hold out
- between meals (try 3)
-
- - Initial number of fish (try 500)
-
- - Initial number of sharks (try 100)
-
- - Do you want a record kept (answer Y)
-
- The simulation then begins. You see the fish (dots) and
- the sharks (exclamation points) move and breed. (A newborn
- shark is a bright apostrophe and stays that way until after
- it catches a fish.) And you get various statistics along
- the sides of the display.
-
- The display will run indefinitely. You stop it by pressing
- any key, after which it will complete its current cycle and
-
-
-
-
-
-
-
-
- Wa-Tor: a Predator-Prey Simulation Page 2
-
-
-
- stop. At this point, you get a choice. You can quit or,
- if you've asked that a record be kept, you can choose one
- of the following:
-
- 2. If you have the color/graphics board, you can ask for a
- graph of the first 320 cycles (they are called "Chronons,"
- which is the time unit on Wa-Tor). The graph will appear
- on the screen without text. If you want it printed on
- paper (and have a suitable printer), press P. If you don't
- want the graph printed out, press anything else.
-
- 3. Even if you aren't equipped for graphs, you can get a table
- of the statistics, chronon by chronon. At your choice, you
- can have it printed out or page through it on the screen.
-
-
-
-
- What You Need to Work it:
-
-
- To run the program, put the files WA-TOR.COM and WA-TOR.000
- on a disk in the default drive and enter WA-TOR from the DOS
- prompt.
-
- To get the best out of WA-TOR, you need a color/graphics
- board (though a green monitor is sufficient --that's what I have,
- so there's no color in the program). It looks fine on a text
- monitor with the monochrome display board, but, of course, you
- can't get it to show you a graph.
-
- If you want the graphs printed out, you must run the DOS 2
- GRAPHICS command before you start WA-TOR. The printed graph is
- got by a Print-Screen (don't do it from the keyboard --the pro-
- gram does it better), so you can't get the printed graph unless
- you are equipped for screen graphics. The GRAPHICS command will
- set up an IBM or Epson graphics printer to do it. I'm sure there
- are other graphics programs that work on other printers, but I
- can't help you about that.
-
- Since the program works by printing to the screen memory
- directly, it may not work on all PC clones. I can report that it
- runs fine on a Compaq, both under IBM DOS 2.10 and under Compaq's
- version of MS-DOS 1.10.
-
- One trick: to keep its records, WA-TOR makes a file called
- WA-TOR.DAT on the default disk. If you want to keep the files
- for reference, rename them before you make another run keeping
- records. To print one out, you must rename it back to WA-TOR.DAT
- and run WA-TOR >>without<< keeping records. You can hurry past
- the simulation display by just hitting <ENTER> for all the pa-
- rameters and answering N to "Keep a record?" It will then offer
- you the usual print-out options, and it will make its graph and
- table from whatever is in WA-TOR.DAT on the default disk.
-
-
-
-
-
-
-
-
- Wa-Tor: a Predator-Prey Simulation Page 3
-
-
-
-
-
-
-
- Comments & Suggestions:
-
-
- Essentially, the "ocean" is a rectangular grid. Each crea-
- ture can move in only four directions, one step each chronon.
- The fish aren't very interesting, they move simply at random into
- unoccupied adjoining places. When they breed, they simply
- divide. (Everything on Wa-Tor is parthenogenic). If there's no
- empty place for them, they neither move nor breed. I've put a
- few tricks into the sharks, however. They have just enough in-
- telligence to catch a fish if one adjoins. Otherwise, they move
- at random, unless completely surrounded by other sharks. They
- breed by calving. The calf emerges alongside its mother (pro-
- vided there's an empty place for it). It's fully fed, but the
- mother is not, and has paid a certain price for breeding in that
- she has lost a chance to feed, because she cannot move and catch
- a fish in that chronon. The calf stays in its immature condition
- and does not start its breeding cycle until it catches a fish.
- You can see this because they change to the mature (exclamation
- point) form in the next chronon.
-
- The interesting thing is to vary the parameters and see what
- difference it makes. I've hardly explored the possibilities, but
- I can see a couple of tendencies. Initially, both sharks and
- fish are distributed randomly in the ocean, and they have ran-
- domly assigned stages in their breeding cycles and (for the
- sharks) randomly assigned degrees of hunger. Generally, there's
- a big explosion and then a severe crash in the shark population
- when you start, because the sharks are distributed more or less
- evenly among the fish. After the first recovery, the sharks are
- likely to be unevenly placed, and you begin to get local explo-
- sions and crashes, so the swings in the totals are liable to be
- smaller, though that depends on the parameters.
-
- One curious development: the tougher the sharks, the worse
- the crashes. The parameters I've suggested above usually give a
- fairly severe initial crash, but then the swings damp out. If
- you let the sharks go four or five chronons between meals, they
- seem much more likely to fish out the whole ocean and become
- extinct. So, it seems that weaker sharks are fitter to survive,
- but how could a species evolve that way?
-
- Naturally, the stronger the fish --the more frequently they
- breed, the more sharks they will support. I did some runs with
- the fish breeding every chronon, sharks breeding every ten and
- lasting three chronons between meals, with the result that the
- shark population oscillated gently between about 140 and 300.
-
- I've included the source code in WA-TOR.PAS. If you have a
- Pascal compiler you might try to vary other properties of the
-
-
-
-
-
-
-
-
- Wa-Tor: a Predator-Prey Simulation Page 4
-
-
-
- sharks. Dewdney suggests several possibilities. One might also
- try adding a second predator. Duplicate my shark list with
- another, giving them a distinct symbol in the Procedure Markit
- case structure, and allow the user to assign different proper-
- ties. Then, see how they compete. Or, you might take the in-
- telligence out of a predator (make them move just like the fish),
- and see what happens under various combinations of breeding and
- starving times.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-