Contents
CoreWin is a Core War simulator for the
Windows environment. It provides a visual arena in which Core War programs, or
“warriors”, battle each other. It is simple to use and visually appealing, with
high-resolution graphics and GUI controls. An unlimited number of warriors can
battle simultaneously in a Core of up to 130,000,000 memory locations.
This document is intended only as a user’s guide to the
simulator; it does not describe Core War, or how to write Core War programs.
For these topics, please refer to the introductory materials at http://www.corewar.info, http://www.koth.org, and many other Core War
sites.
·
Full support of ICWS’94 standards, with all current
extensions
·
Built-in editor and compiler, with full support for
multi-line EQUates, for/rof loops, and complex expressions. Shows detailed
descriptions of all compile errors.
·
User-selectable parameters, including read/write
limits
·
Four kinds of tournament play: Melee, Challenge,
Round-Robin, and Benchmark
·
Multiple core views, showing color-coded instructions,
that update in real time
·
P-space view, showing contents of p-space for any
warrior
·
Conditional breakpoints
·
Editable core contents, p-space, and process queues
To get started:
·
Run CoreWin.exe; the main window will come up.
·
Click the Setup button to bring up the Settings dialog
box. Here, you can choose warriors, set up tournaments, and change the core
size and many other parameters.
o
The Add button, next to the Warrior list, will bring
up a file browser. Choose one or more warriors, and click OK to add them to the
list.
o
Change any parameters you wish, and click OK.
·
On the main window, click the Start button to launch
the battle.
·
Click Stop to pause the battle. Click Start to resume
or Single Step to execute one instruction of each warrior.
·
Use the slider control just above the buttons to
govern the speed of the battle.
·
At the end of the battle, the Battle Status line lets
you know who won.
·
Click New Battle to set up a new battle using the
same warriors and parameters, or click Setup again to pick new ones.
You’re on your way! Enjoy.
This window allows the user to control and monitor each
battle.

The progress of a battle is displayed graphically on one or
more rectangular display areas. There are two display topologies to choose
from:
Each memory location in the Core is assigned a block on the
screen. The color of each block reflects the contents of the corresponding
memory location. Each warrior is assigned a distinguishing color. Black
represents empty core, and gray is an unused portion of the graphics area, not
part of Core. A red spot marks the process of each warrior that will execute
next.

