home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / wator.zip / REN0056.REN < prev    next >
Text File  |  1984-12-23  |  10KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.                                         WA-TOR
  6.                               A Predator-Prey Simulation
  7.  
  8.               This program is an implementation of the Wa-Tor world
  9.           simulation described by A. K. Dewdney in his "Computer Recre-
  10.           ations" column in the Scientific American, December, 1984, pp.
  11.           14-22.  For a more complete discussion, you should see that
  12.           article.  Essentially, it simulates the behavior of a simple
  13.           system of two species, predators ("sharks") and their prey
  14.           ("fish").
  15.  
  16.               According to Dewdney, the simulation was originally imple-
  17.           mented by David Wiseman on a VAX, using an "ocean" of 80-by-23
  18.           points.  Dewdney's own version for a PC used five arrays to keep
  19.           track of the positions and properties of the sharks and fish in a
  20.           "humbler, 32-by-14 ocean," and he reports it to be "rather
  21.           slow."  Late in the article, Dewdney suggested that it might be
  22.           made to run faster if it were built on linked lists instead of
  23.           arrays.  Wanting an exercise in the use of pointers and lists in
  24.           Turbo Pascal, that is how I made it.  It uses a 50-by-25 ocean,
  25.           and writes directly to the screen for speed.
  26.  
  27.  
  28.  
  29.  
  30.           What it Does
  31.  
  32.  
  33.               There are three parts to the program.
  34.  
  35.             1.  Some introductory information appears, and you are then
  36.                 asked to specify certain parameters.  Here they are (with
  37.                 my suggestions for values to use in the first run):
  38.  
  39.                   -  Fish breeding time (try 2)
  40.  
  41.                   -  Shark breeding time (try 7)
  42.  
  43.                   -  Shark starvation time --how long they can hold out
  44.                      between meals (try 3)
  45.  
  46.                   -  Initial number of fish (try 500)
  47.  
  48.                   -  Initial number of sharks (try 100)
  49.  
  50.                   -  Do you want a record kept (answer Y)
  51.  
  52.                 The simulation then begins.  You see the fish (dots) and
  53.                 the sharks (exclamation points) move and breed.  (A newborn
  54.                 shark is a bright apostrophe and stays that way until after
  55.                 it catches a fish.)  And you get various statistics along
  56.                 the sides of the display.
  57.  
  58.                 The display will run indefinitely.  You stop it by pressing
  59.                 any key, after which it will complete its current cycle and
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.           Wa-Tor: a Predator-Prey Simulation                         Page 2
  69.  
  70.  
  71.  
  72.                 stop.  At this point, you get a choice.  You can quit or,
  73.                 if you've asked that a record be kept, you can choose one
  74.                 of the following:
  75.  
  76.             2.  If you have the color/graphics board, you can ask for a
  77.                 graph of the first 320 cycles (they are called "Chronons,"
  78.                 which is the time unit on Wa-Tor).  The graph will appear
  79.                 on the screen without text.  If you want it printed on
  80.                 paper (and have a suitable printer), press P. If you don't
  81.                 want the graph printed out, press anything else.
  82.  
  83.             3.  Even if you aren't equipped for graphs, you can get a table
  84.                 of the statistics, chronon by chronon.  At your choice, you
  85.                 can have it printed out or page through it on the screen.
  86.  
  87.  
  88.  
  89.  
  90.           What You Need to Work it:
  91.  
  92.  
  93.               To run the program, put the files WA-TOR.COM and WA-TOR.000
  94.           on a disk in the default drive and enter WA-TOR from the DOS
  95.           prompt.
  96.  
  97.               To get the best out of WA-TOR, you need a color/graphics
  98.           board (though a green monitor is sufficient --that's what I have,
  99.           so there's no color in the program).  It looks fine on a text
  100.           monitor with the monochrome display board, but, of course, you
  101.           can't get it to show you a graph.
  102.  
  103.               If you want the graphs printed out, you must run the DOS 2
  104.           GRAPHICS command before you start WA-TOR.  The printed graph is
  105.           got by a Print-Screen (don't do it from the keyboard --the pro-
  106.           gram does it better), so you can't get the printed graph unless
  107.           you are equipped for screen graphics.  The GRAPHICS command will
  108.           set up an IBM or Epson graphics printer to do it.  I'm sure there
  109.           are other graphics programs that work on other printers, but I
  110.           can't help you about that.
  111.  
  112.               Since the program works by printing to the screen memory
  113.           directly, it may not work on all PC clones.  I can report that it
  114.           runs fine on a Compaq, both under IBM DOS 2.10 and under Compaq's
  115.           version of MS-DOS 1.10.
  116.  
  117.               One trick: to keep its records, WA-TOR makes a file called
  118.           WA-TOR.DAT on the default disk.  If you want to keep the files
  119.           for reference, rename them before you make another run keeping
  120.           records.  To print one out, you must rename it back to WA-TOR.DAT
  121.           and run WA-TOR >>without<< keeping records.  You can hurry past
  122.           the simulation display by just hitting <ENTER> for all the pa-
  123.           rameters and answering N to "Keep a record?"  It will then offer
  124.           you the usual print-out options, and it will make its graph and
  125.           table from whatever is in WA-TOR.DAT on the default disk.
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.           Wa-Tor: a Predator-Prey Simulation                         Page 3
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.           Comments & Suggestions:
  143.  
  144.  
  145.               Essentially, the "ocean" is a rectangular grid.  Each crea-
  146.           ture can move in only four directions, one step each chronon.
  147.           The fish aren't very interesting, they move simply at random into
  148.           unoccupied adjoining places.  When they breed, they simply
  149.           divide.  (Everything on Wa-Tor is parthenogenic).  If there's no
  150.           empty place for them, they neither move nor breed.  I've put a
  151.           few tricks into the sharks, however.  They have just enough in-
  152.           telligence to catch a fish if one adjoins.  Otherwise, they move
  153.           at random, unless completely surrounded by other sharks.  They
  154.           breed by calving.  The calf emerges alongside its mother (pro-
  155.           vided there's an empty place for it).  It's fully fed, but the
  156.           mother is not, and has paid a certain price for breeding in that
  157.           she has lost a chance to feed, because she cannot move and catch
  158.           a fish in that chronon.  The calf stays in its immature condition
  159.           and does not start its breeding cycle until it catches a fish.
  160.           You can see this because they change to the mature (exclamation
  161.           point) form in the next chronon.
  162.  
  163.               The interesting thing is to vary the parameters and see what
  164.           difference it makes.  I've hardly explored the possibilities, but
  165.           I can see a couple of tendencies.  Initially, both sharks and
  166.           fish are distributed randomly in the ocean, and they have ran-
  167.           domly assigned stages in their breeding cycles and (for the
  168.           sharks) randomly assigned degrees of hunger.  Generally, there's
  169.           a big explosion and then a severe crash in the shark population
  170.           when you start, because the sharks are distributed more or less
  171.           evenly among the fish.  After the first recovery, the sharks are
  172.           likely to be unevenly placed, and you begin to get local explo-
  173.           sions and crashes, so the swings in the totals are liable to be
  174.           smaller, though that depends on the parameters.
  175.  
  176.               One curious development: the tougher the sharks, the worse
  177.           the crashes.  The parameters I've suggested above usually give a
  178.           fairly severe initial crash, but then the swings damp out.  If
  179.           you let the sharks go four or five chronons between meals, they
  180.           seem much more likely to fish out the whole ocean and become
  181.           extinct.  So, it seems that weaker sharks are fitter to survive,
  182.           but how could a species evolve that way?
  183.  
  184.               Naturally, the stronger the fish --the more frequently they
  185.           breed, the more sharks they will support.  I did some runs with
  186.           the fish breeding every chronon, sharks breeding every ten and
  187.           lasting three chronons between meals, with the result that the
  188.           shark population oscillated gently between about 140 and 300.
  189.  
  190.               I've included the source code in WA-TOR.PAS.  If you have a
  191.           Pascal compiler you might try to vary other properties of the
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.           Wa-Tor: a Predator-Prey Simulation                         Page 4
  201.  
  202.  
  203.  
  204.           sharks.  Dewdney suggests several possibilities.  One might also
  205.           try adding a second predator.  Duplicate my shark list with
  206.           another, giving them a distinct symbol in the Procedure Markit
  207.           case structure, and allow the user to assign different proper-
  208.           ties.  Then, see how they compete.  Or, you might take the in-
  209.           telligence out of a predator (make them move just like the fish),
  210.           and see what happens under various combinations of breeding and
  211.           starving times.
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.