push_swap/include/app/best_move_inner.h
2024-01-29 22:45:54 +01:00

69 lines
2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* best_move_inner.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/29 21:31:42 by maiboyer #+# #+# */
/* Updated: 2024/01/29 21:50:15 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef BEST_MOVE_INNER_H
#define BEST_MOVE_INNER_H
#include "app/best_move.h"
#include "app/rotate.h"
#include "app/state.h"
#include "me/types.h"
#include "me/vec/vec_i64.h"
typedef void (*t_banana_func)(void *);
typedef t_usize (*t_iter_pos_func)(t_vec_i64 *);
enum e_best_move_stack_selector
{
MAIN,
OTHER,
BOTH,
};
typedef struct s_best_move_args_but_better
{
t_best_move_args data;
t_vec_i64 *main_stack;
t_vec_i64 *other_stack;
t_iter_pos_func iter_func;
} t_best_move_args_but_better;
static inline t_banana_func choose_rot(enum e_best_move_stack_selector ty,
t_best_move_args_but_better *data,
t_rotation *rot)
{
if (ty == MAIN)
{
if (rot->direction == FORWARD)
return (data->data.main.forward);
else
return (data->data.main.reverse);
}
else if (ty == OTHER)
{
if (rot->direction == FORWARD)
return (data->data.other.forward);
else
return (data->data.other.reverse);
}
else if (ty == BOTH)
{
if (rot->direction == FORWARD)
return (data->data.both.forward);
else
return (data->data.both.reverse);
}
return (NULL);
}
#endif /* BEST_MOVE_INNER_H */