Blocks can be different sizes, up to 8x8 pixels per cell;
smaller block sizes show more of the total Core. The block size adjusts
automatically to show the entire Core for any given Core size and display
topology. The shape of each block reflects the action that last took place at
the corresponding core location:
Action |
Shape, 4x4 and 8x8 |
Shape, 2x2 pixels |
Shape, 1x1 pixel |
|
Executed |
Solid square, black border |
Solid square |
Dot |
|
Written to |
X |
/ |
Dot |
|
Incremented |
+ |
| |
Dot |
|
Decremented |
- |
- |
Dot |
|
Compared or read |
Dot |
Dot |
Dot |
For large Core sizes, only the first 262,144 locations
(131,072 for rectangular topology) are visible.
Clicking anywhere in the display area will open a Core View
window at that location; or, if one is already open, will change the location
of the most recently used Core View window. The range of instructions shown by
each open Core View window is marked with a red underline in the Core display.
This area displays the key battle parameters and the status
of the current battle. Core size is the size of Core for the current battle,
and Max Cycles is the number of instruction cycles per warrior before a draw is
declared. Battle Status can be In Progress, Stopped, Drawn, or Won by one of
the warriors. The Completion progress bar shows the percentage of Max Cycles
that has elapsed.
Tournament progress is also shown in this area. The
tournament type can be Melee, Round Robin, Benchmark, or Challenge. (See the Settings
section for a description of the tournament types.) The number of rounds that
have been fought between the current matchup (combination of warriors) is
shown, as well as how many matchups have taken place. The Show Results button
brings up the Tournament Results window.
This may be viewed at any time during a tournament.
The right-hand part of the central area contains one row of
controls for each warrior, up to eight. Warriors beyond the first eight may be
accessed through the warrior list in the Settings
dialog.
The name of each warrior is shown in a button; clicking this
button brings up the Edit Warrior window. The
color bar at the right shows the color of this warrior, and the current number
of live processes. The progress bar shows the number of live processes as a
percentage of the maximum allowed (which is shown at the top of this area as
Max Processes).
When CoreWin is first started, no warriors have yet been
loaded, so the warrior area is empty. When the source code of at least one
warrior has been loaded using the Settings dialog, the warriors that will
participate in the first matchup are automatically compiled and a new battle is
set up. If one or more warriors fail to compile properly, the user is notified
and the battle cannot be started.
The controls at the lower left part of the central area
control the battle and bring up other windows.
·
The Setup button brings up the Settings dialog, which allows the user to set
the various parameters that govern the battles. Note that setting new
parameters aborts the current tournament and sets up a new one.
·
The Options button brings up the Options
dialog, which allows the user to change certain display options. Changing these
options will not interrupt the current tournament.
·
The New Battle button sets up a new tournament: all
warriors are compiled, all Core locations are set to zero instructions (DAT 0,
0) or a custom instruction, the warriors are loaded into Core, and the Start
and Single Step buttons are enabled.
·
The Start button starts or resumes a battle.
·
The Stop button temporarily halts a battle.
·
The Single Step button executes one instruction of
each warrior, and then stops.
·
The View Core button opens a Core
View window that shows a close-up view of the instructions in Core. This
window is non-modal, so that it can remain open while the battle is running,
and the battle controls can still be used. It updates in real time as the
battle progresses. Multiple core views can be opened; a new core view window
opens each time the View Core button is clicked.
·
The View P-space button brings up the P-space View window that shows the contents of P-space
for any warrior. This window is non-modal, so that it can remain open while the
battle is running, and the battle controls can still be used. It updates in
real time as the battle progresses.
·
The Speed slider control, above the buttons, controls
the speed at which warrior instructions are executed. There are seven speed
levels. The slowest three speeds are fixed at 4, 20, and 100 cycles per second.
The speeds of the four highest settings depend on the CPU speed of the computer
running CoreWin, on the warriors involved, and on the display option selected.
For faster speeds, turn off all display graphics by selecting the “None”
display option (see the Options section).
·
For the fastest possible speed, check the Max
checkbox. This sets the speed slider to maximum, turns off all graphics
displays, and disables all breakpoints.
This dialog box allows the user to set the conditions under
which battles are run. Drop-down list boxes provide several pre-defined values
for each parameter, but any number may be typed in instead. Numbers may be
specified using decimal notation (the default) or hexadecimal (a dollar sign
followed by hex digits).

