home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / fun / games / corewars.spk / !CoreInfo / Info / !Corewars next >
Text File  |  1990-11-15  |  13KB  |  238 lines

  1.  
  2.  
  3.    !CoreWars : Archimedes implementation
  4.    -------------------------------------
  5.  
  6.  This file describes the archimedes implemention of Corewars, and explains
  7. some of the features.
  8.  
  9.  
  10.  Desktop front end
  11.  
  12.  In the Corewars suite of programs, there should be four different applicat-
  13. ion directories, !CoreInfo, !CoreDebug, !CoreProgs and !CoreWars. This suite
  14. is PUBLIC DOMAIN and may only be distributed with all four parts complete.
  15.  
  16.  The purpose of each application unit is as follows:-
  17.  
  18.  !CoreInfo   - Double clicking on this will open a directory viewer holding
  19. six text files, '!Corewars', 'colours', 'intro', 'commands', 'contacts' and
  20. 'glossary'. Some information may be repeated in different files. See the end
  21. of file 'intro' for the contents of the other files. Most information in this
  22. file is for beginners to Corewars, and should be read carefully (if you have
  23. any other queries, problems or have found bugs, please get in touch with me).
  24.  
  25.  !CoreDebug  - Double clicking on this will load up the REDCODE debugger,
  26. which sits on the icon bar. This will process files dragged on to it, giving
  27. a full report on the compilation, in order that you can trace mistakes in
  28. your programs. The same compiler is present in the main program, but does not
  29. give any specific errors, and the actual application !Corewars normally does
  30. not have enough memory to multi-task with !Edit.
  31.  In order that a program is recognized by Corewars, it must have a filetype
  32. 'text', and may contain either line-feeds (ASCII 10) or carriage-returns 
  33. (ASCII 13) to seperate lines. It cannot contain the ASCII value 0, as this
  34. is used as a marker by the compiler. For more details on the actual syntax,
  35. see the file 'commands'.
  36.  
  37.  !CoreProgs  - Double clicking on this will open up a directory viewer of a
  38. directory called 'progs'. Various example programs are in here, and you may
  39. wish to use it for your own programs, but !Corewars doesn't care where you
  40. keep them (which is an advantage over any non-desktop versions).
  41.  
  42.  !CoreWars   - This is the main program in the suite, and deals with the
  43. actual execution of the various programs. It has a desktop front end, with
  44. an options window from which you can select various different configurations,
  45. although once a battle is started, it can be paused and the options changed
  46. via a different menu on-screen.
  47.  To begin with, the various different options are:-
  48.  
  49.  'Flash when dead' - when selected, the program will pause every time a split
  50. halts execution (ie dies) and flash the cell where it tried to execute the
  51. instruction which was invalid. This can slow things down a fair bit, however,
  52. when running programs which repeatedly split execution and then get killed
  53. quickly. Otherwise, the split dying will disappear without a trace.
  54.  
  55.  'Pause between rounds' - this applies to tournaments (see below), and when
  56. selected, the program will beep and display the result at the end of each
  57. round, waiting for space, otherwise it will keep reloading and fighting
  58. rounds until the prescribed number have been fought (without requiring user
  59. interaction).
  60.  
  61.  'Timeout no win' - if the executions limit has been reached (limit set by
  62. user - see below) or the game has been aborted, this will decide the result.
  63. If selected, this will mean that the game is marked 'timeout' and neither
  64. side would score a point in a tournament. Otherwise, the side with the most
  65. instructions originally compiled will win and gain a point in a tournament
  66. (this was to encourage the practice of writing longer, and therefore more
  67. interesting programs).
  68.  
  69.  'Single step' - if selected, the program will pause between each individual
  70. execution of every different split (if more than one exist), to facilitate
  71. easier debugging (if used in conjunction with a debug mode), and you need
  72. to press and release Ctrl-S to step to the next instruction.
  73.  
  74.  'No limit to executions' - normally, there is a limit set to the number of
  75. executions performed by each side before the game is declared a draw, or
  76. whatever. With this option selected, however, the execution counter will
  77. reset itself every time it reaches the limit, so in effect the game never
  78. ends, until a side has died or the user terminates the game with Ctrl-A etc.
  79.  
  80.  'Executions limit' (number) - This determines how many executions will be
  81. performed on either side before the game is considered a draw etc. The limit
  82. is 256-999999 executions (999999 sounds a lot, but some battles last a long
  83. time!)
  84.  
  85.  'Last result:  .. in .. executions' - This gives the result of the last
  86. game, or round played. The possible results are 'green/red win', 'draw' and
  87. 'timeout'. The difference between draw and timeout is thus: If 'timeout no
  88. win' is selected, and a game runs out of time, it is considered a 'timeout'.
  89. Otherwise, if programs are judged for winner by length, and they are of equal
  90. size (ie same program on both sides), then the result is considered a 'draw'.
  91.  
  92.  'Main display window...' - Part of the screen during the actual execution is
  93. set aside for a display of the battle. What the different displays are is as
  94. follows: 'Debug 1' = Dissassembles and prints the last execution performed by
  95. each side underneath the filename of each side, as well as the cell number.
  96. 'Nothing' = just prints the name of each program up, and does nothing else
  97. during the battle to gain extra speed.    'Debug 2' = dissassembles in the
  98. same fashion as 'debug 1', but scrolls each pair of instructions down the
  99. display window, and wraps around constantly, so you can see the previous few
  100. instructions performed by each side, although different splits are not
  101. distinguished between. NB Both debug modes are comparatively slow modes, and
  102. so should only usually be used when debugging if you want more speed at other
  103. times.   Finally..  'Closeup' = During the battle, the pointer is turned on, and restricted to the battle area. Clicking the select button on a point will
  104. enlarge the surrounding cells to x16 in the display window. Clicking the adj-
  105. ust button on a point does the same, but dissassembles the instructions. If
  106. you use <control> with any cursor key, the enlarged display will scroll in
  107. the direction you choose, cell by cell, until you reach the limit of the
  108. battle area.
  109.  
  110.  'random start'  - when selected, the place at which the relevant program
  111. will be initially compiled into memory is determined randomly, and can be any
  112. cell between 0-31999 and no nearer than 2000 cells to the start of the other
  113. program (to prevent overlap of programs) - similarly programs may not extend
  114. more than 1000 cells in either direction when being compiled.
  115.  
  116.  'define start'  - if selected rather than 'random start', the place at which
  117. the relevant program is initially placed in memory is defined by the user,
  118. and the cell address given in the box to the right, with the limitation of
  119. 0-31999 and it cannot be closer than 2000 cells to the other program. If you
  120. are playing a tournament, both programs cannot be in fixed positions for
  121. obvious reasons (work it out for yourself!)
  122.  
  123.  
  124.  Tournaments and related options
  125.  
  126.  One game may not be representative of a program's overall performance
  127. against another, and so to cater for this, a system of tournaments exists
  128. whereby a set number of different 'rounds', or seperate games, are fought
  129. automatically by the computer, and the results collated afterwards. The
  130. number of rounds which can be played is between 1 and 500 (which should give
  131. scope for more realistic results!). This value is entered in the box below
  132. 'number of rounds'.
  133.  To play a tournament, just choose 'tournament' from the main corewars menu
  134. instead of 'one game', and the menu option 'reset table' will reset the
  135. tournament results.
  136.  The results are presented in the box to the right of the program info boxes.
  137.  
  138.  
  139.  
  140.  Program execution
  141.  
  142.  
  143.  Once the programs to fight have been selected by dragging them on the
  144. options window or the !Corewars icon, and either a tournament or one game has
  145. been selected on the menu, the screen is cleared and set up to execute the
  146. programs. The programs are loaded and compiled in turn, and the screen up-
  147. dated to show where they have been placed in memory. The actual compiling
  148. takes only a small fraction of a second once the programs have been loaded.
  149.  The screen display needs a little explanation, and can be divided up into
  150. different areas:-
  151.                               
  152.  
  153.  Main memory display (grey outlined black box in centre of screen) - this is
  154. a  visual representation of the heart of the MARS computer - the core. A
  155. complex colour scheme is used to indicate the status of the different cells
  156. of memory and this is detailed in the file 'colours'. Initially, however, it
  157. is all cleared to black. As the battle progresses, this area will be updated
  158. rapidly as the programs execute.
  159.  
  160.  Display window (blank space below main core window) - this is used in diff-
  161. erent ways depending on the current display mode, but this is where the
  162. debugging, closeups or whatever are displayed during the battle, and also
  163. where the result is displayed after a battle, if applicable.
  164.  
  165.  Options (at top of screen) - Normally inaccessable during the battle, these
  166. options mirror the options on the corewars window on the desktop. If you
  167. press Ctrl+P the battle will be paused, and the mouse appear above the op-
  168. tions. Clicking on an item will either select it (in the case of display
  169. mode) or toggle it. Most items are straightforward, and described above.
  170. To resume the battle, click on the bottom left item 'RESUME'.
  171.  
  172.  Time (long bar along bottom of screen) - This bar shows the relative prog-
  173. ress of the current battle in red, and when the bar reaches the right-hand
  174. end, it will either end the battle in a timeout etc., or reset if 'no limit
  175. to executions' is selected. The length of the bar is calculated to be prop-
  176. ortional to the executions limit.
  177.  
  178.  Splits (counters up left-hand side) - These indicate the number of active
  179. (living) splits existing on both sides (when either reaches zero, one side
  180. has completely died).
  181.  
  182.  Speed (indicator up right-hand side) - This indicator is altered by pressing
  183. Ctrl and either + or - during the battle. When the red bar is fully up, the
  184. programs will execute at full speed with no delays, but otherwise they will
  185. execute more slowly as the bar goes down, to quite a slow speed.
  186.  
  187.  
  188.  
  189.  
  190.  Controls
  191.  
  192.  A summary of the controls available during the battle are as follows:
  193.  (Ctrl=control)
  194.  
  195.  Ctrl alone - select very slow mode; when Ctrl is held down, two things
  196. happen: both programs execute very slowly (1 execution per side per 1/50
  197. second [vsync]) and every instruction executed is highlighted for a short
  198. duration. This also happens during single step mode.
  199.  
  200.  Ctrl+ '+'          increase speed
  201.  Ctrl+ '-'          decrease speed
  202.  Ctrl+P             pause
  203.  Ctrl+S             step through instructions (in single step mode)
  204.  Ctrl+A             abort one round (or game)
  205.  Ctrl+Q             abort whole tournament including current round
  206.  Ctrl+<cursor key>  scroll display window when in closeup mode (mouse pointer
  207.                     will move to point to centre of enlargement)
  208.  
  209.  
  210.  
  211.  Programming techniques
  212.  
  213.  The archimedes version of Corewars has several different parts to it. The
  214. desktop front-end of !Corewars and !CoreDebug is written almost entirely in
  215. BASIC. The compiler sections of both programs is written in machine code, and
  216. most of the MARS simulation is machine code except for little sections during
  217. pauses and after battles etc. This is to give the greatest speed possible.
  218.  There are two main arrays in memory which are needed to run programs. The 
  219. first contains the opcodes of all the instructions, and is bytewise. The
  220. high nibble (top 4 bits) of each byte is the opcode (0-15) and the low nibble
  221. contains the addressing mode flags (a total of 2 bits for each operand).
  222.  The second array contains the operands, and each cell is a word long (4
  223. bytes). The high two bytes contain operand A, with the top bit indicating
  224. sign, and the low two bytes contain operand B in the same way.
  225.  A further array of a kind would be needed to provide information such as
  226. whether the cell was protected, and unneccessary but useful information such
  227. as whether the cell had been executed, and by whom. Because writing to a
  228. seperate status array and then plotting points on the screen to update the
  229. change in status would be time-consuming and also space-devouring (it would
  230. need another 32000 unit array), I decided to take a risky shortcut and
  231. directly access screen memory, and the different bytes representing the
  232. different colours on screen are manipulated in such a way as if they are
  233. just bit-flags. The result is a high operating speed and a saving of space,
  234. and the closeup display routine, for example, only needs to just copy one
  235. block of screen memory to another, enlarging in the process.
  236.  
  237.  I hope you can make good use of this program and are interested in the ideas
  238. behind its creation and philosophy.