Setting up a Corewar Environment
For best results when playing around with Corewar one needs to be
able to easily edit, run and debug warriors, observe the action when
battling warriors against each other, and benchmark warriors against
various test sets. It takes a fair amount of custom scripting to set up
environment, one way around the programming effort is to use an
integrated environment such as CoreWin where warriors can
be run, examined, and tested using a GUI. Myself, I'd be lost if I
couldn't just right-click a warrior and do stuff with it. My context
menus usually have options to edit, run in pmarsv, and benchmark using
various test sets, all repeated for coresizes 80, 800 and 8000.
If going the right-click way, first step is get a handle on file
associations. Make a type for Redcode and associate *.red, *.war and
*.rc files to it, then various tools and scripts can be associated. For
Windows and the Linux KDE GUI this is easy. If using Windows make sure
you set the system to display file extensions or you'll have a heck of
a time trying to do anything with files, un-dummify the system. The
Linux Gnome GUI needs a bit of help as it tends to ignore file
extensions (nice try but sorry extensions matter, otherwise every app
that uses text files ends up in the same right-click menu), fortunately
ROX Mime Editor permits creating custom file types based on extension
(and content too if you want), once the file type is created apps can
be easily added and removed using the normal Gnome GUI.
If you know what "on the path" means and already have such a
directory for such purposes then skip the next two paragraphs, this is
for folks new to the concept. Often many different tools and scripts
are needed and it's nice to not have to specify the full location
everytime they're run, for example evolvers usually just specify
"pmars" instead of trying to guess where you put it. In Windows, tools
can be put in the same directory as the app that uses them but this
leads to a lot of duplication, to avoid docs often say to "put in a
path directory". This means a directory where the path does not have to
be specified. C:\Windows\System32 is (usually) an example of a path
directory but you probably don't want to put corewar tools there
amongst a zillion system files, so make your own path directory. The
following instructions are for Windows XP SP3, other versions might be
different. Be extremely careful when adjusting the system internals,
one slip and poof (and I'm not responsible for any damage you do, if
you have any doubts cancel immediately and seek instructions
Run Windows Explorer and make a directory named say "mypath" in the
root of the C: drive (change "mypath" in these examples to whatever you
want to call it but don't use spaces in the name). Or open up a command
prompt and type
"md c:\mypath" (without the quotes). Now to add to the path variable.
Go to control panel (classic view) and run the System applet, click
Advanced, click Environment Variables, highlight the path variable,
click edit, *press the right-arrow key* to clear the highlight and
*without disturbing the existing text* add ;c:\mypath (make sure to add
the semicolon to separate from the other path directories) and click
OK, OK, OK and close the control panel. Now anything put in C:\mypath
can be run without specifying the directory.
With a path directory in place now qbasic.exe, blassic.exe,
gwbasic.exe, pmars-server renamed to pmars.exe, pmarsw.exe and its DLL,
various batch files for testing warriors etc can all go
in the [my]path (or whatever it's named) directory.
Linux already has a path directory for user programs -
/usr/local/bin - just copy the (Linux versions of the) binaries and
scripts there, you have to be root but most distros have an option to
run a file manager as root. Some distros have a local/bin or similar
directory under the home directory for path things without having to be
Ok, got associations, got path, now can set things up. Oops...
didn't cover Windows associations but it's easy, if you haven't done so
already find the Folder Options, make sure it's set to not hide
extensions, click File Types and add a type for (say) "Redcode" and add
the extensions *.red *.war and *.rc, pick an icon and add Notepad
(Wordpad might work better, doesn't mind unix-format files but make
sure it saves as plain text). Now to make other tools. When saving
batch files from Notepad and maybe other Windows editors, put quotes
around the filename so it doesn't automatically add a ".txt" extension.
When creating new files in Windows Explorer and
renaming to ".bat" if doing it that way it is necessary that Windows is
set to not hide the extension or it'll look like it has the right name
but still has a hidden .txt extension, that won't work.
To visually run warriors in pmarsv, go to your path directory and
make 3 batch files, say "pmv80.bat", "pmv800.bat" and "pmv8000.bat".
The following assume the pmarsv program is named "pmarsw.exe", the
common SDL version. Adjust the batch files
as needed, they can be named anything as long as they end in .bat and
probably shouldn't be too long or contain spaces in the name (when
spaces are used in a batch filename then everything calling it must
always quote the filename to permit passing parameters, sometimes
that's inconvenient so it's common practice to avoid spaces, use _
"pmv80.bat" should contain something like...
pmarsw -v 664 -l 5 -d 5 -s 80 -p 80 -c 800 %1 %2 %3 %4 %5 %6 %7 %8 %9
if not .%2==. pause
The numbers after -v control the graphics, the 1st digit is speed,
2nd digit is graphics mode and the 3rd digit is detail level (usually
4). Experiment with the first 2 digits. The remaining parameters
specify max length 5, min distance 5, size 80, 80 processes, 800 cycles
followed by up to 9 parameters for specifying warrior names. The if and
pause at the end pauses to see the scores if more than one warrior is
run at once.
"pmv800.bat" should contain something like...
pmarsw -v 414 -l 20 -d 20 -s 800 -p 800 -c 8000 %1 %2 %3 %4 %5 %6 %7 %8 %9
if not .%2==. pause
"pmv8000.bat" should contain something like...
pmarsw -v 114 -l 100 -d 100 -s 8000 -p 8000 -c 80000 %1 %2 %3 %4 %5 %6 %7 %8 %9
if not .%2==. pause
Now go back to the File Types dialog under Redcode and add these to
the app list (typically keep the editor as the default app). Since
they're in a path directory for the commands only need to say
pmv80.bat, pmv800.bat and pmv8000.bat (the .bat is probably optional
but good practice to specify). If done right you should be able to
right-click a warrior file (which should now all have the icon you
selected for warriors) and select open with and pick the core size to
run it in.
This ends Windows batch file associations 101 - from now on I'll be
more terse. I use many other batch files but some of the handiest are
for benchmarking individual warriors using variations of this test800b batch - make copies of it like
test80bm.bat (nanobm07), test800h.bat (Franz), test800b.bat (tinybm04),
testwilk.bat (Wilkies), testmoo.bat (Wilmoo), testfiz.bat (WilFiz), etc
all edited for various coresizes, rounds and benchmark sets. Some bench
sets are too big to display in one screen, can add "mode con lines=50"
(without the quotes) to the batches (near where it sets the other vars
is fine) or add notepad etc to the list setting. The location of the
benchmark set and the pmars command line has to be precisely edited for
each batch. Various benchmark sets for various coresizes are at http://corewar.co.uk/ under
benchmarks, also look under Misc for alternate benchmarking programs
but not sure if any can be associated, in the old days this stuff was
done from a command line.
For Linux the process is similar for running pmarsv but it has to be
run in a terminal such as xterm to permit entering the debugger, and
Linux doesn't support passing multiple names from the GUI (but in Gnome
a script placed in the Scripts directory can, so that's where I put my
scripts for battling warriors against each other). I ended up having
variations that include a read command to pause to see the scores when
battling warriors, actually need to redo it all but once something
works good enough I tend to leave it alone. I still use many of my old
batch files from my Linux GUI's (Gnome on Ubuntu, KDE on the Asus'
Xandros) using DosEmu/FreeDos. I documented my Asus setup in the eeecw.txt file, my Ubuntu setup is similar.
Last updated 6/23/09
Terry Newton (email@example.com)