Sections
Home
Hills
Infinite Hills
Tournaments
Software
Evolving
Optimizer
Community
Newsletter
Discussion
History
Sections
 
For Beginners
First Steps
FAQ
Guides
Lexicon
Benchmarks
For Beginners
> Home > The Corewar Newsletters > Core Warrior > Issue #1

Issue 68                                                        9 June, 1998
_______________________________________________________________________________
Core Warrior is a newsletter promoting the game of corewar. Emphasis is placed
on the most active hills--currently the '94 draft hill and the beginner hill.
Coverage will follow where ever the action is.  If you have no clue what I'm
talking about then check out these five-star internet locals for more
information:

FAQs are available from:
ftp://rtfm.mit.edu/pub/usenet/news.answers/games/corewar-faq.Z
http://www.koth.org/corewar-faq.html

FTP site is: ftp://ftp.csua.berkeley.edu/pub/corewar
Mirrored at: ftp://ftp.inria.fr/INRIA/Projects/para/doligez/cw/mirror
        and: ftp://www.koth.org/corewar

pMARS itself is also available from:
Stormking web pages--http://www.koth.org/pmars.html
Terry's web page--http://www.ncs.infi.net/~wtnewton/corewar/
Fechter ftp site--ftp://members.aol.com/ofechner/corewar

Web pages are at:
http://www.koth.org/                            ;Stormking
http://www.ecst.csuchico.edu/~pizza/koth        ;Pizza
http://pauillac.inria.fr/~doligez/corewar/      ;Planar

Newbies should check the stormking page for the FAQ, language specification,
guides, and tutorials.  Post questions to rec.games.corewar.  All new players
are infinitely welcome!

A collection of Bezzi's hints in the first issues is available at:
ftp://ftp.volftp.vol.it/pub/pc/msdos/games/solutions/bbhints.zip
_______________________________________________________________________________
Welcome back.

In this issue, you can find a summary of my exploits in Ilmari Karonen's recent
Tournament, and how I went about writing the warriors I used in that
Tournament, as well as David Moore's once-almost-unkillable `The Fugitive'.

-- Philip Kendall
_______________________________________________________________________________
Current Status of the Internet Pizza Server ICWS '94 Draft Hill:

Hill Specs:
         coresize: 8000
   max. processes: 8000
         duration: after 80,000 cycles, a tie is declared.
max. entry length: 100
 minimum distance: 100
    rounds fought: 200
  instruction set: ICWS '94 Draft

 #   %W /  %L /  %T                       Name               Author Score  Age
 1  39.4/ 37.0/ 23.7           Recycled Bits++          David Moore 141.8    3
 2  34.2/ 28.0/ 37.8                      Vain          Ian Oversby 140.4   80
 3  35.2/ 30.6/ 34.2                     Fixed         Ken Espiritu 139.8   64
 4  34.4/ 30.0/ 35.5                     Vigor         Ken Espiritu 138.9   68
 5  33.1/ 28.4/ 38.5                    Shadow    Christian Schmidt 137.9    4
 6  31.4/ 25.0/ 43.7             Ultraviolet-B         Ken Espiritu 137.7   90
 7  31.1/ 26.6/ 42.3                      Newt          Ian Oversby 135.7  158
 8  31.3/ 27.5/ 41.2         Tuesday Afternoon             John K W 135.1    8
 9  34.5/ 34.7/ 30.7                     Shape    Christian Schmidt 134.4    5
