What is Corewar ?
The ASM, for assembler, is one of the two .exe in the project.
It’s a compiler, his goal is to convert “.s” file, in a school made
assembly language (see below) into binaries files “.cor” files that
are readable by the Virtual Machine.
There’s two parts to parse for the asm, the header and then the
prog.
In the prog differents kinds of informations can be found,
instructions, labels, arguments.
To manage with that we’re using a hash table, also we’ve implemented
a code span error management, based on rust one.
The virtual machine, the second .exe, is the arena, where everything
takes sense, rules that found the games are checked by the vm.
Each .cor given by args to the vm are proportionally loaded in the
memory.
Processes are reading the circular memory and applying the
instructions they receive.
The main instruction is “live: champion’s number", if the num is not
valid it goes to the void.
A process dies if he doesn’t call a live in CYCLE_TO_DIE cycles.
During a cycle all processes are playing once time.
When all processes are dead, last calling live champions is checked
to elect a winner.
Each champions have the same goal, to stay alive by calling the live
instruction for their own player's number, by the way the player's
number is given either by the user or randomly.
There is a real distinction between champions and processes,
processes are independents of champions.
At the begining of the game a process spawns at the start of each
champions’prog loaded in the memory.
But they’re not assigned to their starting champ, they might read an
enemy prog later during the game.
In .s file you can find 4 kinds of instructions: Movement (zjmp),
writing (sti st ..), loading (fork ld ldi ..), operators (add sub
..).