·
Core Size can be fixed, staying the same for each
round, or random, varying between maximum and minimum values.
o
Fixed: Core size can be set to any value from 16 to
134,218,000 (hex $8000000). Note that the core size may be limited by available
memory; each Core location requires 12 bytes of RAM.
o
Random: The first box becomes the maximum size, and
another box appears for the user to type in the minimum size. Note: Warriors
are compiled once for each matchup, using the maximum core size. Therefore,
warrior source code should not refer to the predefined variable CORESIZE when
the core size is set to vary randomly each round.
·
Parameters
o
Max Cycles: the number of instructions each warrior
executes before a battle is declared to be a draw. The maximum number is
$80000000.
o
Max Processes: the maximum number of live processes
each warrior can have. It can be set to any number from 1 to $80000000.
o
Max Length: the maximum number of compiled
instructions a warrior can have.
o
Min Distance: the minimum number of core locations
separating any two warriors when they are initially placed into Core.
o
Read Limit: the maximum distance over which one
instruction may read a value from another memory location. The limit may be
given as a fraction of the core size using the drop-down box, or a numerical
value may be typed in.
o
Write Limit: the maximum distance over which one
instruction may write a value to another memory location. The limit may be
given as a fraction of the core size using the drop-down box, or a numerical
value may be typed in.
o
P-space size: the size of the “personal” or “private”
memory cache for each warrior, accessible using the STP and LDP instruction
codes. The size may be given as a fraction of the core size using the drop-down
box, or a numerical value may be typed in.
·
Warrior Positions
o
At the beginning of each battle, one warrior starts
at location 0. The location of the second warrior may be random, fixed (for the
first round only) at a location typed into the text box at the bottom, or set
to permutate through all possible positions.
o
The seed used to set the Random number generator
(RNG) can be random, a checksum based on the compiled warrior codes of all
warriors, or a fixed number typed into the text box. It is set at the beginning
of each tournament.
·
The Warrior List shows the list of warriors that will
participate in the next tournament. The total number of warriors in the list is
shown to the right of the list box.
o
New: Brings up an empty Edit
Warrior window, where the source code for a new warrior may be typed in.
o
Add: Brings up a file browser, where the user may
select one or more warriors to add. A warrior list file may also be selected,
which will add all the warriors in the list.
o
Remove: Select one or more warriors in the list, then
click Remove to remove them from the list.
o
Remove All: Clears the warrior list.
o
Edit: Brings up the Edit
Warrior window with the selected warrior.
o
Standards: selects which Redcode language standards
will be used when compiling warriors.
o
Sort list: Sorts the warrior list alphabetically.
o
Save list: Saves the warrior list to a text file.
·
Initial Instruction
o
The instruction that fills empty Core at the
beginning of each battle can be set to DAT 0,0 or to
any custom instruction. If Random is selected, each empty location of Core is
set to a random combination of opcodes, modifiers,
modes, and A and B values.
·
Tournament options
o
Melee: All warriors battle simultaneously. For this
tournament type, there is only a single matchup (combination of warriors).
o
Round Robin: Each warrior battles every other
warrior, one on one. There are N*(N-1)/2 matchups, where N is the number of
warriors in the warrior list.
o
Challenge: The warrior selected by the drop-down box
battles each of the other warriors, one on one. When a new warrior is chosen to
be the Challenger, it is moved to the top of the warrior list. There are N-1 matchups.
o
Benchmark: Each warrior in the warrior list battles
each warrior in the benchmark list. The benchmark may consist of one warrior or
a warrior list; selecting the Benchmark radio button brings up a file browser.
There are N*B matchups, where B is the number of
benchmark warriors.
o
“Rounds per matchup” determines how many battles are
fought by each matchup.
o
To have each warrior battle itself during
tournaments, check the Self Fights check box.
o
Tip: Before starting a lengthy Round Robin or
Challenge tournament, select Melee and click OK to close the Settings dialog.
This will compile all warriors, and alert you if any of them fail to compile
successfully. If all warriors compile, you may change the tournament type back
to Round Robin or Challenge and then start the tournament.
·
Save Settings saves the current parameters (including
the settings in the Options dialog box) to a
configuration file. The warrior list is not saved. Settings may be saved either
to the default file, called default.cfg (parameters will be read from this file
the next time CoreWin is started), or to a user-specified file, which may be
loaded at any later time.
·
Load Settings loads all parameters from a
configuration file (either the default file or a user-specified file). If the
default file does not exist, hard-coded defaults will be used.
·
The OK button sets the Core parameters, cancels the
current battle, and sets up a new tournament.
·
The Cancel button keeps the old parameters and does
not disturb the current battle.
This dialog box allows certain options to be set without
interrupting the current tournament.