10  40.3/ 46.4/ 13.3                   Silccon        M. J. Pihlaja 134.2   22
11  34.0/ 33.9/ 32.1              Fire and Ice          David Moore 134.1   53
12  36.2/ 38.6/ 25.2            The Body Guard          Ian Oversby 133.9    7
13  36.3/ 38.7/ 25.1 He Scans a Little Crooked              P.Kline 133.9    0
14  35.7/ 37.9/ 26.4              Floody River              P.Kline 133.6    1
15  32.7/ 32.1/ 35.2                     Alien    Christian Schmidt 133.3   13
16  32.0/ 32.6/ 35.4                 Pulp v0.4          Ian Oversby 131.5    2
17  37.4/ 43.5/ 19.1                 Blurstone        M. J. Pihlaja 131.3    4
18  25.1/ 19.2/ 55.7                  Fugitive          David Moore 130.9   34
19  35.1/ 39.5/ 25.4                    BiShot    Christian Schmidt 130.8   24
20  35.8/ 41.3/ 22.9                    Eraser         Ken Espiritu 130.4    5
21  33.7/ 37.2/ 29.1               Digitalis 4    Christian Schmidt 130.2   52
22  36.2/ 43.0/ 20.7           Electric Head 2        Anton Marsden 129.4    8
23  24.0/ 19.6/ 56.4 Return Of Return Of The J             John K W 128.5   30
24  27.9/ 28.6/ 43.5              Gemini Dream     John K Wilkinson 127.3    9
25  30.0/ 34.2/ 35.8 obvious to those who know        Robert Macrae 125.8  116

Age since last issue: 7 ( 34 last issue, 11 the issue before )
New warriors: 9  Turnover/age rate 129%
Average age: 34 ( 32 last issue, 34 the issue before )
Average score: 134 ( 133 last issue, 135 the issue before )
The top 25 warriors are represented by just 9 independent authors: Schmidt with
5, Oversby and Espiritu with 4, Wilkinson and Moore with 3, Pihlaja and Kline
with 2, and Marsden and Macrae with one each.

It was a battle of the papers at the beginning, before David Moore hit the top
again with Recycled Bits++
_______________________________________________________________________________
94 - What's New

 #   %W /  %L /  %T                       Name               Author Score  Age
 8  37.8/ 38.3/ 23.9            The Body Guard          Ian Oversby 137.2    0
19  35.5/ 40.9/ 23.6                    Eraser         Ken Espiritu 130.2    0
 5  35.7/ 34.2/ 30.1                     Shape    Christian Schmidt 137.1    0
10  38.8/ 42.9/ 18.3                 Blurstone        M. J. Pihlaja 134.8    0
 4  33.3/ 28.3/ 38.4                    Shadow    Christian Schmidt 138.3    0
 1  40.7/ 35.7/ 23.6           Recycled Bits++          David Moore 145.7    1
18  30.9/ 31.3/ 37.7                 Pulp v0.4          Ian Oversby 130.5    1
 8  36.4/ 37.5/ 26.1              Floody River              P.Kline 135.2    1
13  36.3/ 38.7/ 25.1 He Scans a Little Crooked              P.Kline 133.9    0

David Moore is back with his new pspacer to regain the KotH spot.
_______________________________________________________________________________
94 - What's No More

 #   %W /  %L /  %T                       Name               Author Score  Age
