Corewar documentation 1.0.0
Loading...
Searching...
No Matches
corewar.h
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** Corewar
4** File description:
5** The header of the corewar project
6*/
12#include "mymemory.h"
13#include "myop.h"
14
15#ifndef COREWAR_H_
16 #define COREWAR_H_
17
18// MACROS :
19
20
21
22// STRUCTURES :
23
28typedef struct cell_s {
29 int address; // The address of the cell
30 unsigned char value; // The value of the cell
31 char *owner; // The last champion who wrote in the cell
33
37typedef struct champion_s {
38 char *file_path; // The path of the file of the champion
39 char *prog_name; // The program name
40 char *comment; // The comment of the program
41 int prog_size; // The program size
42 int prog_number; // The program number
43 int address; // The address of the program in the arena
44 int reg[REG_NUMBER]; // The registers of the program
45 int cooldown; // The cooldown of the program
46 bool alive; // The alive status of the program
47 int program_counter; // The program counter of the program
48 bool carry; // The carry of the program
50
54typedef struct corewar_s {
55 size_t total_cycle; // The total of cycle done
56 int dump_cycle; // The cycle number to dump the memory
57 node_t *champions; // The champions list
58 node_t *arena; // The arena
60
67
72void free_corewar(void);
73
74
75
76// FUNCTIONS PROTOTYPES :
77
78 // Corewar functions :
79
85
90void free_corewar(void);
91
96int corewar(void);
97
98
99 // Parsing functions :
100
107int parse_args(int argc, char **argv);
108
109
110 // Champion functions :
111
117
123int champion_number_exist(int number);
124
129int analyse_champions(void);
130
131
132 // Read files functions :
133
141char *read_file(char *filepath, int size, int start);
142
143
144 // Header functions :
145
151int get_prog_size(char *header);
152
158int is_valid_magic(char *header);
159
160
161 // Arena functions :
162
167void build_arena(void);
168
173void display_arena(void);
174
175
176#endif /* COREWAR_H_ */
struct corewar_s corewar_t
The corewar structure.
int analyse_champions(void)
Analyse each champion files and complete the champion structure.
Definition champion.c:54
int get_prog_size(char *header)
Get the program size.
Definition header.c:37
int parse_args(int argc, char **argv)
Parse the arguments.
Definition parsing.c:104
corewar_t * get_corewar(void)
Get the corewar object.
Definition corewar.c:18
int champion_number_exist(int number)
Check if a champion number exist.
Definition champion.c:39
struct champion_s champion_t
The champion structure.
struct cell_s cell_t
The cell structure.
int is_valid_magic(char *header)
Check if the magic number is valid.
Definition header.c:19
void build_arena(void)
Build the arena.
Definition arena.c:40
void free_corewar(void)
Free the corewar structure.
Definition corewar.c:29
int get_next_champion_number(void)
Get the next champion number disponible.
Definition champion.c:18
int corewar(void)
The virtual machine of the corewar.
Definition corewar.c:46
char * read_file(char *filepath, int size, int start)
Read a file and return the content.
Definition read_file.c:21
void display_arena(void)
Display the arena.
Definition arena.c:68
The header file of the libmymemory.
The header file of the op.
The cell structure.
Definition corewar.h:28
The champion structure.
Definition corewar.h:37
The corewar structure.
Definition corewar.h:54
Definition mylist.h:43