Sunday, 24 January 2010

Cross Simulator Core Graphics

One difficulty when trying to write code to plot graphics in Redcode is the width of the core display. The four most popular simulators uses a variety of different widths:

Simulator
Display Width
pMARS SDL mode 0
157
pMARS SDL mode 2
126
CoreWin
128
ARES
80
nMars
various

The simplest solution is to define a variable for the width which can be modified by the person running the program. Alternatively it's possible to use the the predefined VERSION constant to determine the simulator:

Simulator
Version
pMARS SDL mode 0
92
pMARS SDL mode 2
92
CoreWin
230
ARES
0
nMars
93

Putting the two together we can write the following code which sets the correct width for pMARS SDL, CoreWin and ARES:

width equ ( (VERSION==92)*157 + (VERSION==230)*128 + (VERSION==0)*80 )

Thursday, 7 January 2010

Fractals in Corewar

Koch Curve in RedcodeIn 1997 Anton Marsden organised a Corewar tournament with a difference.  The three rounds challenged players to use Redcode to solve a variety of problems.

In the third round of Anton's Corewar Tournament the challenge was to write a Redcode program to draw a pretty picture.  First place was taken by Ilmari Karonen with a fractal fern.

Here's my own attempt at creating a pretty picture in the core view of pMARS. It's a fractal known as the Koch Curve.

Here's the program, just 18 instructions:

width equ 157

        org    koch

        stack equ count+30

koch:   mov    #2-ptr, >stack
        jmp    count,  }move

        sub.a  #2,     move
        mov    #2-ptr, >stack
        jmp    count

        jmp    return, }move

count:  djn    koch,   #11
        mod.a  #8,     move
        div.a  #2,     move
        add.b  *move,  pos
        mul.a  #2,     move
pos:    add    #1,     koch+71*width/2+16
return: mov.ba <stack, ptr
ptr:    jmp    0,      >count

move:   dat    -1
        dat    -width
        dat    1
        dat    width

Have you tried to write a graphical display in Corewar?

Tuesday, 27 October 2009

Tinywarrior Issue 4

Tinywarrior issue 4, corewarThe fourth issue of Tinywarrior has just been published, the newsletter which reports the latest events and techniques for the tiny hill. Here's what you can expect to find in this issue:

Flux and the SPL/DIV Clear by John Metcalf examines a SPL/DIV clear inspired by G2.

Larger Than Infinity by Zul Nadzri reveals the results of Zul's experiments with White Noise.

Any feedback would be greatly appreciated.

Tuesday, 25 August 2009

Maezumo, Evolving for the Corewar Tiny Hill with a Twist

Maezumo, the Evolver with a TwistAt the beginning of August, Christian Schmidt released version 1.04 of Maezumo, his corewar evolver. If you're familiar with the old version the biggest difference you'll notice are the additions to the progress report.

Maezumo evolves warriors using traditional mutation, keeping a hill of the top warriors. Hill warriors are then injected back into the soup. Where Maezumo offers something innovative is in the hint modes.

If the hint modes are enabled, Maezumo generates warriors from inbuilt templates. These challenge the hill and if successful enter the soup for further enhancement by the mutation algorithm.

Maezumo is supplied with a Windows binary, Basic source code and all the necessary support files. To evolve for the tiny hill, I simply extracted the archived, changed the settings in maezumo.ini and double clicked maezumo.exe. I selected the scanner/paper hint mode to cover the two most successful tiny strategies.

After a 13 hour run, the top warrior on Maezumo's hill is an evolved style paper which scores 75 against SAL's tiny hill. I think it would be realistic to expect a strong tiny warrior after a 3 or 4 day run.

Have you tried Maezumo yet? If so, let me know your thoughts :-)