26   1.3/  1.4/  1.3            The Body Guard          Ian Oversby   5.2   14
26   1.7/  1.8/  0.4                  hTest 80              P.Kline   5.6    0
26  30.1/ 38.2/ 31.7                     Vixen          Robert Hale 122.0    2
26  33.7/ 44.8/ 21.5               One or Zero            Sayembara 122.5    5
26   1.5/  2.0/  0.6            Scanitator Pro    Christian Schmidt   5.0    3
26  30.7/ 37.4/ 31.9                 Tornado 4          Beppe Bezzi 124.1   78
26   1.3/  1.6/  1.1                    Sphere    Christian Schmidt   5.1    9
26  27.2/ 29.7/ 43.1                Indecisive          Robert Hale 124.6   12
26  34.7/ 44.0/ 21.3      )(( Ca*mou*flage ))(            Sayembara 125.3   14

The only significant loss here is Beppe's Tornado 4.
_______________________________________________________________________________
94 - What's Old

 #   %W /  %L /  %T                       Name               Author Score  Age
 7  31.1/ 26.6/ 42.3                      Newt          Ian Oversby 135.7  158
25  30.0/ 34.2/ 35.8 obvious to those who know        Robert Macrae 125.8  116
 6  31.4/ 25.0/ 43.7             Ultraviolet-B         Ken Espiritu 137.7   90

Newt keeps on going, whilst obvious may well not be around for the next edition
of Core Warrior.
_______________________________________________________________________________
OLD HALL OF FAME
* means the warrior is still active.

Pos    Name                  Author          Age     Strategy
 1  Thermite II            Robert Macrae     2262    Qscan -> bomber
 2  Impfinity v4g1         Planar            1993    Stone/ imp
 3  Jack in the box        Beppe Bezzi       1620    P-warrior
 4  Tornado 3.0            Beppe Bezzi       1567    Bomber
 5  Torch t18              P.Kline           1539    Bomber
 6  Chameleon              Myer R Bremer     1437    P-warrior
 7  Frontwards v2          Steven Morrell    1420    One shot scanner
 8  Evol Cap 6.6           John Wilkinson    1299    Imp / stone
 9  quiz                   Schitzo           1262    Scanner/ bomber
10  T.N.T.                 Maurizio Vittuari 1204    Bomber
11  Grilled Octopus v0.5   David Boeren      1154    P-warrior
12  Hazy Shade II          John Wilkinson    1102    P-warrior
13  Stepping Stone         Kurt Franke       1049    Qscan -> Vampire
14  Rosebud                Beppe Bezzi        993    Stone/ imp
15  Iron Gate 1.5          Wayne Sheppard     926    CMP scanner
16  T.N.T. pro             Maurizio Vittuari  925    Bomber
17  Agony II               Stefan Strack      912    CMP scanner
18  Barrage                Anton Marsden      876    Qscan -> replicator
19  Blue Funk              Steven Morrell     869    Stone/ imp
20  Flurry                 Anton Marsden      835    Qscan -> pwarrior
21  Thermite 1.0           Robert Macrae      802    Qscan -> bomber
22  Blue Funk 3            Steven Morrell     766    Stone/ imp
23  Night Train            Karl Lewin         755    Replicator
24  Mirage 1.5             Anton Marsden      736    Scanner/ bomber
25  Blizzard               Anton Marsden      713    Qscan -> replicator
_______________________________________________________________________________
NEW HALL OF FAME
* means the warrior is still active.

Pos    Name                  Author          Age     Strategy
 1  Probe                  Anton Marsden      403    Q^2 -> Bomber
 2  Blur 2                 Anton Marsden      396    Scanner
 3  Damage Incorporated    Anton Marsden      373    Q^2 -> Bomber
 4  Return Of The Jedimp   John K W           357    Q^2 -> Stone/imp
 5  unrequited love        kafka              346    Q^2 -> Paper
 6  Impish v0.2            Ian Oversby        345    Stone/imp
 7  Gigolo                 Core Warrior staff 332    Q^2 -> Stone/imp
 8  Falcon v0.3            Ian Oversby        275    P-warrior
 9  Nine Seven Six         M R Bremer         232    Q^2 -> Stone/imp
10  Rosebud                Beppe              218    Stone/imp
11  Q^2 Miro               Anders Ivner       214    Q^2 -> Scanner/bomber
12  Instant Wolf 3.4       Edgar              205    P-warrior
13  Goldfinch              P.Kline            201    P-warrior
14  Simple v0.4b           Ian Oversby        197    QScan -> Stone/imp
15  Trident^2              John K W           195    Q^2 -> Stone/imp
16  ompega                 Steven Morrell     189    Stone/imp
17  Frogz                  Franz              172    Q^2 -> Paper
18  The Machine            Anton Marsden      164    Scanner
19  Newt                   Ian Oversby        158 *  Q^2 -> Stone/imp
20  Memories               Beppe              152    Scanner
21  Head or Tail           Christian Schmidt  142    Q^2 -> Paper
22  Electric Head          Anton Marsden      140    P-warrior
23  Tiberius 3.1           Franz              130    Q^2 -> Paper
24= Solomon v0.8           Ian Oversby        116    Stone and scanner
24= obvious to those who k Robert Macrae      116    Q^2 -> Paper	

Newt climbs another place to 19th, whilst obvious fights its way onto the
bottom of the Hill, displacing Franz's CC Paper 3.3
_______________________________________________________________________________
Current Status of the Internet Pizza Server Beginner's Hill:

Hill Specs:
         coresize: 8000
   max. processes: 8000
         duration: after 80,000 cycles, a tie is declared.
max. entry length: 100
 minimum distance: 100
      maximum age: At age 100, warriors are retired.
    rounds fought: 200
  instruction set: ICWS '94 Draft

Last challenge: Fri May 15 00:16:19 PDT 1998
 #   %W /  %L /  %T                       Name               Author Score  Age
 1  55.2/ 18.1/ 26.7               March 0.93c           Csaba Biro 192.2   85
 2  55.3/ 28.3/ 16.5                     Rusty           John Lewis 182.3   38
 3  54.8/ 30.4/ 14.8  WannaChatInWarriorNames?         John Metcalf 179.2   47
 4  54.9/ 33.0/ 12.1                Minge VIII     Simon Wainwright 176.7    4
 5  49.0/ 28.4/ 22.6                      Fook            Max Misch 169.6   10
 6  49.6/ 33.6/ 16.8           One Step Beyond         John Metcalf 165.5   13
 7  47.6/ 29.8/ 22.6                      Fook            Max Misch 165.4    6
 8  45.8/ 34.0/ 20.2              Enceladus v5         Ryan Coleman 157.6   63
 9  47.8/ 44.2/  8.0               Ghost Train         John Metcalf 151.3    2
10  45.6/ 42.6/ 11.8            Sleepy Warrior         John Metcalf 148.6   46
11  43.4/ 38.7/ 17.9                Death kiss      Anders Rosendal 148.2   94
12  36.5/ 28.9/ 34.6                 Cascade 6        Steve Gunnell 144.1   24
13  39.3/ 43.6/ 17.2                     delta    Peter Andrewartha 134.9    3
14  38.3/ 42.7/ 19.0                   Twinkle         John Metcalf 133.8   44
15  38.7/ 47.5/ 13.8             Fire-master 3             P._V._K. 129.9    1
16  34.8/ 41.4/ 23.9          Sachinhamirwasia         Sapan Bhatia 128.2   51
17  38.2/ 50.6/ 11.2                NewClear 5         Ryan Coleman 125.9   14
18  35.8/ 50.5/ 13.6                 Brimstone         John Metcalf 121.2   37
19  30.3/ 48.3/ 21.5    Sachinhamirwasia ver 2         Sapan Bhatia 112.3   53
20  35.4/ 59.4/  5.2                     Oscck         John Metcalf 111.3    5
21  14.1/ 16.9/ 69.0                      DJ85    Peter Andrewartha 111.2   18
22  28.6/ 49.5/ 21.9                      KB15     Peter Anrewartha 107.7    7
23  26.5/ 47.4/ 26.2                     QUIRK               Mwolak 105.6   25
24  31.9/ 65.0/  3.1                     Splat           Paul Crook  98.8   36
25  24.1/ 57.2/ 18.6                   Fleapit        Steve Gunnell  91.0    9
_______________________________________________________________________________
The Hint - How to win Ilmari's Tournament

Ilmari Karonen recently ran a tournament, based around Round 4 of the Redcode
Maniacs Tournament (see
http://www.geocities.com/SiliconValley/Park/5427/maniacs.htm for details of
this), and the classic `Prisoner's Dilemma' problem. Basically, the idea was to
design a p-switcher switching between Carbonite (a stone) and TimeScape (a
paper). One thing which made the Tournament different from the normal Hill was
that it was not just a straight all-fights-all; after all the fights had been
completed, the worst warriors were removed, and the remaining warriors fought
again. The winner was the last warrior standing :-) Full details can be found
on the Tournament Web pages:

http://www.sci.fi/~iltzu/corewar/imt1/

The first thing I realised about this tournament was that the strategy needed
was rather different to normal Hill fights: on the Hill, to get a good result,
you need to score well against all warriors, both good and bad, whilst in IMT1,
the worse warriors will get removed from the running, so a successful warrior
will have to do well against other good warriors, with the scores against the
weaker warriors not mattering too much. A good example of this is TimeScape:
against simple warriors which run Carbonite a lot, this does very well, but it
is not a successful warrior in the Tournament (as can be seen from the
results).

The next question is how to determine what is a good warrior, using the
currently available tools. mts appears to be along the right lines, but this
doesn't store the results of each individual battle, only the total scores, so
determining the new scores after the bottom n warriors have been removed would
require re-running all the battles, which would take a lot of runtime (and all
this was being doing on what was supposedly the undergraduate teaching Unix box
at university :-) ), so I ended up writing a program to do this job: it isn't
quite the same as the Tournament in that only 1 warrior is removed every time,
rather than being removed it batches as happened in the Tournament, but it is
quite close. If anyone's interested, I've put the ANSI C source code up on my
web pages, at http://www.geocities.com/SiliconValley/Park/5427/ilmari.html.

At this stage, some more thinking about the tournament took place, and it
became obvious that the strategy for a successful warrior would be to split
wins as much as possible with the opposition, as this would score an average of
1.5 points per round, as opposed to the 1 point per round which is very easily
obtained by both parties running TimeScape every round. Therefore a successful
warrior will be scoring around 150 points per 100 rounds, at least against
other successful warriors.

Enough thinking, time for some practice: testing revealed that the Carbonite
after win, TimeScape after loss or tie warrior (DTfT) was the best of any of
the standard warriors given by Ilmari, and a few more simple and not-so-simple
switchers thrown in my me. DTfT has a great strength in that it is virtually
impossible to beat in a 1-on-1 fight (the only way to gain a decisive victory
is to run TimeScape a lot, and DTfT very quickly starts throwing TimeScape back
when fighting an opponent which does that). Also, it likes to cooperate with an
opponent: if it wins a round, it runs Carbonite in the next round, thus giving
the other warrior a chance for a win.

Self-fights are also very important in the Tournament (in the final round,
involving 3 warriors, half your score comes from the self-fight). At first
glance it appears that DTfT should be good in a self-fight, as both copies will
run Carbonite in the first round, and then alternation will occur between
Carbonite-TimeScape and TimeScape-Carbonite states, giving a win for one copy
or other in every round, and therefore a perfect score in the
self-fight. However, TimeScape beats Carbonite only around 90% of the time, and
after one tie, the warrior drops into the low-scoring TimeScape-TimeScape
state, and stays there.

To solve this problem, I changed from the very simple switcher used in DTfT to
a P^2 switcher which still selected Carbonite after a win and TimeScape after a
loss (no matter what the previous state), but ran the same warrior again after
a tie. This doesn't make the warrior significantly easier to beat, but does
mean it gets a much better score in self-fights, and is also less likely to get
stuck into a TimeScape-TimeScape state when fighting other cooperative
warriors.

This makes the self-fight score much better, but still not perfect; I didn't do
any detailed tests, but I think that it tends to drop around 10 points per 100
rounds in self-fight, which could be the difference between winning and
losing. The first thing I tried was putting in a decoy which had all its
b-fields pointing to just after Carbonite, so TimeScape's bombing line (mov.i
{-FSTEP,<FSTEP) would then blow Carbonite away. This improved the score in
self-fights, but did tend to give away some points in other fights, so I'm not
sure if this was an improvement or not.

Then, Ilmari made the ruling that suicidal switchers were allowed: this gives a
very easy method of getting a perfect score, by simply having two suicidal
states, when the two copies of the warrior alternating between them. The P^2
switcher used was now a 4-state affair:

				   State to change to after
		State	Component	W	L	T

		  0	TimeScape	1	0	0
		  1	Carbonite	1	0	1
(Initial state)	  2	 Suicide	2	3	0
		  3	 Suicide	2	0	0

State 2 expects to lose, whilst state 3 expects to win. In the first round,
state 2 will win for the warrior which moves second, thus placing the two
warriors into the correct states for the next round, when the starting orders
are reversed.

This now gives a perfect score in the self-fight (gaining say 10 points per 100
rounds), but gives away two losses at the start of every other fight while it
switches away from its suicidal states (therefore losing 6 points per
fight). Therefore whether this is a good idea or not depends on both the number
of rounds per fight and the number of warriors in the fight, neither of which
were known at this stage. Is there a way to detect a self-fight without giving
up two losses, remembering that the tournament rules stated that no PINs were
allowed, and the p-switcher could not read or write outside the warrior's
initial 100-instruction length?

Ths solution which I came up with was to create a special routine, which was to
be run on the first round only, and simply did nothing for almost 80000 cycles!
If this routine did not complete its waiting phase (which can occur either
because it won because the other warrior suicided earlier, or it was killed by
the opponent), it was pre-set to switch to TimeScape for the second round. On
the other hand, if it did complete its wait, it reloaded its pspace to switch
into suicidal mode, and then commited suicide itself. This still gives the
perfect self-fight, but now gave up only 3 points when fighting other warriors
(or perhaps less: I think that most successful warriors will run Carbonite on
the first round, to avoid getting locked into a TimeScape-TimeScape state, and
after Carbonite has killed my `do nothing' routine, I again think that
successful warriors will stick with Carbonite, so by running TimeScape, I get a
win and end up back on level terms).

