Corewar

  • Corewar is a game, a very special game. It consists in making small programs fight in a virtual machine.
  • The project is split in two main parts :
    • The assembler : It will allow you to write programs destined to fight. It will need to understand the assembly language, and generate a binary programs that can be interpreted by the virtual machine.
    • The virtual machine : It will house the binary programs (the champions) and provide them with a standard execution environment, It offers a lot of features useful to the fight.

Dependencies

sdl2 sdl2_ttf sdl2_image sdl2_mixer

Compilation & Usage

git clone https://www.github.com/knona/corewar.git
cd corewar/
make

Then to use asm :

cd ./asm/
./asm champ.s

And to use the VM :

cd ./corewar/
./corewar [-vg] [-d nbr_cycles] [[-n number] champion1.cor]

Our VM offers various options :

option
-v activates the verbose mode
-g launches the graphical interface
-d nbr_cycles dumps the memory at nbr_cycles and exits the game
-n number manually assigns the number of the champ ID

Graphical Interface

Our project comes with a SDL-made tron-inspired glossy and classy GUI to fully enjoy the fights. Furthermore it has a memory and processes explorer which will allow you to understand what's really happening inside the VM. It can be really helpful since one of the major difficulties of this project is to figure out how the virtual machine works.
Plus the GUI is kind of groovy. So, while you're working on corewar you can also develop your dance skills! 💃🕺

key
arrow up speed up the game (limit at X64)
arrow down slow down the game (limit at 1/64)
space pause the game and enter the explorer mode
esc exit the game
mouse the mouse is used to query informations about a memory location or a process
scroll in the processes explorer, scroll is used to navigate through the different processes on the same memory location
mouse click in the processes explorer, click is used to view the next page of informations about a process

Screenshots

Memory explorer

Memory explorer

Process explorer (general)

Process explorer (general)

Process explorer (registers)

Process explorer (registers)