Epitech project — 2023 (1st year) Made by Louis Rollet, Guillaume Tran, Théodore Billotte and Marton Roux.
Corewar is a game in which several assembly programs, called champions, fight
inside the shared memory of a virtual machine. Each champion is a process running
its own bytecode; the last champion still able to signal that it is alive — by
executing the live instruction — wins the round.
The project is split in two parts:
- an assembler (
asm) that compiles a champion written in the Corewar assembly language (.s) into executable bytecode (.cor); - the virtual machine (
corewar) that loads the champions into a circular shared-memory arena and runs them concurrently until a winner emerges.
A single make at the root of the repository builds everything (the asm and
corewar binaries and the internal list library):
make # build asm and corewar
make re # rebuild from scratch
make clean # remove object files
make fclean # remove object files and binariesCompile a champion's source into a .cor file:
./asm champion.s # produces champion.corLoad one to four champions into the virtual machine:
./corewar champion.cor [champion2.cor ...]Available flags:
| Flag | Description |
|---|---|
-n <id> |
Set the number of the champion that follows. |
-a <addr> |
Set the load address of the champion that follows. |
-dump <n> |
Dump the memory in hexadecimal after n cycles, then stop. |
-d |
Enable the live graphical visualizer (bonus, see below). |
-h |
Display the help message. |
Example:
./corewar -n 1 -a 100 champion.cor -dump 0B champion2.corA champion wins when it is the last one alive — i.e. the last process to have
executed the live instruction. A champion loses once it has no running process
left, or once its processes stop declaring themselves alive.
Running the VM with the -d flag opens a graphical visualizer that shows the
memory arena and the champions fighting over it in real time:
./corewar -d champion.cor champion.corUnit tests (Criterion) can be run with:
make tests_run