To decide which four warriors to submit to the Tournament, I created nine
different warriors: the 2-state P^2, the 4-state P^2 and the 4-state P^2 with
first round routine, each with three different decoys: the decoy pointing
towards Carbonite, a decoy pointing away from Carbonite, and a 1,1 decoy
designed to slow down the djn trail of Carbonite. I ran all nine of these off
together using my test program, and took the last four standing. These were the
4-state P^2 with first round with all three of the decoys, and the simple
4-state P^2 with the 1,1 decoy (which came last of the four).

Anyway, the results:

Rank    Name                    Author                   %W  %L  %T   Score
___________________________________________________________________________
  1     Type Three Quantum Sing Philip Kendall           50  49   1   1199  
  2     Type One Quantum Singul Philip Kendall           49  49   2   1197  
  3     Altruist 2/3            Robert Macrae            48  49   3   1181

  4     Variations 1            M. J. Pihlaja            45  46   9   2034  
  5     Type Two Quantum Singul Philip Kendall           43  43  13   2012  
  6     Variations 1            M. J. Pihlaja            42  43  15   1987  

  7     System D 2-12/20        Robert Macrae            33  32  34   2945  
  8     Modus Vivendi 3/20      Robert Macrae            34  34  32   2935  
  9     Type Four Quantum Singu Philip Kendall           32  32  37   2893  
 10     Variations 4            M. J. Pihlaja            30  29  41   2886  

