From: houk@athena.cs.uga.edu (Joshua Houk)
Newsgroups: rec.games.corewar
Subject: Beginning at Corewar...
Date: 28 Sep 92 03:44:24 GMT
Organization: University of Georgia, Athens

I figured this might make for interesting reading (as well as a few good
hearty laughs, but hey...why not?). This'll basically overview what
I've done with corewar so far. It ain't much - but this might help out
some beginners (hey, a guy can wish, can't he?). 

Also, if more experienced programmers (i.e. everybody) have any comments,
suggestions, tips, etc - I'm always searching for ways to improve.
Posting or email will be swell...!

I got caught up in corewar about a month ago. I ftp'd a swell Unix C
program - the very nice Deluxe (curses) one -
and experimented with your basic programs. That was
fun for a couple of days, but then the urge to write something of
my own overwhelmed me. So, I did. Unfortunately, I hadn't grasped
the basics at all.

The first program that I wrote was Prime-Imp. Theoretically, it was supposed
to move one space, jump over a space, jump over another one, etc. - so that
the cells written for the first pass would go to cells 1, 3, 5, 7, 11, and
13. Then, the program would go back to cell 2, and repeat the sequence,
thereby clearing out a nice path.

In real-life, well...here's the code - get ready to break down in guffaws
of laughter...

==========
;redcode verbose
;name Prime-Imp v1.0
;author Joshua Houk
;strategy    Moves forward in a scattershot fashion, then backtracks to
;strategy    one cell after the previous start point and repeats.
;strategy    Hopefully, this will provide some sort of defense.
;strategy    Revision of imp.

start  mov 0 , 1
mov  0 , 2
mov  0 , 2
mov  0 , 4
mov  0 , -9
jmp start
==========

Not only could I not add that day (it looks like I intended a 1,3,5,9 - not
a 2,3,5,7,11) - but, yep - the code just might be the silliest program
ever written. Needless to say, this just copies "mov 0,1" over and over.
It's a plain imp. The next one is even more embarrassing...

==========
;redcode verbose
;name Prime-Imp v2.0
;author Joshua Houk
;strategy | Moves forward in a scattershot fashion, then backtracks to
;    one cell after the previous start point, then steamrolls
;    through the path to every address. This should prove to be
;    a more offensive version (and let's just see how many people
;    I can offend :).
;    Revision of imp, so obviously I can't take all credit.

start  mov 0 , 1
mov  0 , 2
mov  0 , 2
mov  0 , 4
mov  0 , -9
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , -10
jmp start
==========

The idea was to skip a few cells, return to the start, and clear out
everything, then jump back and repeat the process, inching forward slowly.
Of course, it did the exact same thing as the first one.

I thought I figured out where I was messing up, and returned by developing
what amounted to be an impgun. Of course, that wasn't my intention
again...

==========
;redcode-x verbose
;name Breadman 1.0
;author Joshua Houk
;strategy : Hops and skips forward a few cells, then jumps back and cuts a
;strategy   swath through - clearing everything out. Then splits and
;strategy   repeats continuously, while simulaneously moving foward.
;strategy   Based on a modification of my previous two programs, and
;strategy   fares a *whole* lot better than the earlier generation
;strategy   Prime-imps.

gun  spl start
jmp gun
start  mov 0 , 1
mov  0 , 2
mov  0 , 2
mov  0 , 4
mov  0 , -9
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , 1
mov  0 , -10
jmp start
end gun
===========

Okay - maybe I didn't learn...er...  It would figure that this program has
been the only program that I've submitted to the Hill that actually
made it (#20 on X-hill, with two decisive wins over I'll Be Back (42-1)
and Rolling Thunder (37-7)). And I can't even take credit for it!

After varying Breadman a little bit and having absolutely no idea what I
was doing, I grew disenchanted, and threw everything down for a couple weeks.
During that time, I cleared my mind (and saw the amazing band Pavement)
and soon I was ready to pick up corewar again - this time reading and
trying to comprehend redcode before writing anything new. It just might
have worked. 

The first new program to come out was Trigger Cut.

==========
;redcode verbose
;name Trigger Cut v1.0
;author Joshua Houk
;strategy  Bombs galore, with two seperate addressing systems.

start mov b , @a
      add a , b
      mov @a , a
      mov d , @c
      add c , d
      mov @c , c
      jmp start
a     dat #7
b     dat #15
c     dat #5
d     dat #11
      end start
==========

This is a variation of the mortar program, except that it tosses out a
second, separate bomber before jmp-ing back. This covers ground not bombed
by the first bomber, plus saves one task, to boot, by not waiting for the
JMP instruction. Not too shabby, but didn't do great on the hill...

I fooled around with this for awhile. The most successful variant expanded
on this (with mov b , @a ... mov d , @c ... mov d , @a ... mov c , @b),
changed the addressing to something safer for the main program, and
included a SPL(0) instruction.

After beating that horse to death, I started work on a mice variant,
probably since that program was killing me all the time.

==========
;redcode-x verbose
;name Comets Are The Chances In Our Future v2.0
;author Joshua Houk
;strategy  Replicator (sigh) that replicates a lot. Based on Mice, but
;strategy  includes more SPL instructions and tighter addressing.
;strategy  v2.0 - Sends off imps every so often, too.

bomb	dat #0 , #0
start   mov #12 , bomb
loop    mov @bomb , <branch
        djn loop , bomb
        spl @branch , 0
	spl @start , 0
	spl @imp , 0
        add #525 , branch
        jmz start , bomb
branch  dat #0 , #615
imp     mov 0,1
	dat #0,#0
        end start
===========

The first program of mine that could even be remotely called original in
any way - and even then it's not totally original - but original enough
by corewar standards (I think - tell me if I'm wrong...). This copies
itself, then shoots an imp, making it harder to kill - and it's not too
shabby offensively, either.

Then, I figured since I'm bastardizing every other program, why not my own?
Henceforth - Trigger Comet and Comet Trigger, differing only (at first)
with execution order. Trigger Comet flopped. Comet Trigger I'm currently
fine-tuning and doing some neat stuff with, so I won't post the code now,
just the strategy...

==========
;redcode verbose
;name Comet Trigger v3.1
;author Joshua Houk
;strategy  Melding of my Trigger Cut and Comets... programs.
;strategy  Main loop is a increased SPL instruction mice variant.
;strategy  Offshoot program is a multi-address bomber. (22 Sep 92)
;strategy  v2.0 - Adds imp stomper. Fares nicely... (26 Sep 92)
;strategy  v3.0 - Thwarts replicators by sending out imps. (27 Sep 92)
;strategy  v3.1 - Shortens the program a *lot*. Almost in half. ("")
===========

I will post the code shortly, maybe. Anyhow, there should be enough info
here for a good grasp of what it does. This version now beats xtc about
4 out of ten times. Xtc wins the other six, but previous incarnations
of C-T never came close to stomping the bugger :). This means I'm going
to have to adjust my mini-hill a bit (made mostly of "classic" programs),
but if I'm improving, I don't mind...!

The moral? If you get discouarged, take some time out, read up, and
examine other programs closely to see what they do.

Once again - any comments/suggestions are appreciated!

-- 
Joshua "Throwing the election" Houk || houk@athena.cs.uga.edu
[Co-moderator of the Indie-List - email for info!]
"Throw your arms around the scene, hold it close at the slightest suggestion."
   - Synthetic Flying Machine