Core War

Core War

A game of Core War running under the pMARS simulator
Original author(s) D. G. Jones & A. K. Dewdney
Initial release 1984
Type Programming game

Core War (or Core Wars) is a programming game in which two or more battle programs (called "warriors") compete for the control of the "Memory Array Redcode Simulator" virtual computer ("MARS"). 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 the victorious program in sole possession of the machine.

Contents

History

Core War was inspired by a program called Creeper and a subsequent program called Reaper that destroyed copies of Creeper. Creeper was created by B. Thomas at BBN.[1] Dewdney was not aware of the origin of Creeper and Reaper and refers to them as a rumor originating from the Darwin game and the worm experiments of Shoch and Hupp.

The 1984 Scientific American article on Core War[2] nonetheless cites the game Darwin, written by Victor A. Vyssotsky, Robert Morris Sr., and M. Douglas McIlroy at the Bell Labs in the 1960s. 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".

The first description of the Redcode language was published in March 1984, in Core War Guidelines by D. G. Jones and A. K. Dewdney.[3] The game was introduced to the public in May 1984, in an article written by Dewdney in Scientific American. Dewdney revisited Core War in his "Computer Recreations" column in March 1985,[4] and again in January 1987.[5]

The International Core Wars Society (ICWS) was founded in 1985, one year after Dewdney's original article. The ICWS published new standards for the Redcode language in 1986 and 1988, and proposed an update in 1994 that was never formally set as the new standard.[6] 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.[7]

Redcode

Redcode is the programming language used in Core War. It is executed by a virtual machine known as a Memory Array Redcode Simulator, or MARS. The design of Redcode is loosely based on actual CISC assembly languages of the early 1980s era, but contains several features not usually found in actual computer systems.

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:

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.

Key features

No numeric instruction values
The Redcode standard leaves the underlying representation of instruction codes undefined, and provides no means for programs to directly access it. Arithmetic operations may only be done on the two address fields contained in each instruction. The only operations supported on the instruction codes themselves are copying and comparison for equality.
No absolute addressing
All addresses are interpreted as offsets relative to the instruction containing them. Since the address space wraps around, it is in fact impossible for a Redcode program to determine its absolute address.
Low level multiprocessing
Instead of a single instruction pointer a Redcode simulator has a number of process queues, each containing a variable number of instruction pointers which the simulator cycles through. New processes may be added to the queue using the SPL instruction.

Other notable features of Redcode include:

No external access
Redcode and the MARS architecture provide no input or output functions. The simulator is a closed system, with the only input being the initial values of the memory and the process queues, and the only output being the outcome of the battle, i.e. which programs had surviving processes. Of course, the simulator may still allow external inspection and modification of the memory while the simulation is running.
Constant instruction length and time
Each Redcode instruction occupies exactly one memory slot and takes exactly one cycle to execute. The rate at which a process executes instructions, however, depends on the number of other processes in the queue, as processing time is shared equally.
Relatively few instructions
The earliest published version of Redcode had only eight instructions, while the currently used version has eighteen. However, Redcode supports a number of different addressing modes and (in later versions) instruction modifiers which increase the actual number of possible opcodes to several thousand.
All addresses are valid
All numbers in Redcode are treated as unsigned integers, and the maximum integer value is set to equal the number of memory locations minus one. Thus each integer is a valid address, and each memory location has exactly one valid address. Numbers that would fall outside the valid range are wrapped around according to the usual rules of modulo arithmetic.
Circular memory
As a consequence of the above and the lack of absolute addressing, the memory space (or core) appears to the programs in it as a circle with no definite start or end. A process that encounters no invalid or jump instructions can continue executing successive instructions endlessly, eventually returning to the instruction where it started.

Variants

A number of variants of Redcode exist. The earliest versions described by A. K. Dewdney differ in many respects from the later standards established by the International Core War Society, and could be considered a different, albeit related, language. The form of Redcode most commonly used today is based on a draft standard submitted to the ICWS in 1994 that was never formally accepted, as the ICWS had become effectively defunct around that time. Development of Redcode, however, has continued in an informal manner, chiefly via online forums such as the rec.games.corewar[8] newsgroup.

