Two computer programs in their native habitat — the memory chips of a digital computer — stalk each other from address to address. Sometimes they go scouting for the enemy; sometimes they lay down a barrage of numeric bombs; sometimes they copy themselves out of danger or stop to repair damage. This is the game I call Core War.”

Dewdney, A. K. Scientific American May 1984.

Core War is played between two or more computer programs in the memory of the MARS virtual computer. The aim is to survive long enough to outsmart and eliminate all opponents. Core War was designed by A K Dewdney and David Jones and announced in the May 1984 issue of Scientific American. Programs are written in an abstract assembly language known as Redcode.

Core War: a battle between Son of Vain and Reepicheep

Strategy

A variety of strategies have evolved for Core War, each with their own strengths and weaknesses. Three of the most common are named after the moves in the game paper-scissors-stone. Programs often combine two or more strategies in parallel.

Paper
A paper replicates off multiple copies of itself and executes them in parallel. Modern paper is normally small and resilient, performing well against stones and losing to scissors.
Scissors
Scissors scan for the opponent and hit hard, first stunning with a SPL attack then switching to a deadly DAT attack. Modern scissors are often large and fragile, scoring well against paper but losing to stones.
Stone
A stone blindly scatters simple DAT bombs through memory in the hope of hitting an opponent. Modern stones are normally small and fast, scoring well against scissors and losing to paper.
Vampire
Vampires attempt to capture enemy processes by placing a JMP inside the opponent's code. Modern vampires are often complex, scoring well against scissors, average against paper and losing to stones.
Imp
An imp is a mobile program which copies itself just ahead of the instruction pointer using only MOV instructions. Modern imps run at multiple points in memory and are usually paired with paper or stone.

Redcode

Redcode is a simple assembly language with 18 instructions and 8 addressing modes, mostly for basic maths and flow control. The language is relatively easy to learn. Short, fast programs often score well:

scan    sne    222,     3517   ; scissors / scanner
        add    inc,     scan   ; - sparse attack on empty memory
        mov    bomb,    }scan  ; - dense attack on occupied memory
        mov    bomb,    >scan
        djn    scan,    #343

bomb    spl    #1,      1
clear   mov    inc,     >scan  ; clear / wipe memory
        djn.f  clear,   >scan
inc     dat    12,      12

Discover

To discover more about Core War and to find out how to get involved visit corewar.co.uk or search online for “corewar”.