[Core War]

Philip Kendall - How to submit a warrior

This page is a quick guide as to how to write a warrior and submit it to one of the ongoing Corewar tournaments; it assumes you already have pMARS, and know a little about how Redcode works; if you don't, see the Getting Started page.

The first thing to know about warriors is that they are simply plain text files. They are traditionally given the extension '.red', but this is not essential; it just makes them easier to find! For this example, we'll take a very simple warrior: Imp, as appeared in the original Core War articles written in Scientific American by A.K. Dewdney. The actual functional part of Imp is just:

   imp       mov.i   0,1

This just takes the current instruction (0) and copies it to the next instruction (1), then increments the program counter to point to the next instruction, where the whole cycle begins again, leaving a trail of mov.i 0,1 instructions behind.

The first thing you have to do is to fire up your favourite text editor, and type in the line given above. All modern Redcode implementations are pretty free-form, so you don't need to worry too much about where you put tabs, spaces and the like; everyone has their own personal style on this, but most people at least line up all the labels (the 'imp' bit), the instructions (the 'mov.i' bit) and the arguments (the '0,1' bit). Don't worry about the case of your instructions either: 'mov.i', 'MOV.I' or even 'mOv.I' will work; again, people have their own preferences here.

Now save the file to 'imp.red' in the same directory as you've got pMARS (if you're using something like Microsoft Word, make sure you save in a plain text format (.txt), rather than as a Word document. Note that the Microsoft applications generally won't let you save it as a 'imp.red', but will insist on calling it 'imp.red.txt'; as mentioned above, this doesn't matter in the slightest, apart from it does take longer to type :-)).

Now start up a command prompt and change to the directory where you placed pMARS and 'imp.red', and type in the following command:

   C:rewar>pmars imp.red

This should give the following output:

           Missing ';assert'. Warrior may not work with the current setting

   Source: filename 'imp.red'
   Number of warnings: 1

   Program "Unknown" (length 1) by "Anonymous"

          ORG      START
   START  MOV.I  $     0, $     1

   Unknown by Anonymous scores 0

If it doesn't, something's gone wrong! Check you've typed the commands in correctly and have another go. Don't worry about the warning at the moment: I'll explain about this further down.

Whilst this warrior compiles and runs, you can't submit it to one of the Core War tournaments in this form. You need to put some special lines into your warrior so it can be recognised by the machines running the tournaments; edit your warrior, and place the following lines at the start of the file:

   ;name Imp
   ;author [your name]
   ;strategy Simple imp
   ;assert CORESIZE==8000

A semi-colon means that the rest of the line is a comment; therefore these lines won't affect how your warrior fights, but identify it in various ways. To take each of these in turn:

Now edit the file again, and place

             end     imp

at the end of the file. The 'end' directive tells pMARS to stop processing here, and that execution of the warrior should begin at the instruction labelled 'imp'. (This is optional: if you don't give an 'end' directive, or don't give a starting place, execution will begin at the first instruction).

Your warrior should now look something like this, allowing for some changes in the spacing and the like:

   ;name Imp
   ;author [your name]
   ;strategy Simple imp
   ;assert CORESIZE==8000

   imp       mov.i   0,1

             end     imp

If it does, save it again. If it doesn't, edit it until it does :-). Running pMARS on this file should produce the following output:

   Program "Imp" (length 1) by "[your name]"

          ORG      START
   START  MOV.I  $     0, $     1

   Imp by [your name] scores 0

If it does, congratulations! You're now ready to submit your warrior to one of the on-line tournaments. Start up your favourite e-mail program, and start a message to pizza@ecst.csuchico.edu, with a subject line of 'koth'. (This is the 'Pizza' Core War Server; koth stands for King Of The Hill). Now either copy and paste your entire warrior into the mail, or insert the 'imp.red' file. (If you insert the file, ensure it is as plain text, and is not MIME or uuencoded; also turn off sending HTML mail, as this will only confuse the server). Not long after you've sent this mail, you should get back a confirmation message, looking something like:

   Your corewar program has compiled successfully and will be entered into the
   Beginner's tournament.

   Your program is currently the only one waiting to run.

   Below is a complete listing of your program after assembly.

   Program "Imp" (length 1) by "[your name]"

          ORG      START
   START  MOV.I  $     0, $     1