·
Display Topology may be set to circular (four
rectangular display areas arranged around the outside of the main window) or
rectangular (a single large display area at the top of the window).
·
Cells to Display: This setting determines which
events will cause a cell to be displayed. The core view windows will still
display the Core contents, but the instructions will be warrior-colored only if
the corresponding cell is displayed.
o
None: No updates to the core display are made. This
greatly increases maximum execution speed.
o
Executed only: Cells that are executed by a process
are displayed.
o
Executed and written to: Displays executed cells,
plus cells that are targets of a MOV, ADD, SUB, MUL, DIV, MOD, or LDP instruction.
o
Incremented/decremented: Displays executed and
written cells, plus cells that are incremented or decremented by DJN or any of
the pre-decrement and post-increment address modes.
o
Compared to: Displays executed, written, and
incremented/decremented cells, plus cells that are used in a comparison by JMZ,
JMN, SLT, CMP, SEQ, or SNE.
o
Read from: Displays executed, written, inc/dec, and
compared cells, plus cells that are the source of a MOV, ADD, SUB, MUL, DIV,
MOD, or STP instruction, or that are the intermediate address of an indirect
address calculation.
·
Check for early draws: when checked, a draw will be
declared if every process of every warrior is executing an Imp instruction
(“MOV $0, $1” or “MOV #X, $1”).
·
Pause between rounds: when checked, execution will
pause at the end of each round of a multi-round tournament. Clicking the Start
button will start the next round.
This window allows the user to edit, compile, and save
warrior source code. Source code may be typed in or read from text files. The
window is resizable. Also, each of the four panels may be resized individually
by dragging the splitter bars that separate them.

·
The Open button lets the user browse for a text file
containing warrior source code.
·
The Save button saves the source code into a text
file.
·
The Compile button compiles the source code into MARS
code, and shows the results:
o
Object Code shows the binary compiled code (numbers
shown in hexadecimal)
o
Load File shows the compiled code with readable
opcodes and address modes (numbers shown in decimal). An asterisk (*) marks the
starting instruction.
o
Errors displays any compilation errors
·
Once a warrior has been compiled, the load file may
be saved to a text file. Note: Operands in load files are absolute numbers, and
are independent of the core size at the time of compilation. When warriors are
loaded into Core, operands are adjusted to fit the core size.
·
The OK button returns the source code to the main
window. Note that source code does not need to be compiled before clicking OK.
This is the name that will be used to label this warrior. If
the source code contains a line beginning with ;name, the name is taken from
that line; otherwise, the name of the source file is used. This default name
may be changed.
·
Numbers are decimal integers.
·
Lines beginning with a semicolon are comment lines,
and are ignored. Completely blank lines are also ignored. Some specific comment
lines are recognized by the compiler (all are optional):
o
;redcode – Marks the beginning of source code. All
prior lines are discarded.
o
;name <name> – The name of the warrior.
This is used as a default identifier when warriors are loaded.
o
;author <author’s name> - The name of the
person who created the warrior.
o
;assert <expression>
– The expression is evaluated; if the result is false (0), a warning message is
displayed, but the warrior is not prevented from compiling or battling.
o
;debug, ;trace,
;break, and ;condition are directives that govern breakpoints.
·
Lines containing valid instructions use the following
sequence of elements:
[label]
opcode[.modifier] [a-mode]a-operand, [b-mode]b-operand [;comment]
o
Square brackets denote optional elements. A comma
must separate the two operands. For some opcodes, the comma and b-operand are
optional.
o
Elements may be separated by whitespace (spaces or
tabs).
o
Labels are case sensitive, but opcodes and modifiers
are not.
o
A label is any combination of letters, numbers, and
underscores, beginning with a letter or underscore. When a label is used in an
operand, it represents the number of instructions between the current
instruction and the instruction that begins with that label. For instance, the
two instructions
Dest DAT #0, #Source
Source MOV $Source, $Dest
are equivalent to
DAT #0, #1
MOV $0, $-1
o
A label may appear by itself on a line, in which case
it refers to the next line.
o
An opcode is a three-letter code representing the
action to be performed by the instruction. The set of allowable opcodes depends
on which language standard (ICWS’88 or ICWS’94) is selected on the Settings dialog.
§
’88 opcodes: DAT, MOV, ADD, SUB, JMP, JMZ, JMN, DJN,
CMP, SPL, SLT
§
’94 opcodes:
’88 opcodes, plus MUL, DIV, MOD, SEQ, SNE, NOP, LDP, STP
o
Pseudo-opcodes are compiler directives. They do not
compile into source code, nor do they add to the distance between instructions
during label evaluation.
§
Pseudo opcodes: EQU, END, ORG, FOR, ROF, PIN
o
Modifiers are optional characters that specify which
field (A or B) is the source and which is the target of an instruction
§
’88 standards: No modifiers are allowed. All
instructions have default behaviors.
§
’94 standards: Modifiers may be .A, .B, .AB, .BA, .F,
.X, or .I
o
A mode character indicates the address mode to be
used by the operand that follows it.
§
’88 modes: # (immediate), $ or not specified
(direct), @ (indirect using B-field), or < (pre-decrement indirect using
B-field).
§
’94 modes: ’88 modes, plus > (post-increment
indirect using B-field), * (indirect using A-field), { (pre-decrement indirect
using A-field), or } (post-increment indirect using A-field).
o
An operand is any expression involving integers,
labels, register variables (a-z), parentheses, arithmetic operators (+, -, *,
/, %), comparison operators (==, !=, <, >, <=, =>), and logical
operators (&&, ||, !). It evaluates to an integer (the ‘/’ operator
uses integer division). Comparison and logical operators return 1 for true and
0 for false. Operands may contain whitespace. The following predefined
variables may be used to refer to the current parameters:
§
CORESIZE
§
MAXPROCESSES
§
MAXCYCLES
§
MAXLENGTH
§
MINDISTANCE
§
ROUNDS
§
PSPACESIZE
§
WARRIORS (the number of warriors participating in
each battle)
§
CURLINE (the current line in the compiled warrior,
starting with 0)
§
RANDOM (a random integer in the range 0..CORESIZE-1)
§
VERSION (the version number of CoreWin, times 100)
A breakpoint may be set at any location in core. It consists
of a set of conditions; when those conditions are satisfied on that line,
execution will be halted. The following conditions may be specified:
Breakpoints can be set in source code using four compiler
directives:
Breakpoints can also be set at runtime, from any Core View window, by clicking on the location number to
the left of an instruction.
Each unique set of conditions defines a breakpoint type.
There are two predefined types: Type 1 halts on Execute, is fixed, and has
frequency 1 (E F 1). Type 2 is the same, but movable (E M 1). These two types
may be set by a single mouse click in a Core View window. Any breakpoint defined
at compile time, or using the Edit Breakpoint
window, is given a custom type, greater than 2. The breakpoint type is shown in
the Breakpoints dialog box. All breakpoints that are identical (created using
the ;trace compile directive, or using the Fill Next option in the Edit
Breakpoint window, or copied from a movable breakpoint) share the same type.
The total number of different breakpoint types may not exceed 255.
This window shows the results of the current tournament. If
the tournament has not yet completed, partial results are shown. Two separate
pages, Summary and Details, show the total results for all warriors and the
results for each individual warrior, respectively. This window is resizable, as
are each of the columns.

A warrior that dies during a battle receives a score of
zero. Each survivor receives a score determined by the score formula. The
default formula is (W*W – 1)/S, where W is the total number of warriors per
matchup, and S is the number of surviving warriors. When W=2 (one-on-one
battles), the score is 1 for a tie and 3 for a win. The score formula may be
changed by clicking the Change button and entering a new expression, using the
variables W (or w) and S (or s), plus any of the predefined variables
(CORESIZE, etc).
This page shows the total results for each warrior in the tournament. For the Challenge tournament type, only the results for the challenging warrior are shown here. The Show Details button brings up the Tournament Details page (Challenge, Round Robin, and Benchmark only).
This page shows how each of the opponents of a single warrior performed against it. For the Challenge tournament type, the table shows the results of each challenged warrior against the challenger. For Round Robin and Benchmark, the table shows the results of each opponent of the warrior selected in the drop-down box. The Show Summary button brings back the Summary page.
Click the Save button to store the results of the tournament to a text file.
This window shows a detailed view of the instructions within
the Core. The view shows a block of instructions, color-coded by the warriors
that executed, modified, or otherwise affected the instructions. An instruction
in red is about to be executed. Empty core, or any instruction at a location
that is not displayed in the graphics area, is colored dark gray. The window is
non-modal, so it may remain open while a battle is in progress, and the
controls on the main window may be used. The view updates in real-time as the
battle progresses. A new core view is opened each time the View Core button on
the main window is clicked. The view may be resized vertically, but not
horizontally.
Instructions that have breakpoints set are shown with a
symbol to the left of the line. Normally, the symbols are green, but a
breakpoint that has caused execution to halt is colored red. Squares mark type
1 breakpoints (E F 1), circles are type 2 (E M 1), and diamonds are type 3 or
greater (custom breakpoints).

·
The Line and Page spin controls move the view through
Core by 1 line and 1 page per click, respectively.
·
To move the view to a new location, type a number
(decimal or $hex) into the Location box and press the TAB key to execute the
move.
·
The Processes button brings up the Processes dialog box.
·
The Breakpoints button brings up the Breakpoints dialog box.
·
A mouse click on the location number of an
instruction line (to the left of the opcode) toggles among three breakpoint
types: Type 1 (fixed), Type 2 (movable), and back to Type 0 (no breakpoint). If
a breakpoint is not one of these three types, a click has no effect.
·
A double click on the location number of an
instruction line brings up the Edit Breakpoint dialog
box, allowing a custom set of conditions to be set for that instruction.
·
A double click on the right part of an instruction
line (starting at the opcode) brings up the Edit Core
dialog box, allowing that instruction to be changed.
·
A right click on either of the operands (either A or
B) brings up a popup menu showing the absolute address of the operand. If the
operand uses an indirect address mode, both the intermediate address (“$X”) and
the final address (“<X”) is shown. Clicking on either of the addresses in
the popup will open a new Core View window at that location.
·
The range of cells shown in each Core View window is
marked with a red underline in the Core display. A click anywhere in the Core
display will move the topmost Core View window to that location.
This dialog box shows the core location, and the instruction
at that location, of each process of the warrior selected in the drop-down box.
The first process in the list is the one that will be executed next. The process
queue may be edited by using the buttons to the right of the process list.

·
Add: Brings up a location dialog box. Type in a
location at which to begin a new process, then click OK. The new process is
queued immediately after the selected process.
·
Delete: Removes the selected process from the process
queue.
·
Edit: Brings up a location dialog box. Type in a new
location for the selected process, then click OK.
·
Move Up: Moves the selected process ahead of the
prior process in the process queue.
·
Move Down: Moves the selected process behind the next
process in the process queue.
·
Roll to Top: Makes the selected process the next one
to be executed (at the top of the queue). All other processes are moved by the
same amount, so that the relative order of the processes is unchanged.
·
If the Close and Move button is clicked, the dialog
box closes and the Core View window moves to the location of the selected
process.
·
If the Close button is clicked, the dialog box closes
and the Core View location does not change.

·
Add: Brings up a location dialog box. Type in a
location at which to set a new breakpoint, then click OK. The Edit
Breakpoint dialog box appears, in which the breakpoint
conditions may be specified.
·
Edit: Brings up Edit Breakpoint dialog box, in which
new breakpoint conditions may be specified.
·
Clear: Clears the selected breakpoint.
·
Clear All: Clears all breakpoints.
·
If the Close and Move button is clicked, the dialog
box closes and the Core View window moves to the location of the selected
breakpoint.
·
If the Close button is clicked, the dialog box closes
and the Core View location does not change.
This
dialog box sets the conditions that will cause a breakpoint to halt execution.
You may choose any set of the “Break on” events. If the Test event is checked,
a valid Redcode expression (see the last paragraph in the Edit Warrior section)
must be typed into the box below. Aside from the predefined variables such as
CORESIZE, the only labels that may be used in the expression are A (or a) and B
(or b), representing the values of the A and B operands, respectively.
The number
in the Frequency box is how many times the selected event(s) must occur before
execution is halted.
If the
Movable box is checked, the breakpoint is movable, and may be copied to a new
location by a MOV.I instruction; otherwise, it is fixed.
The number
in the Fill Next box is how many instructions will be set with this breakpoint.


This window shows the contents of P-space for the selected
warrior. The view shows a block of locations, in the color of the warrior to
whom it belongs. The window is non-modal, so it may remain open while a battle
is in progress, and the controls on the main window may be used. The view
updates in real-time as the battle progresses. The view may be resized
vertically, but not horizontally.

·
The Line and Page spin controls move the view through
P-space by 1 line and 1 page per click, respectively.
·
The user may type a number (decimal or $hex) into the
Location box to move the view to that location. Press the tab key after
entering the number to execute the move.
·
A double-click over any P-space location brings up
the Edit P-space dialog box, allowing the value at
that location to be changed.
This dialog box allows the P-space value at a P-space
location, for a particular warrior, to be changed. The Fill next number
specifies how many consecutive P-space locations will be filled with the new
value. The “read only” value at location 0 may also be changed.
