home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1995 March / SOFM_Mar1995.bin / pc / sri / kids / corewars.280 / corewars.doc < prev    next >
Text File  |  1995-01-27  |  14KB  |  363 lines

  1.      COREWARS (Revision 2.80)                              Page 1 of 7
  2.      Copyright (c) Triskelian Simulations 1990.
  3.  
  4.  
  5.  
  6.  
  7.      Program:   COREWARS
  8.      Revision:  2.80
  9.      Date:      24 August 1991
  10.  
  11.  
  12.      COREWARS (just a little light reading)
  13.      ======================================
  14.  
  15.      The enclosed files are released (again) into the public domain.
  16.      The original program I found was written by Kevin A. Bjorke in
  17.      May 1984.  Mr.Bjorke's version was targeted at Unix machines and
  18.      used the Small-C dialect.
  19.  
  20.      The program itself is based on several Scientific American
  21.      "Computer Recreations" articles written by A.K.Dewdney.  These
  22.      articles appeared in the May 1984, March 1985, and January 1987
  23.      issues.  Check these articles at your local library for the gory
  24.      details.
  25.  
  26.      Mr.Dewdney also describes COREWARS in his book, "The Armchair
  27.      Universe: An exploration of Computer Worlds", W.H.Freeman and
  28.      Company, New York, 1988.
  29.  
  30.  
  31.      So What IS "COREWARS"?
  32.      ======================
  33.  
  34.      The idea behind COREWARS is that two mutually antagonistic
  35.      programs are loaded into the memory of a hypothetical machine.
  36.      The two programs then try to obliterate each other.  They may
  37.      shoot at each other, roll over one another, whatever.  The first
  38.      program to crash and burn, or to start executing the other
  39.      program's code, LOSES.
  40.  
  41.  
  42.      COREWARS v2.80
  43.      ==============
  44.  
  45.      This program (COREWARS) plays the part of the hypothetical
  46.      machine and referee.  There are a few additions and enhancements
  47.      added to this version.  (How's that for understatement?)
  48.  
  49.      This program supports up to eight initial programs.  Each program
  50.      may spawn as many other programs (called tasks, just to be
  51.      obnoxious) as it wants, up to a user specified per program and
  52.      per system limit (currently 255).  Each program is loaded
  53.      starting at a random location (this version supports either
  54.      random or fixed starting locations, that's up to you).
  55.  
  56.      Speaking of memory, this version provides two different methods
  57.      of defining memory range.  You may select the overall memory
  58.      COREWARS (Revision 2.80)                              Page 2 of 7
  59.      Copyright (c) Triskelian Simulations 1990.
  60.  
  61.      size, from 500 to 8000 locations.  You may also set the
  62.      addressing range, from 1/32 to the entire available memory range.
  63.  
  64.      You may specify the number of instructions per cycle, i.e. how
  65.      many instructions each task may execute sequentially before
  66.      another task gets to execute.  The original COREWARS used a 1:1
  67.      ratio.  This version allows any ratio up to 64:1.
  68.  
  69.      You may also specify the task scheduling method used.  By default
  70.      this version will use a task number based round robin scheduler.
  71.      This means it just goes from task to task in sequential numeric
  72.      order (e.g. 1,2,3,etc.).  As Dewdney points out, this can give an
  73.      undo advantage to "rabbit" programs.  This is the NUMERIC
  74.      scheduling option.
  75.  
  76.      The two alternative scheduling methods are PROGRAM and
  77.      INTERLEAVE.  Program is blatantly unfair, but interesting for
  78.      comparison purposes.  This scheduling approach runs all of each
  79.      programs tasks as a single clump, before proceeding to the next
  80.      program (e.g. A1,A2,A3,B1,B2,C1, etc.).  By contrast, the
  81.      INTERLEAVE scheduler attempts to mix tasks from each of the
  82.      original programs (e.g. A1,B1,C1,A2,B2,C1,A1,B3,C1,etc.).
  83.  
  84.      The display is peculiar to this particular COREWARS incarnation.
  85.      You may specify which, if any, program is to be displayed.  You
  86.      may select detailed display, which will also display the
  87.      effective addresses for each instruction as they are resolved.
  88.      The instruction steps are displayed on the right hand side of the
  89.      runtime display screen.  The particular program and display mode
  90.      are displayed at the top of the screen.
  91.  
  92.      COREWARS statistics are displayed on the lefthand side of the
  93.      screen.  The current cycle, slice (instruction within a cycle),
  94.      active task, total instruction count, and free memory information
  95.      are continually displayed.  Below this is a table detailing the
  96.      current status for each active program (all task information is
  97.      reflected under the appropriate parent program).  This area is
  98.      continually updated in conjunction with the program instruction
  99.      display.  The statistics display will also be automatically
  100.      updated every 100 cycles.
  101.  
  102.      You can single step execution OF THE DISPLAYED PROGRAM ONLY.
  103.      Press "S" each time you want to single step the next instruction
  104.      of the program being displayed.  The breakpoint occurs AFTER the
  105.      execution of the instruction.  The breakpoint will not be reached
  106.      if the current instruction causes the battle program to die.
  107.  
  108.      When the COREWARS programs are running you may pause the program
  109.      by pressing "P".  You can abort the combat by pressing [ESCAPE].
  110.  
  111.      COREWARS (Revision 2.80)                              Page 3 of 7
  112.      Copyright (c) Triskelian Simulations 1990.
  113.  
  114.      "REDCODE"
  115.      =========
  116.  
  117.      Core Wars uses a machine language-like instruction set called
  118.      "REDCODE".  The table below shows the basic instruction formats
  119.      and their addressing modes.  Programs must be terminated by the
  120.      pseudo-instruction END (no arguments).  Note that the
  121.      instructions [DJN, PCT, SPL, SWP] are all extensions to the
  122.      original REDCODE instruction set.
  123.  
  124.  
  125.      Description                Instruction    Notes
  126.      -----------------------------------    -----------    -----
  127.      Add A to B                    ADD   A   B
  128.      Compare A to B, skip next loc if !=    CMP   A   B
  129.      Data                    DAT       B
  130.      Decrement B, jump to A if nonzero         DJN   A   B    1
  131.      Decrement B, jump to A if zero         DJZ   A   B    1
  132.      Jump to A if B is > zero            JMG   A   B
  133.      Jump to A                    JMP   A
  134.      Jump to A if B is zero            JMZ   A   B
  135.      Move A to B                MOV   A   B
  136.      Protect                    PCT   A        2
  137.      Split (spawn task)                SPL   A        2
  138.      Subtract A from B                SUB   A   B
  139.      Swap contents of A and B            SWP   A   B     3
  140.  
  141.           Addressing modes:  IMMEDIATE    #n
  142.                        DIRECT        n
  143.                        INDIRECT     @n
  144.  
  145.           Notes:
  146.  
  147.           1)  As has been pointed out, these were confused in
  148.               A.K.Dewdney's original discussions.  I have chosen the
  149.               coward's solution: implement both.
  150.  
  151.           2)  These are extensions proposed by Dewdney.
  152.  
  153.           3) This was added for amusement value.  Neither argument may
  154.               be immediate.
  155.  
  156.  
  157.      COREWARS (Revision 2.80)                              Page 4 of 7
  158.      Copyright (c) Triskelian Simulations 1990.
  159.  
  160.      This is not the place to describe what assembly language
  161.      programming is all about.  People have written entire books on
  162.      the subject.  (Then again, people have written entire books on
  163.      the mating habits of frogs.)  The original Scientific American
  164.      articles contain a good overview and list some useful references
  165.      for further reading.
  166.  
  167.  
  168.      SAMPLE PROGRAMS
  169.      ===============
  170.  
  171.      Some sample REDCODE programs have been included.  All of the
  172.      sample programs are in files with an *.WAR extension.  Many of
  173.      these programs are taken directly from the magazine articles and
  174.      discussed there in some detail.  Two programs, A_IMP and AA_IMP,
  175.      were borrowed from R.Sawyer.  DDWARF and IMPACT were added just
  176.      to keep everything interesting.
  177.  
  178.      New combatants:
  179.      IMPGUN2, comes from D.Sharpe.
  180.      MORTAR, is inspired by Michael L. Mauldin.
  181.      MORTAR2, is my own MORTAR variant.
  182.      TRAPDWARF, is inspired by Stephen Peters and Mark A. Durham.
  183.  
  184.  
  185.      Filename    Description
  186.      --------    -----------
  187.      CHANG1    A sample sophisticated program using SPL
  188.  
  189.      DWARF    A simple attack program, step of 5
  190.      DWARF7    Same as DWARF, step of 7
  191.      DWARF13    Same as DWARF, step of 13
  192.      DWARF29    Same as DWARF, but hits every 29th
  193.      DDWARF    DWARF modified to cope with PCT instruction
  194.      MORTAR    Like DWARF, but using a Fibonacci sequence
  195.      MORTAR2    A variant of MORTAR, using PCT also
  196.      TRAPDWARF    An anti-DWARF program
  197.  
  198.      GEMINI    A self-cloning program (offset 100)
  199.      BIGFOOT    A GEMINI clone using a large prime number offset
  200.      JUGGER    "JUGGERNAUT", a GEMINI clone that rolls through memory
  201.  
  202.      IMP    Core Wars' answer to the tortoise
  203.      IMPGUN    An IMP deringer (i.e. 2 shot)
  204.      IMPGUN2    An IMP generator
  205.  
  206.      IMPSTOMP    Defensive Anti-IMP program
  207.      IMPACT    IMPSTOMP using PCT instruction
  208.      A_IMP    Anti-IMP program
  209.      AA_IMP    Anti-Anti-IMP program
  210.  
  211.  
  212.      COREWARS (Revision 2.80)                              Page 5 of 7
  213.      Copyright (c) Triskelian Simulations 1990.
  214.  
  215.      REVISION HISTORY
  216.      ================
  217.  
  218.         "There I was, basking in the egocentric glow of COREWARS
  219.         v2.22.  And then I spotted D.Sharpe's COREWARS 3.0 on a local
  220.         BBS!  OK, so this particular programmer has a wee bit of ego.
  221.         I'll just add one or two things..."
  222.  
  223.      That was a year ago.  I have no excuse for all the time I spent
  224.      on it this year. <grin>
  225.  
  226.      Version 2.70
  227.      -------------
  228.      1. Implement SPL instruction.
  229.      2. Correct detailed display for newer REDCODE instructions.
  230.      3. Add single step option.
  231.      4. Allow user to select task scheduling algorithm.  Only round
  232.         robin scheduling is currently implemented.
  233.  
  234.      Version 2.60
  235.      -------------
  236.      1. Corrected overflow error in ADD/SUB instructions.
  237.  
  238.      Version 2.50
  239.      ------------
  240.      1. Change user runtime display.
  241.      2. Allow user interaction with runtime operation.
  242.      3. Allow user to enter up to eight initial programs.
  243.      4. Add MORTAR and MORTAR2 *.WAR programs.
  244.  
  245.      Version 2.40
  246.      ------------
  247.      1. Add printer dumps.
  248.      2. Allow user to specify multiple memory ranges on display/dumps.
  249.      3. Add DJN and SWP instructions.
  250.      4. Add hooks to support SPL instruction in future release.
  251.         It is currently processed as a "NOP".
  252.      5. Add memory "fuelgauge", numeric indicator of memory ownership.
  253.      6. Allow user to save REDCODE programs to disk.
  254.  
  255.      Version 2.30
  256.      ------------
  257.      1. Add more sample programs.
  258.      2. Standardize documentation with other Triskelian Simulation
  259.         products.
  260.      3. Internal code cleanup.
  261.  
  262.      Version 2.22
  263.      ------------
  264.      1. Selectable instruction addressing range.
  265.  
  266.      COREWARS (Revision 2.80)                              Page 6 of 7
  267.      Copyright (c) Triskelian Simulations 1990.
  268.  
  269.      Version 2.21
  270.      ------------
  271.      1. Show user why *.WAR file input aborted and recover.
  272.      2. Trap user null programs and recover.
  273.  
  274.      Version 2.20
  275.      ------------
  276.      1. Added PCT instruction.
  277.      2. Detect program subversion (IMP problem).
  278.      3. User interrupt of memory dump (hit [ESCAPE]).
  279.      4. Add flags (MemA, MemB, PROTECT) to memory dump.
  280.      5. Cosmetic changes to execution display.
  281.  
  282.      Version 2.11
  283.      ------------
  284.      1. Selectable CPU slice (instructions per cycle).
  285.      2. Added numerous *.WAR files.
  286.  
  287.      Version 2.10
  288.      ------------
  289.      1. Use the *.WAR extension (borrowed from R.Sawyer).
  290.      2. Semicolon comments in *.WAR files.
  291.      3. Selectable maximum memory size.
  292.      4. Selectable starting locations.
  293.      5. Options to suppress execution outputs.
  294.      6. Flags to support memory displays, PCT, etc..
  295.      7. A_IMP.WAR & AA_IMP.WAR (borrowed from R.Sawyer).
  296.  
  297.      Version 2.00
  298.      ------------
  299.      1. Upgrade COREWARS Small-C to Turbo-C, ANSI, etc.
  300.  
  301.  
  302.      FOR MORE INFORMATION
  303.      ====================
  304.  
  305.      Contact the following people for further information about
  306.      COREWARS.  Please note this information is several years old and
  307.      therefore rather suspect.
  308.  
  309.                International Core Wars Society
  310.                          and/or
  311.                The Core Wars Newsletter
  312.                William R. Buckley
  313.                5712 Kern Drive
  314.                Huntington Beach, CA   92649
  315.  
  316.                A.K.Dewdney
  317.                c/o The Editors
  318.                Scientific American
  319.                415 Madison Avenue
  320.                New York, NY  10017
  321.  
  322.  
  323.      COREWARS (Revision 2.80)                              Page 7 of 7
  324.      Copyright (c) Triskelian Simulations 1990.
  325.  
  326.      NONE OF THE ABOVE (obviously)
  327.      =============================
  328.  
  329.      COREWARS requires ANSI.SYS support to run normally.  If you start
  330.      seeing things like "[4;H" or "[35m" popping up on your screen --
  331.      DON'T PANIC.  Just add a line like "DEVICE=ANSI.SYS" to your
  332.      CONFIG.SYS file.  Pertinent details can be found in your (or
  333.      anybody else's) DOS manual.
  334.  
  335.      This program is hereby released to the PUBLIC DOMAIN.  No copies
  336.      or derivatives of this product may be distributed for profit or
  337.      personal gain.  A minimal handling fee may be charged for
  338.      distribution.
  339.  
  340.      COREWARS and any associated files and documentation are
  341.      distributed without any express or implied warranties.
  342.      Triskelian Simulations does not warrant that COREWARS or any
  343.      associated files operate as claimed.  You the user assume full
  344.      risk for any direct or consequential damages, even if Triskelian
  345.      Simulations has been advised of the possibility of any damages.
  346.      By using this program you agree to abide by the terms and
  347.      conditions stated above.
  348.  
  349.      If all else fails, contact Triskelian Simulations on our local
  350.      support bulletin board:  TECHLINE BBS  (206)532-9220.  We are
  351.      probably more confused than you are, but we will try and help.
  352.  
  353.      One final parting shot, er, note.  I would like to thank Richard
  354.      Edwards for nagging me so much about COREWARS that I spiffied the
  355.      thing up just to make him go away.  Actually, it was a blast.
  356.  
  357.  
  358.      David E. Thomas
  359.      Triskelian Simulations
  360.      630 Washington
  361.      Hoquiam, WA  98550
  362.      FIDOnet (1:352/30.3)
  363.