A-maze-D documentation 1.0.0
Loading...
Searching...
No Matches
amazed.h
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2024
3** amazed
4** File description:
5** The amazed.h
6*/
13#include "mymemory.h"
14
15#ifndef AMAZED_H_
16 #define AMAZED_H_
17
18/* Projects structures */
19
20typedef struct robot_s {
21 void *room;
22 int id;
23 struct robot_s *prev;
24 struct robot_s *next;
25} robot_t;
26
27typedef struct position_s {
28 int x;
29 int y;
31
32typedef struct door_s {
33 void *room;
34 struct door_s *next_door;
35} door_t;
36
37typedef struct room_s {
38 char *room_name;
39 position_t position;
40 robot_t *robot;
41 int waiting;
42 int visited;
43 struct door_s *doors_list;
44 struct room_s *prev;
45 struct room_s *next;
46} room_t;
47
48typedef struct path_s {
49 room_t *room;
50 int g_score; // Coût depuis le noeuds de départ jusqu'à ce node
51 int f_score; // Coût total estimé depuis le départ
52 // jusqu'à l'arrivée en passant par ce node
53 struct path_s *prev; // Noeud précédent dans le chemin optimal
54} path_t;
55
56typedef struct path_info_s {
57 room_t *start;
58 room_t *end;
59 my_bool_t only_free_room;
60 int start_val;
61 int nb_paths;
62 linked_list_t *possible_paths;
63 path_t *tmp;
65
66typedef struct robot_path_s {
67 path_t *path_wait;
68 path_t *path;
69 int path_wait_cost;
70 int path_cost;
71 room_t *room;
73
74typedef struct maze_s {
75 int nb_robots;
76 robot_t *robots_list;
77 room_t *rooms_list;
78 room_t *start;
79 room_t *end;
80 int start_find;
81 int end_find;
82 int return_value;
83} maze_t;
84
85
86
87/* Projects functions */
88
89/* Parsing */
90void remove_comment(char *line);
91void *return_and_free(maze_t *maze, linked_list_t **file_content, char **line);
92int add_door(maze_t *maze, char *line);
93int add_room(maze_t *maze, char **line);
94int check_line(maze_t *maze, char **line, int line_index);
95int error_handling(maze_t *maze, char **line, int line_index);
96int get_robots_numbers(maze_t *maze, linked_list_t **file_content);
97int next_error_handling(maze_t *maze, char **line, int line_index);
98int next_line(maze_t *maze, char **line);
99int check_valid_maze(maze_t *maze);
100
101/* Init maze */
102maze_t *init_maze(void);
103robot_t *create_robots_list(room_t *start, int nb_robots);
104
105/* Path finding */
106void display_path(path_t *path);
107path_t *get_best_path(room_t *start, room_t *end, my_bool_t only_free_room);
108
109/* Robots */
110void remove_robots_at_end(room_t *end, robot_t **robots);
111void reset_rooms(room_t *rooms);
112void move_robots(maze_t *maze);
113
114/* Exec amazed */
115void amazed(maze_t *maze);
116
117#endif /* AMAZED_H_ */
path_t * get_best_path(room_t *start, room_t *end, my_bool_t only_free_room)
Get the best path between two rooms.
Definition path_finding.c:113
void reset_rooms(room_t *rooms)
Reset the visited attribute of each rooms.
Definition rooms.c:86
robot_t * create_robots_list(room_t *start, int nb_robots)
Create a list of robots.
Definition robots.c:22
void move_robots(maze_t *maze)
Move the robots.
Definition robots.c:140
void display_path(path_t *path)
Display the path found.
Definition path_finding.c:142
void remove_robots_at_end(room_t *end, robot_t **robots)
Remove the robots at the end of the maze.
Definition robots.c:49
Definition amazed.h:32
Definition mylist.h:34
Definition amazed.h:74
Definition amazed.h:56
Definition amazed.h:48
Definition amazed.h:27
Definition amazed.h:66
Definition amazed.h:20
Definition amazed.h:37