Quite good, even if I do say so myself :-) I was helped in the final battle by
having two of my warriors in there, as the self-fight detection routine works
just as well between two of my warriors with the first round routine, so both
of my warriors immediately scored 900 points, and only had Altruist 2/3 to
fight. Anyway, here's the code of the winning warrior, Type Three Quantum
Singularity:

;redcode-94
;name Type Three Quantum Singularity
;author Philip Kendall
;strategy A P^2 switcher doing win -> Carbonite, loss -> Timescape,
;strategy tie as last round. Also with a couple of suicidial states
;strategy to ensure a perfect score in self-fights, a special first
;strategy round 'do nothing' loop to work out when we're fighting
;strategy ourself, and a decoy which points towards Carbonite to
;strategy reduce the number of ties.
;assert CORESIZE==8000 && MAXCYCLES==80000

	for     49
	dat.x   0,(carb+3)
	rof

dbomb   dat     >-1, >1
carb    spl     #0, <-100
	mov     dbomb, tar-197*3500
tar     add     #197, -1                ; gets bombed to start coreclear
	djn.f   -2, <-1151

	for     8		; must be followed by 8 dats
	dat.f   0,0
	rof

TSTEP equ 1800
CSTEP equ 3740
NSTEP equ -1922
FSTEP equ 1870

