Core War

from Wikipedia, the free encyclopedia
Core War
Core War PMars Screenshot.png
Senior Developer DG Jones, AK Dewdney
Erstveröffent-
lichung
1984
platform Memory Array Redcode Simulator
genre Programming game
Game mode Single player
language English

Core War is a programming game in which two or more programs written in a simple assembler-like language called Redcode compete against each other in the same memory space. The winner is the program that outlives all others. Although Core War can stand for any type of game, it is commonly referred to as the variant based on the Redcode programming language and made known through the articles by Alexander K. Dewdney in Scientific American .

Core War develops Darwin's game idea from 1961. While Darwin's programs were executed directly on the computer, Core War uses the Memory Array Redcode Simulator ( MARS ), a virtual machine .

The International Core War Society ( ICWS ) published revisions of Redcode in 1984 and 1988 ; an update proposal from 1994 was not adopted.

Rules of battle

Redcode as a fighting language differs from other assembly languages:

  • Only relative addressing is used.
  • The memory space (core) is ring-shaped. Addresses are therefore to be interpreted as moduli of the memory size.
  • Any possible argument to a command is also a valid argument.
  • Data is stored as arguments to the DAT command.
  • Running DAT as a command kills the process.

Programs

The simplest program imp (in German "Knirps"), consisting of an instruction ( mov $0, $1), copies its content one field further, and then goes to this field.

twin

Gemini (in German "Zwilling") makes a complete copy of his program, and then jumps to his copy.

                 jmp     3
 dat1            dat     #0
 dat2            dat     #99
 start           mov     @dat1,   @dat2
                 add     #1,      dat1
                 add     #1,      dat2
                 cmp     dat1,    dat3
                 jmp     start
                 mov     #99,     94
                 jmp     94
 dat3            dat     #10

It was only with the introduction of the SPL (split) command that dynamics came into play. This was shown in two programs with different strategies.

Mice and Catcan

While the Mice program (by Chip Wendell) uses the SPL command to split up in a controlled manner,

 ptr     dat     #0
 org     mov     #12,     ptr    ; n = 12
 loop    mov     @ptr,    <dest  ; *dest = *(ptr+(*ptr))
         djn     loop,    ptr    ; if(--ptr != 0)
                                ;     goto loop
         spl     @dest          ; split(*dest)
         add     #653,    dest   ; dest += 653
         jmz     org,     ptr    ; if(!ptr)
                                ;     goto org
 dest    dat     #0,      #833
         end     org

the Catcan program uses the instruction as a split bomb to turn off the enemy, in order to finish him off by extinguishing him in the end:

Warrior: Cat Can Standard: CWS'88 Author: A. Kirchner Remixor: F. Uy

 start     mov       trap2,   < bomb
           mov       trap1,   < bomb
           sub     # 6,         bomb
           jmn       start,     bomb ; trap loop
 set       mov     # -12,       bomb
 kill      mov       bomb,    @ bomb
           djn       kill,      bomb ; kill loop
 reset     jmp       set,       0
           jmp       set,       0
           dat     # 0,       # 0    ; buffer
 bomb      dat     # 0,       # -1024
 trap1     spl       0,         2
 trap2     jmp       -1,        1
           end       start

;
; Your basic two sweep methodical bomber.
; Fires SPL 0 and JMP −1 at every eight
; addresses, then erases the core with
; DAT bombs.

Although Mice was superior to most of the older opponents (Gnome, Zwilling ,. ), Catcan was even more successful with his split bomb.

In order to understand the consequence of the SPL instruction, one has to know what a duel in Core War looks like. The sequence provides that first one program executes an instruction and then the other program. If a program now executes an SPL statement, the result is that the execution of a program is split into two different parts. Without a split, the sequence is for two programs A and B: ABABAB…. If program B is now split into two processes exactly once (which can be quite useful), the sequence is AB 1 AB 2 AB 1 AB 2 AB 1 AB 2 …. If a program is hit by an SPL bomb or jumps into one, then the program has to spend an exponentially increasing (up to the limit of 64 possible processes) portion of its "computing time" for the completely useless instructions, which makes its meaningful actions massive be slowed down.

Agony

With the 94 standard, numerous programs (the so-called scanners and vampires) were created that are far superior to the catcan, for example the Agony 2.1 program by Stefan Strack:

;strategy Small-interval CMP scanner that bombs with a SPL 0 carpet.
;strategy 2.0: smaller
;strategy 2.1: larger, but should tie less; changed scan constants
;strategy Submitted: @date@

 CDIST   EQU     23                 ; distance between addresses CoMPared
 IVAL    EQU     994                ; scan increment (mod-2 pattern)

 scan    ADD     incr,   comp                            ; CMP scan loop:
 comp    CMP     0,      CDIST                           ;
         SLT     #incr-comp+CDIST+(bptr-comp)+1,comp     ; don't bomb self
         JMP     scan                                    ;

         MOV     #CDIST+(bptr-comp)+1,count    ; init bomb-loop w/ # of bombs
         MOV     comp,    bptr                 ; use "comp" as bomb-pointer
 bptr    DAT     #0                            ; this will be "comp" when exec
 split   MOV     bomb,   <bptr                 ; bomb away
 count   DJN     split,  #0
         JMN     scan,   scan                  ; fall thru when self-obliterated
 bomb    SPL     0                             ; and clear the core
         MOV     2,<-1
 incr    DAT     #IVAL,  #IVAL

Adaptations for evolutionary research

  • Tierra is an adaptation of Core War written by Thomas S. Ray , an early member of the ICWS, and is used in modeling living systems.
  • Avida is another descendant of Core War . It is based on Tierra, and abstracts evolutionary processes even further. It was developed by Christoph Adami , Charles Ofria and Titus Brown and is used in evolutionary research.

Web links