Corewar

A 42 Project where me and my team of two have to create a working Corewar Virtual Machine, Redcode assembler and our own Corewar champion!

Core War is a 1984 programming game created by D. G. Jones and A. K. Dewdney in which two or more battle programs (called “warriors”) compete for control of a virtual computer. These battle programs are written in an abstract assembly language called Redcode. At the beginning of a game, each battle program is loaded into memory at a random location, after which each program executes one instruction in turn. The goal of the game is to cause the processes of opposing programs to terminate (which happens if they do not execute a live instruction with CYCLES_TO_DIE), leaving the victorious program in possession of the machine’s memory.

image below is not our own visualizer

Corewar

Getting Started

Downloading

git clone git@github.com:chimpansiets/Kooroorlog.git

Installing

Running ‘make’ in the directory will install all dependencies and create two executables.

  • asm (for the assembler, which compiles .s files into .cor files)
  • corewar (for the virtual machine, which runs the main program)
make

Running

Assembler

First off you want to compile your champions from pseudo-assembly (.s) into the corresponding Corewar language.

./asm redcode_file.s

Corewar

The main executable handles up to 4 champions. To see how the actual corewar operates, please reference the corewar.pdf.

./corewar [-dump nbr_cycles] [[-n number] champion1.cor] ...

There are many options, including (again, read corewar.pdf for more info):

-dump number		To dump memory after 'number' of cycles.
-s			To set the optional speed of the game (1 is fast, 100 is slow)
-viz			To display the visualizer.
-n playernum champion	To set the player number of the Champion.
-a / -activity		To show an activity monitor, which displays the number of processes being executed in the current cycle.
-r / -rainbow [1 - 10]	To enable rainbow mode, with optional speed of 1 to 10.

Authors

License

MIT License. Just kidding, I actually have no idea what license.

Written on February 1, 2020