From 5001e89f399dbd74dab054743f95c752b6f04bc6 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Mon, 25 Apr 2022 00:30:06 +0200 Subject: Working algorithm, its faster tan light! --- src/cube.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/cube.h') diff --git a/src/cube.h b/src/cube.h index c050d22..ccc83d2 100644 --- a/src/cube.h +++ b/src/cube.h @@ -158,8 +158,7 @@ static const rot_f rot_func[] = { rotation_d, rotation_f, rotation_b, - rotation_rp, - rotation_lp, + rotation_rp, rotation_lp, rotation_up, rotation_dp, rotation_fp, @@ -184,6 +183,13 @@ static void perform_rotations(cube_t *cube, rotations rots[]) { } } +static rotations reverse_rotation(rotations rot) { + int ret = (int)rot; + if ((int)rot < 6) ret = (int)rot + 6; + if ((int)rot >= 6 && rot < 12) ret = (int)rot - 6; + return (rotations)ret; +} + /******************************************************************************/ /* Parsing rotations from input ***********************************************/ @@ -222,7 +228,7 @@ static rotations* parse_scramble(char **str) { ssize_t i = 0; char *rot_str = str[0]; while (rot_str) { - printf("token: %s\n", rot_str); + // printf("token: %s\n", rot_str); rot_str = str[++sz]; } @@ -372,7 +378,7 @@ static void dump_cube_grid(cube_t *cube) { typedef uint32_t rot_cnt_t; #define build_rot_cnt(rot, cnt) (rot_cnt_t)(((uint32_t)(rot) << 16)|(cnt)) -#define get_rot(rot_cnt) (((uint32_t)(rot_cnt))>>16) +#define get_rot(rot_cnt) (rotations)(((uint32_t)(rot_cnt))>>16) #define get_cnt(rot_cnt) (uint32_t)((rot_cnt) & 0xffff) KHASH_INIT(cube, cube_t, rot_cnt_t, 1, kh_cube_hash_func, kh_cube_hash_equal) -- cgit v1.2.3