-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_lemin_3.c
53 lines (47 loc) · 918 Bytes
/
print_lemin_3.c
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
#include "lem_in.h"
void move_old_ants_1(t_route **route, t_lemin **lemin)
{
t_route *r;
r = (*route);
r->next->ant = r->ant;
r->ant = 0;
print_ants(&r->next->ant, r->next->room, lemin, 1);
// ft_printf("L%d-%s ", r->next->ant, r->next->room);
check_ant_in_end(&(r->next), lemin);
}
void move_old_ants(t_routes **routes, t_lemin **lemin)
{
t_routes *rs;
t_route *r;
rs = (*routes);
while (rs)
{
r = rs->route->next;
if (r->ant)
{
while (r->next && r->next->ant)
r = r->next;
move_old_ants_1(&r, lemin);
rs = rs->next;
(!rs) ? rs = (*routes) : 0;
}
else
{
if (!rs->next)
return ;
if (rs->next->route->next->ant)
rs = rs->next;
else
break ;
}
}
}
void print_start_end(t_routes **routes, t_lemin **lemin, int ants)
{
while (ants <= (*lemin)->ants)
{
ft_printf(BLU"L%d-%s "END, ants, (*routes)->route->next->room);
ants++;
}
ft_printf("\n");
}