-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
65 lines (56 loc) · 1.05 KB
/
main.c
File metadata and controls
65 lines (56 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
** main.c for lem_in in /home/thibaud/rendu/lem_in
**
** Made by thixbaud
** Login <thibaud@epitech.net>
**
** Started on Sat Apr 12 23:46:01 2014 thibaud
** Last update Sat May 3 03:46:53 2014 thibaud
*/
#include "lem_in.h"
int main(void)
{
t_all *p;
p = parse();
my_show_map(p->map);
algo(p->arc, p->room, p->ants);
sfree(p->map);
free_list(p->room);
free_arc(p->arc);
free(p);
return (0);
}
void my_show_map(char **map)
{
int i;
i = 0;
while (map != NULL && map[i])
printf("%s\n", map[i++]);
}
void algo(t_arc *arc, t_lem *list, int ants)
{
t_graphe *graphe;
t_way *ways;
ways = NULL;
graphe = new_graphe();
while (arc)
{
insert_arc(graphe, arc->first_room, arc->second_room);
arc = arc->next;
}
ways = get_ways(graphe, 1, my_list_size(list), ways);
free_graphe(graphe);
fill_ways(ways, ants);
run_lem_in(ways, list);
free_ways(ways);
}
void no_map()
{
printf("No map.\n");
exit(EXIT_FAILURE);
}
void no_arc()
{
printf("No rooms are linked.\n");
exit(EXIT_FAILURE);
}