time    spl     1,              <-200
	spl     1,              <-300
	mov.i   -1,             0

tim1    spl     @tim1,          }TSTEP
	mov.i   }tim1,          >tim1
cel1    spl     @cel1,          }CSTEP
	mov.i   }cel1,          >cel1
	mov.i   {-FSTEP,        <FSTEP
	mov.i   {cel1,          <ncl1
ncl1    jmp     @ncl1,          >NSTEP

	for     2		; must be followed by 2 dats
	dat.f   0,0
	rof

pState  equ     138     ; pspace location containing current state
nStates equ     4       ; maximum number of states (for brainwash protection)

;NOTE: state values go from 0 to STATES-1

	dat.f   0,init-state
in      dat.f   0,loss_t-state
	dat.f   0,win_t-state
	dat.f   0,tie_t-state

think   ldp.a   #0,in              ; get input value
load    ldp.a   #pState,state      ; load old state
	mod.a   #nStates,state     ; brainwash protection
	add.ba  *in,state          ; select correct state table
store   stp.a   *state,load        ; store new state
state   jmp.a   @0                 ; jump to warrior code

init    dat.f   0,first
win_t   dat.f   1,carb
	dat.f   1,carb
	dat.f   2,suicide
	dat.f   2,suicide
tie_t   dat.f   0,time
	dat.f   1,carb
loss_t  dat.f   0,time
	dat.f   0,time
suicide dat.f   3,suicide
	dat.f   0,time

first   mov.ab  #7996,count        ; wait around for ~80000 cycles
count   djn.b   0,#0
	djn.b   first,#10

	; if we haven't lost yet, we're almost certainly fighting
	; ourself, so enable the suicide routine

	mov.i   (win_t+2),init
	jmp.a   store
	
	end     think

_______________________________________________________________________________
Extra Extra - The Fugitive by David Moore

Imp versus Gate. The final showdown of countless battles.
What can our own imps do to survive?
We find the secret to longevity in superior numbers!
When imps run with 100s of processes they are so slow that
they miss much of the core. If any one of them avoids the impending gate,
then the battle is saved.

That's the plan, but how can we accomplish it?
In this article we improve upon the classic approach of launching from paper.
In the past there have been two types of imp-launching paper:
Die Hard, which copies an entire launcher with each silk,
and theMystery1.5, which synchronizes three different copies of paper
to make a single on-board imp work.
The goal is to create a new kind of imp-launching paper that is more
prolific than Die Hard but does not require the expensive binary
launch code of theMystery.

Sometime during the execution of the paper, we would like 3 of its
copies to coincide to execute their 3 imp instructions
in the same order and places that an imp ring would.


        spl  1, 0       ; generate 5 parallel processes
	mov -1, 0
	mov -1, 0

paper   spl   @0,    A   ; 1
	mov  }-1,  >-1   ; 2
	spl   @0,    B   ; 3
	mov  }-1,  >-1   ; 4
