Core War

Modified on 2016/05/06 22:08 by 146.199.165.253 — Categorized as: Von Neumann Games

Image
Core War is a game played between two or more computer programs in the memory of the Memory Array Redcode Simulator (MARS) virtual computer. The aim is to out survive all opponents while attempting to disable all opponents.

Table of Contents [Hide/Show]


   History
   Redcode
      Opcodes
      Modifiers
      Addresses
      P-Space
   Example
   Inspiration for
   External Links


Edit

History

In March 1984 A. K. Dewdney and David Jones wrote the Core War Guidelines which suggested how to implement a simple version of Core War. Shortly after, Dewdney published his first Core War article in Scientific American inspiring a number of programmers to implement their own version.

The following year a society was formed to standardise Redcode and organise an annual tournament. The International Core Wars Society (ICWS) issued a standard in May 1986 and organised the first tournament at Boston's Computer Museum in September 1986.

Edit

Redcode

Core War programs are written in a language called Redcode. The original instruction set had 8 opcodes but with the publication of the '94 standard the number increased to 18.

Each location in memory contains an instruction and two values A and B. A and B are used as address pointers when the instruction is executed. A and B may also be used as data when referenced by another instruction.

Edit

Opcodes

Opcodes can be divided into five groups:

Copying:


Simple Maths:


Flow Control:


Process Control:


Miscellaneous:


Edit

Modifiers

Each opcode has a modifier which describes which values should be used from each address:


Edit

Addresses

Each address has an addressing mode and a pointer. All pointers are relative to where the address is stored. 0 refers to the current location. 1 refers to the next location and -1 to the previous. There are 8 addressing modes:




All values are taken modulo the size of memory (CORESIZE). Values range from 0 to CORESIZE-1. For example if the CORESIZE is 8000, -3 is stored as 7997 (CORESIZE-3).

Edit

P-Space

P-space is an area of private non-volatile memory which can only be accessed via LDP and STP. Each program has its own area of private memory. The contents of p-space are preserved between rounds in a multi-round battle.

Location 0 in p-space contains a flag indicating the result of the previous round:


P-space is often used by programs to switch between two or more strategies based on the performance in previous rounds.

Edit

Example

;redcode
;name imp
;author A. K. Dewdney

        MOV.I $ 0, $ 1

The imp is one of the simplest Core War programs. MOV.I copies an entire instruction from A to B. A is $ 0 and points directly to the imp in the current location. B is $ 1 and points directly to the next location.

When the imp executes it copies itself from the current location to the next location. When the next location is executed, it contains an exact copy of the imp and so the process repeats.

Edit

Inspiration for

CROBOTS

Edit

External Links