-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_best_coord.c
49 lines (45 loc) · 1.38 KB
/
find_best_coord.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* find_best_coord.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: averemiy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/05/13 16:38:33 by averemiy #+# #+# */
/* Updated: 2018/05/21 14:28:55 by averemiy ### ########.fr */
/* */
/* ************************************************************************** */
#include "filler.h"
static void print_cord(int x, int y)
{
ft_putnbr(y);
write(1, " ", 1);
ft_putnbr(x);
write(1, "\n", 1);
}
void find_best_coord(t_filler *f)
{
int i;
int j;
int test;
i = -1;
test = 0;
while (++i < f->map_y)
{
j = -1;
while (++j < f->map_x)
{
if (push_in_map(i, j, f))
{
test = find_distance(i, j, f);
if (f->distance == 0 || test < f->distance)
{
f->distance = test;
f->res_x = j;
f->res_y = i;
}
}
}
}
print_cord(f->res_x, f->res_y);
}