Core War
From Wikipedia, the free encyclopedia
Core War (or Core Wars) is a programming game in which two or more battle programs (called warriors) compete for the control of the MARS virtual computer (Memory Array Redcode Simulator). These battle programs are written in an abstract assembly language called Redcode. The object of the game is to cause all processes of the opposing program(s) to terminate, leaving your program in sole possession of the machine.
Contents |
[edit] History
Core War was in part inspired by a game called Darwin, written by Victor A. Vyssotsky, Robert Morris Sr., and M. Douglas McIlroy at the Bell Labs in the 1960s.
The first description of the Redcode language was published in March 1984, in Core War Guidelines by D. G. Jones and A. K. Dewdney. The game was introduced to the public in May 1984, in an article written by Dewdney in Scientific American ("Computer Recreations" - In the game called Core War hostile programs engage in a battle of bits). Dewdney revisited Core War in his "Computer Recreations" article in March 1985, and again in January 1987.
The International Core War Society (ICWS) was founded in 1985, one year after Dewdney's original article. ICWS published new standards for the Redcode language in 1986 and 1988, and proposed an update in 1994 [1] that was never formally set as the new standard. Nonetheless, the 1994 draft was commonly adopted and extended, and forms the basis for the de facto standard for Redcode today. The ICWS was directed by Mark Clarkson (1985–1987), William R. Buckley (1987–1992), and Jon Newman (1992–); currently the ICWS is defunct.
In 1991, the newsgroup rec.games.corewar was created. Up to now it remains the most prolific source of Core War related information. Most articles and newsletters on Core War have been published in this newsgroup.
[edit] Redcode
0000: ADD.AB # 4, $ 3 0001: MOV.F $ 2, @ 2 0002: JMP.B $ -2, $ 0 0003: DAT.F # 0, # 0
Assembled ICWS-94 style Redcode
Both Redcode and the MARS environment are designed to provide a simple and abstract platform without the complexity of actual computers and processors. Although Redcode is meant to resemble an ordinary CISC assembly language, it differs in many ways from "real" assembly:
- Redcode has very few operations — 10 in ICWS-88 and 16 in ICWS-94.
- Each assembled instruction is divided into an instruction code and two numeric fields. No numeric value is defined for the instruction code. The code may only be copied as part of an entire instruction, and may only be compared for equality.
- Besides the opcode and two numeric operands, ICWS-94 allows each Redcode instruction to have a modifier that defines the size (one field, both fields, or entire instruction) of the data that the instructions operates on. Additionally, each of the numeric fields has associated addressing mode. ICWS-88 defines 4 addressing modes, and ICWS-94 extends this number to 8.
- Each Redcode instruction has the same length and takes the same time to execute. The memory is addressed in units of one instruction.
- All numbers are unsigned (i.e. non-negative) integers less than the size of the memory. Therefore there is a one-to-one correspondence between numbers and memory locations. All arithmetic is done modulo the size of the memory.
- Only relative addressing is used. That is, address 0 always refers to the currently executing instruction, address 1 to the instruction after it, and so on. Addresses past the end of the memory wrap around to the beginning. This way, a program cannot (and need not) know its absolute location in the memory.
Each program can also have several active processes, each having its own instruction pointer. Each program starts with only one process, but others can be created with the SPL instruction. The processes for each program execute alternately, so that the execution speed of each process is inversely proportional to the number of active processes the program has. A process dies when it executes a DAT instruction (or performs a division by zero). A program is considered dead when it has no more processes left.
[edit] Strategy
Warriors are commonly divided into a number of broad categories, although actual warriors may often combine the behavior of two or more of these. Three of the common strategies (replicator, scanner and bomber) are also known as paper, scissors and stone, since their performance against each other approximates that of their namesakes in the well known playground game.
- A replicator (or paper) makes repeated copies of itself and executes them in parallel, eventually filling the entire core with copies of its code. Replicators are hard to kill, but often have difficulty killing their opponents. Replicators therefore tend to score a lot of ties, particularly against other replicators. The earliest example of a replicator is Mice by Chip Wendell.
- A silk is a special type of very rapid replicator, named after Silk Warrior by Juha Pohjalainen. Most modern replicators are of this type. Silk replicators use parallel execution to copy their entire code with one instruction, and begin execution of the copy before it is finished.
- A bomber (or stone) blindly copies a "bomb" at regular intervals in the core, hoping to hit the enemy. The bomb is often a DAT instruction, although other instructions, or even multi-instruction bombs, may be used. A bomber can be small and fast, and they gain an extra edge over scanning opponents since the bombs also serve as convenient distractions. Bombers are often combined with imp spirals (see below) to gain extra resiliency against replicators. The second published warrior in Core War history, Dwarf by A. K. Dewdney, was a bomber.
- A scanner ( or scissor) is designed to beat replicators, usually by bombing memory with SPL 0 instructions. This causes the enemy to create huge number of processes which do nothing but create more processes. This slows down useful processes. When the enemy becomes so slow that it is unable to do anything useful, the memory is bombed with DAT instruction.
- A scanner doesn't attack blindly, but tries to locate its enemy before launching a targeted attack. This makes it more effective against hard-to-kill opponents like replicators, but also leaves it vulnerable to decoys. Scanners are also generally more complex, and therefore larger and more fragile, than other types of warriors. He Scans Alone by P. Kline is an example of a strong scanner.
- A vampire or pit-trapper tries to make its opponent's processes jump into a piece of its own code called a "pit". Vampires can be based on either bombers or scanners. A major weakness of vampires is that they can be easily attacked indirectly, since they must by necessity scatter pointers to their code all over the core. Their attacks are also slow, as it takes an extra round for the processes to reach the pit. myVamp5.4 by Paulsson is a good example of a vampire.
- A one-shot is a very simple scanner that only scans the core until it finds the first target, and then permanently switches to an attack strategy, usually a core clear. Myrmidon by Roy van Rijn is a simple, yet effective oneshot.
- An imp (named after the first ever published warrior, Imp by A. K. Dewdney) is a trivial one-instruction mobile warrior that continually copies its sole instruction just ahead of its instruction pointer. Imps are hard to kill but next to useless for offense. Their use lies in the fact that they can easily be spawned in large numbers, and may survive even if the rest of the warrior is killed.
- An imp ring or imp spiral consists of imps spaced at equal intervals around the core and executing alternately. The imps at each arm of the ring/spiral copy their instruction to the next arm, where it is immediately executed again. Rings and spirals are even harder to kill than simple imps, and they even have a (small) chance of killing warriors not protected against them. The number of arms in an imp ring or spiral must be relatively prime with the size of the core.
- A quickscanner attempts to catch its opponent early by using a very fast unrolled scanning loop. Quickscanning is an early-game strategy, and always requires some other strategy as a backup. Quickscanners score well against long warriors — such as other quickscanners.
- A core clear is a simple warrior that sequentially overwrites every instruction in the core, sometimes even including itself. Core clears are not very common as stand-alone warriors, but they are often used as an end-game strategy by bombers and scanners.
- A bomb-dodger is a specialized strategy against bombers. It scans the core until it locates a bomb thrown by the bomber, and then copies its code there, assuming that the bomber won't attack the same spot again any time soon.
[edit] Variants
- CoreWars 8086 implements a game very similar to the original Core War. Instead of using the customized instruction set of Redcode, CoreWars 8086 warrior programs are written in 8086 assembly language.
- Quantum Coreworld uses a quantum computing superset of standard Redcode.
- Tierra is an adaptation of Core War, written by Thomas S. Ray (an early member of the ICWS), used in the modeling of living system.
- Avida is a further derivative of Core War, building upon Tierra, and abstracting further the processes of evolution. Avida, created by Christoph Adami, Charles Ofria, and Titus Brown, is used in scientific research about evolution.
[edit] Trivia
The word "Core" in the name comes from magnetic core memory, an obsolete random access memory technology. The same usage may be seen in other computer jargon terms such as "core dump".
[edit] See also
[edit] External links
- The Imp Ring, a webring of Core War related sites
[edit] Documents
- Annotated Draft of the Proposed 1994 Core War Standard
- The Beginner's Guide to Redcode provides an introduction to Redcode for programmers and nonprogrammers alike.
- Concise introduction to Core Wars, links and tutorials.
- The Core War Info page
- Corewar History and Statistics Page
- The Core War FAQ (Wikified version)
[edit] Programs
- pMARS is the official simulator of the newsgroup rec.games.corewar. The koth.org Corewars Hills use pMARS, which is compatible with the extended ICWS-94 draft standard.
- CoreWin a GUI-base Corewar simulator for Windows; compatible with the extended ICWS-94 draft standard.
- nMars - Corewars MARS for .NET under LGPL
- CoreWars 8086 open source engine download site
- GTK+ based Corewar Simulator
- ARES - Corewar Simulator and Debugger for Windows, ICWS-94, tiny interactive tutorial
- Memory Armagedom A Brazilian ICWS-94 PMARS for Windows 32]
- Team11's CoreWars A java-based freeware Core War game as client/server application
[edit] Tournaments
- KOTH.org hosts "King of the Hill" Core War tournaments and provides information and software.
- Another site with "King of the Hill" tournaments
- Redcoders Frenzy The ongoing Core War tournament