IsadoraRebelo / CoreWar

This project involves creating a virtual arena, and having simplistic-language programs fight each other.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Summary:

In this project, you will create a virtual “arena” in which programs will fight against one another (the “Champions”). You will also create an assembler to compile those Champions as well as a Champion to show the world that you can create life from coffee.

Introduction:

Corewar is a very peculiar game. It’s about bringing “players” together around a “virtual machine”, which will load some “champions” who will fight against one another with the support of “processes”, with the objective being for these champions to stay “alive”.

The processes are executed sequentially within the same virtual machine and memory space. They can therefore, among other things, write and rewrite on top of each others so to corrupt one another, force the others to execute instructions that can damage them.

The game ends when all the processes are dead. The winner is the last player reported to be “alive”.

General Considerations:

  • The last project of Codam (42 Network School) in the ai branch, the full PDF can be found in this repository.
  • Group project (three people).
  • Makefile commands:
make
make re
make clean
make fclean

Assembler:

Your virtual machine will execute a machine code (or “bytecode”) that will be generated by your assembler. The assembler (the program) will get a file written in assembly language as argument and generate a champion that will be understood by the virtual machine.

In this reposatory the .s files can be found in the Champs folder. The assembler will create a .cor file that can be found in the same folder.

  • Usage:
./asm [ champs/file.s ]

The Virtual Machine:

Inside the Vm, the champions are charged within the memory so that they can space out evenly their entry points. The virtual machine will create a memory space dedicated to the combat of the players, it will then load each champion and their associated processes and execute them sequentially until they die.

The VM can take between 1 and 4 players. You can use a player more then once.

  • Usage:
./corewar_vm [ champs/file.cor champs/file.cor ]

Flags:

-v : Use this flag to visualize the battle.
-dump : At the end of nbr_cycles of executions, the flaf willdump the memory on the standard output and quit the game.

-n : sets the number of the next player. If non-existent, the player will have the next available number in the order of the parameters. The last player will have the first process in the order of execution.

Controls to the visualizer:

Space to stop and continue the process.
S to go to the next movement.

Images:

alt text

About

This project involves creating a virtual arena, and having simplistic-language programs fight each other.


Languages

Language:C 87.8%Language:Assembly 10.6%Language:Makefile 1.7%