Non-game use

In principle, Redcode can be used for purposes other than Core War.[9][10]

Earliest versions

The earliest published description of Redcode is found in the Core War Guidelines[11] published in March 1984 by A. K. Dewdney and D. G. Jones. The language as described here differs significantly from the later variants, being in many ways closer to actual assembly languages of the era.

The Guidelines describe a set of only eight instructions, but it is stated that the earliest implementations of Redcode by Dewdney and Jones had a larger instruction set. Indeed, the language described in the Guidelines is best seen more as a basis for other developers to expand on than as an actual standard.

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.[12]

Core War Programming

Based on the understanding of Core War strategies, a programmer can create a warrior to achieve certain goals. The warrior is saved in ASCII format, with a ".red" extension. Revolutionary ideas come once in a while; most of the time, however, programmers utilize the published warriors to get some ideas. Using optimizers such as OptiMax or core-step optimizer tools, a more compact and efficient warrior can be created.

Warriors can also be generated by Genetic Algorithms or Genetic Programming. Programs that integrate this evolutionary technique are also known as Core War Evolvers. Several small and fast evolvers were introduced by Core War community but were more focused on tiny or nano Core War settings. The latest evolver with significant success was µGP[22] which produced nano and tiny KOTHs. Nevertheless, evolutionary strategy still need to prove its effectiveness in bigger hills (9000 or more cores).[23]

Variants

See also

References

  1. ^ Shoch and Hupp (CACM, vol. 25, no. 3, 1982) from PARC
  2. ^ Dewdney, A. K. (May 1984). "In the game called Core War hostile programs engage in a battle of bits.". Scientific American. http://corewar.co.uk/vogtmann/first.htm. Retrieved 2008-11-18. 
  3. ^ Jones, D. G.; Dewdney, A. K. (March 1984). "Core War Guidelines". http://corewar.co.uk/cwg.txt. Retrieved 19 November 2008. 
  4. ^ Dewdney, A. K. (March 1985). "A Core War bestiary of viruses, worms and other threats to computer memories.". Scientific American. http://corewar.co.uk/vogtmann/second.htm. Retrieved 2008-11-18. 
  5. ^ Dewdney, A. K. (January 1987). "A program called MICE nibbles its way to victory at the first Core War tournament.". Scientific American. http://corewar.co.uk/vogtmann/third.htm. Retrieved 2008-11-18. 
  6. ^ Doligez, Damien; Durham, Mark (8 November 1995). "Annotated Draft of the Proposed 1994 Core War Standard". http://corewar.co.uk/icws94.txt. Retrieved 19 November 2008. 
  7. ^ Metcalf, J. A.. "A Brief History of Corewar". http://corewar.co.uk/history.htm. Retrieved 19 November 2008. 
  8. ^ Groups.google.com
  9. ^ Forth Interpreter in Redcode FORTH interpreter in Redcode
  10. ^ Happy Numbers in Redcode Happy Numbers in Redcode
  11. ^ UsersS.obs.carnegiescience.edu
  12. ^ Mintarjo, W. "Intro to Art in '88: Paper - Stone - Scissors Trilogy."
  13. ^ Obs.carnegiescience.edu
  14. ^ Obs.carnegiescience.edu
  15. ^ The First International Core War Tournament
  16. ^ Obs.carnegiescience.edu
  17. ^ Replicators? - Phoenix & TimeScape source
  18. ^ Metcalf, J. A. "Anatomy of the Scanner, A Basic Introduction."
  19. ^ Obs.carnegiescience.edu
  20. ^ Obs.carnegiescience.edu
  21. ^ Obs.carnegiescience.edu
  22. ^ MicroGP MicroGP page from CAD Group, Politecnico di Torino
  23. ^ Bvowk, Sasha & Fizmo: An Evolutionary Approach Generates Human Competitive Corewar Programs
  24. ^ http://www.nanex.net/FlashCrash/CCircleDay.html

External links