-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec_move.c
65 lines (61 loc) · 2.15 KB
/
exec_move.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
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_move.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbourgea <rbourgea@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/04/14 18:13:39 by rbourgea #+# #+# */
/* Updated: 2021/04/14 18:40:43 by rbourgea ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void execute_best_move_b_2(t_data *data, int i)
{
if (data->relative == 1)
data->lock_b = 0;
else if (data->relative == 2)
data->lock_b = 1;
else if (data->relative == 3)
data->lock_a = 1;
else if (data->relative == 4)
data->lock_a = 0;
data->bool_first_move = 0;
while (i < data->rotation)
{
if (data->direction > 0)
rbw(data);
else
rrbw(data);
i++;
}
data->last_relative = data->relative;
paw(data);
}
void execute_best_move_b(t_data *data, int min, int max)
{
int i;
i = 0;
if (!data->bool_first_move)
{
if (data->list[data->spliter - 1] < data->val &&
data->list[data->spliter - 1] >= min &&
data->list[data->spliter - 1] < max)
raw_optimize(data, &i);
if (data->list[data->spliter - 1] < data->val &&
data->list[data->spliter - 1] >= min &&
data->list[data->spliter - 1] < max)
raw_optimize(data, &i);
if (data->list[data->spliter - 1] < data->val &&
data->list[data->spliter - 1] >= min &&
data->list[data->spliter - 1] < max)
raw_optimize(data, &i);
if (data->list[0] > data->val && data->list[0] >= min
&& data->list[0] < max)
rraw_optimize(data, &i);
if (data->list[0] > data->val && data->list[0] >= min
&& data->list[0] < max)
rraw_optimize(data, &i);
}
execute_best_move_b_2(data, i);
}