This may look slightly different depending on how many people are currently waiting to challenge the various Hills hosted at Pizza, but the important thing is the "compiled successfully" bit. A while after this, depending on how many people are ahead of you in the queue, and how what else is running on the server, which does have things to do other than let us play Core War, you should get back some challenge results, which will look something like:

   Program "Imp" (length 1) by "[your name]"
   (contact address "[your e-mail address]"):
   has challenged the Beginner hill.
   Program "Nuke it!" (length 90) by "Silvio Sampietro"
   (contact address "[Silvio's e-mail address]"):
   Imp wins: 0
   Nuke it! wins: 5
   Ties: 195

   [Something like the above for all 25 warriors on the Hill]
   Your overall score: 50.480000 (Placing 20th)
   A man with a Gun has been pushed off the Beginner hill.
   The current Beginner hill:
    #   %W /  %L /  %T                       Name               Author Score  Age
    1  47.7/ 37.1/ 15.2                  Nuke it!     Silvio Sampietro 158.4    4
    2  45.5/ 33.7/ 20.9           Spat the dummy. Steve Gunnell (oh ye 157.2   95
    3  36.2/ 19.2/ 44.6             Quickest Zeta    Leonardo Humberto 153.2    7
    4  37.4/ 30.4/ 32.2          Silken Half Life            Dale Neal 144.4   15
    5  36.6/ 30.3/ 33.1     Silken Half Life v4.0            Dale Neal 143.0   12
    6  31.2/ 20.1/ 48.7              Quicker Zeta    Leonardo Humberto 142.4   29
    7  40.5/ 40.0/ 19.5          Nuke it! (V 0.2)     Silvio Sampietro 141.1   11
    8  28.9/ 17.2/ 53.9                Redemption         John Metcalf 140.5   71
    9  35.2/ 30.4/ 34.4     Silken Half Life v3.0            Dale Neal 140.0   13
   10  35.8/ 37.8/ 26.5          No Time To Think         A. S. Mehlos 133.8   96
   11  26.1/ 21.8/ 52.1                Quick Zeta    Leonardo Humberto 130.5   34
   12  30.9/ 32.3/ 36.8           Frusteration II         A. S. Mehlos 129.6   99
   13  33.9/ 41.8/ 24.3               Fire Master             P_.V_.K. 126.0   19
   14  22.2/ 19.5/ 58.2                  H-Bomb 9          Josh Yeager 124.9   93
   15  24.0/ 25.0/ 50.9            HardCore v0.2b           Simon Duff 123.0   35
   16  33.1/ 45.0/ 21.9 Death kiss with a dash of      Anders Rosendal 121.2   55
   17  26.4/ 31.8/ 41.8            quatrefoil 133        Steve Gunnell 121.0    5
   18  29.5/ 41.9/ 28.7                  Red Sand          Ken Hubbard 117.1   18
   19  20.8/ 68.7/ 10.5  death by dangerous ;kill     Simon Wainwright  72.9    2
   20   0.6/ 50.7/ 48.7                       Imp          [your name]  50.5    1
   21   7.7/  0.2/  0.1    of mirth and merriment     Simon Wainwright  23.3   41
   22   4.3/  0.8/  2.9              The Outsider     Simon Wainwright  15.8    3
   23   4.0/  1.5/  2.5          death by redcode     Simon Wainwright  14.6    8
   24   2.8/  1.6/  3.6        redcode ragamuffin     Simon Wainwright  12.1   23
   25   4.0/  0.0/  0.0            Pattel's Virus             Ben Ford  12.0   37
   26   1.7/  0.0/  2.3          A man with a Gun             Ben Ford   7.5   80
   Top 25 Averages:
       25.8/ 27.1/ 28.5                                                105.9   33

Obviously, as we came 20th out of 26 warriors, this wasn't a very successful challenge, but this is all we can really expect from such a simple warrior. Also, all the warriors below us have been removed from the Hill by their owners (which is why their won/lost/tied percentages don't add up to 100%) so, in many senses, we came bottom... However, you have now challenged the Hill! Congratulations!

I hope this document was of some help for teaching newcomers to Core War how to submit warriors; if you have any comments, suggestions or the like (especially if you have just followed this through), please mail me.

Valid XHTML 1.0! Valid CSS!