imp     mov.i #0, 2667   ; 5


We're looking for A and B such that the execution of an imp at location C
will be followed by other imps at C+2667 and C+5334.

The following diagram traces the execution of the paper.
Each pair I,J represents the Ith instruction being executed at
location J. Instructions in the same row execute in turn, with the
leftmost instruction executing first.


                           +---------+
                           |   1,0   |
                           +---------+
                          /           \
                        /               \
            +---------+                  +---------+
            |   2,1   |                  |   1,A   |
            +---------+                  +---------+
                 |                      /           \
                 |                    /              \
            +---------+        +---------+         +---------+
            |   3,2   |        |  2,A+1  |         |  1,A+A  |
            +---------+        +---------+         +---------+
          /      |                  |                   |      \
        /        |                  |                   |        \
   [cut]    +---------+        +---------+         +---------+    [cut]
            |  3,B+2  |        |  3,A+2  |         | 2,A+A+1 |
            +---------+        +---------+         +---------+
          /      |              |       |                   |
        /        |              |       |                   |
   [cut]    +---------+      [cut]     +---------+         +---------+
            | 3,B+B+2 |                | 3,A+B+2 |         | 3,A+A+2 |
            +---------+                +---------+         +---------+
          /      |                    /     |               /      |
        /        |                  /       |             /        |
   [cut]    +---------+        [cut]   +---------+     [cut]     +---------+
            | 4,B+B+3 |                | 4,A+B+3 |               | 4,A+A+3 |
            +---------+                +---------+               +---------+
                 |                          |                         |
                 |                          |                         |
            +---------+                +---------+               +---------+
            | 5,B+B+4 |                | 5,A+B+4 |               | 5,A+A+4 |
            +---------+                +---------+               +---------+


Since the 5th instruction (the imp) is executed 3 times in the last row,
an imp ring is possible if for some C:

        B+B+4 = C
        A+B+4 = C + 2667      (2667 == (CORESIZE+1)/3)
        A+A+4 = C + 5334

Solving the system of equations yields:

        A = B + 2667

