home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / corewars.zip / COREWARS.DOC < prev    next >
Text File  |  1986-05-20  |  7KB  |  141 lines

  1.             COREWARS.DOC  09/22/1984
  2.  
  3.         Documentation for COREWARS.EXE Ver. 2.00
  4.  
  5.  
  6. This  game was written by A.K.  Dewdney and presented in the May,
  7. 1984  issue  of  Scientific  American  magazine.   Since  it   is
  8. impossible  to explain all its details here without infringing on
  9. Scientific American's copyrights, you'll have to get a  copy  and
  10. read the instructions for yourself.
  11.  
  12. This  particular  realization  of  Dewdney's  game was written by
  13. Kevin A.  Bjorke,  who  retains  copyrights.   Mr.   Bjorke  has,
  14. however,   released   the   game   to   the   public  domain  for
  15. non-commercial use only.
  16.  
  17. Bob  Green  converted  Bjorke's  work  to  MS-DOS  V.   2.xx from
  18. Bjorke's original in CP/M and from Small-C V.  2.03  to  Computer
  19. Innovations'  C86  on  June  7,  1984.   Mr.  Green's version was
  20. customized for the TeleVideo 950 terminal and reduced the size of
  21. Dewdney's core from 8000 bytes to 1000.  This  game  can  take  a
  22. long  time  to  run if both players' instructions to the computer
  23. are sophisticated.  Smaller core may shorten the  time  of  play.
  24. On the other hand, it might not.
  25.  
  26. Harvey  Lord converted Green's work to the Lattice C compiler, V.
  27. 2.12 and to the VT-100 terminal on September 22,  1984.   It  now
  28. runs  correctly on the DEC Rainbow 100, 100+ and 100B, and on the
  29. IBM PC (and clones) running DOS V.  2.xx when the  ANSI  terminal
  30. device drivers have been installed at cold boot.
  31.  
  32.                   *****
  33.  
  34. Core  Wars  pits one computer program against another in the dark
  35. and lonely corridors of  your  computer's  main  memory,  "core,"
  36. named  after  the memory cores or rings of late 1950s-early 1960s
  37. computers.  Each player writes his or her program, enters it  via
  38. prompts  at  the  outset or by having it in a file which COREWARS
  39. reads.  The programs  then  take  turns  executing  instructions,
  40. first  one,  then  the  other.   Once execution begins, the first
  41. program to render the  other  incapable  of  executing  its  next
  42. instruction wins.
  43.  
  44. The programs COREWARS executes are written in a simple version of
  45. assembly   code   called   REDCODE.    REDCODE   has   only  nine
  46. instructions.
  47.  
  48. INSTRUCTION     MNEMONIC        CODE    ARGUMENTS     EXPLANATION
  49. -----------     --------        ----    ---------     -----------
  50.  
  51.    Move           MOV            1        A   B     Move contents of
  52.                                                     addr A to addr B
  53.  
  54.    Add            ADD            2        A   B     Add  contents of
  55.                                                     addr A to addr B
  56.  
  57.    Subtract       SUB            3        A   B     Subtract contents
  58.                                                     of addr A from
  59.                                                     addr B
  60.  
  61.    Jump           JMP            4        A         Transfer control
  62.                                                     to addr A
  63.  
  64.    Jump if zero   JMZ            5        A   B     Transfer  control
  65.                                                     to addr A if con-
  66.                                                     tents of  addr B
  67.                                                     are zero
  68.  
  69.    Jump if        JMG            6        A   B     Transfer  control
  70.    greater                                          to addr A if con-
  71.                                                     tents of B are
  72.                                                     greater than zero
  73.  
  74.    Decrement:     DJZ            7        A   B     Subtract  1 from con-
  75.    jump if zero                                     tents of  addr B  and
  76.                                                     transfer  control  to
  77.                                                     addr A if contents of
  78.                                                     addr B are then zero
  79.  
  80.    Compare        CMP            8        A   B     Compare contents of
  81.                                                     addrs A  and B;  if
  82.                                                     they  are  unequal,
  83.                                                     skip the next inst.
  84.  
  85.    Data statement DAT            9            B     A nonexecutable
  86.                                                     statement:  B is
  87.                                                     the data value
  88.  
  89.  
  90. There  are  three  instruction  "modes,"  direct,  indirect,  and
  91. immediate.  In direct mode, arguments are relative  addresses  on
  92. which the program directly acts.  They are "relative" to wherever
  93. the  program happens to be when it executes that instruction.  In
  94. indirect mode, specified by a @ before  the  argument,  the  data
  95. acted  upon are found in the address specified by the contents of
  96. the specified address.  In  immediate  mode,  specified  by  a  #
  97. before  the  argument, the argument is treated as data, not as an
  98. address.  If you find this explanation  confusing,  don't  worry.
  99. Dewdney provides examples and expansion in his article.
  100.  
  101. Here are two simple programs  written  in  REDCODE  that  produce
  102. interesting results.  One is called IMP, the other, DWARF.
  103.  
  104.                    IMP
  105.  
  106. MOV  0  1
  107.  
  108. IMP  has  only  one  instruction,  executes from there.  It moves
  109. itself from its starting location, that is relative address 0, to
  110. the next one and executes again from there.  The idea is to  plow
  111. right  through  its opponent, thereby destroying it.  It's a dumb
  112. program, but dangerous.
  113.  
  114.                   DWARF
  115.  
  116. DAT    -1
  117. ADD #5 -1
  118. MOV #0 @-2
  119. JMP -2
  120.  
  121. Execution begins at the ADD instruction.  DWARF simply sits still
  122. where  it  is,  but peppers the rest of memory with 0s.  Since an
  123. instruction is not executable when its memory address contains  a
  124. NULL (0), if DWARF fills its opponent's next address with a NULL,
  125. it wins.
  126.  
  127. Dewdney  provides  one  more, longer program, called GEMINI, that
  128. relocates itself and gives suggestions on  how  to  write  others
  129. that  protect themselves, relocate themselves, repair themselves,
  130. and attack their opponents.  It's a first-rate article; read it.
  131.  
  132. If  you  come  up with some nifty REDCODE programs, Dewdney would
  133. like to  hear  of  it  (and  so  would  I).   He's  reachable  at
  134. Scientific American, 415 Madison Avenue, New York, NY 10017.  I'm
  135. a   programmer   at  Traveler's  Insurance  Co.   Contact  me  at
  136. 203-429-8044 after 5:00 P.M.  EST or on weekends.
  137.  
  138. Enjoy.
  139.  
  140. Harvey Lord
  141.