Therefore, the following paper can launch imp rings:


        B equ 2355      ; B can be almost any number

        spl  1, 0       ; start 5 parallel processes
	mov -1, 0
	mov -1, 0

        spl   @0, B+2667  ; substituted  a <- b+2667
	mov  }-1,  >-1
	spl   @0,    B
	mov  }-1,  >-1
	mov.i #0, 2667


Some programs clear with DAT <2667, <5334 bombs.
If they give you a hard time then you can use 7 point imps:


;redcode-94
;name Seven Brothers
;author David Moore
;assert CORESIZE==8000

	size equ 1143

	c1 equ 2365
	c2 equ 5715

start   spl  1, 0       ; start 7 parallel processes
	spl  1, 0
	mov -1, 0

paper   spl   @0,   c1
	mov  }-1,  >-1
        spl   @0,   c2+size
	mov  }-1,  >-1
	spl   @0,   c2
	mov  }-1,  >-1

imp     mov.i #1, size

end


Finally, the source code for The Fugitive, which uses a q^2 and paper
with imps and anti-imp bombing:


;redcode-94
;name The Fugitive
;author David Moore
;strategy qscan, silk, imps
;assert CORESIZE==8000

;---------
; q^2 scan
;---------

QB equ 1000  ; scan pattern
QS equ 500
QI equ 250

qscan seq qscan+QB+(QS*0), qscan+QB+(QS*0)+QI
      jmp q0, 0

      seq qscan+QB+(QS*3), qscan+QB+(QS*3)+QI
      jmp q1, 0
      seq qscan+QB+(QS*6), qscan+QB+(QS*6)+QI
      jmp q1, {q1
      seq qscan+QB+(QS*7), qscan+QB+(QS*7)+QI
      jmp q1, }q1

      seq qscan+QB+(QS*1), qscan+QB+(QS*1)+QI
      djn.a q2, >q1
      seq qscan+QB+(QS*2), qscan+QB+(QS*2)+QI
      jmp q2, >q1
      seq qscan+QB+(QS*4), qscan+QB+(QS*4)+QI
      jmp q2, {q2
      seq qscan+QB+(QS*5), qscan+QB+(QS*5)+QI
      jmp q2, 0
      seq qscan+QB+(QS*8), qscan+QB+(QS*8)+QI
      jmp q2, {q1
      seq qscan+QB+(QS*9), qscan+QB+(QS*9)+QI
      jmp q2, }q1
      seq qscan+QB+(QS*10), qscan+QB+(QS*10)+QI
      jmp q2, }q2

      jmp pboot, >393

;-----------
; q^2 bomber
;-----------

qb1   dat 23,  23
qb2   dat  1,  34

      dat  QS*1,  QS*6
tab   dat  QS*2,  QS*3
      dat  QS*7,  QS*7

q2    add.ab tab, fwd
q1    add.b  tab, @-1
q0    sne   @fwd, pboot-1
      add  #QI-2, @2
      add.ba fwd, fwd
      mov    qb2, *fwd
      mov    qb2, @fwd
fwd   mov     88, @qscan+QB+(QS*0)
      sub    qb1, @-3
      djn     -4, #5
      jmp  pboot,  0
 
for 48
 dat 0,0
rof

;---------------
; Silk with Imps
;---------------

impy equ 2667

c1 equ 3855
c2 equ 2355
c3 equ  831
c4 equ 4000

pboot spl  1, >7648        ; 8 processes
      spl  1, >7356
      spl  1, >7212

      mov <1, {1               ;optional
      spl paper+c4+8, paper+8  ;extra launcher

paper spl  @0, >c1
      mov }-1, >-1
      spl  @0, >c2+impy
      mov }-1, >-1
      spl  @0, >c2
      mov }-1, >-1

      mov.i #1, {1         ; anti-imp bombing

      mov.i #c3, impy      ; my imp (a-field is data)

end qscan

____________________________________________________________________________
Questions?  Concerns?  Comments?  Complaints?  Mail them to people who care.
Authors: Beppe Bezzi <giuseppe.bezzi@galactica.it>,  Anton Marsden
<amarsden@mcs.vuw.ac.nz>, Christian Schmidt <schmc003@goofy.zdv.Uni-Mainz.de>
and Philip Kendall <pak21@cam.ac.uk>
© 2002-2005 corewar.info. Logo © C. Schmidt