h48

A prototype for an optimal Rubik's cube solver, work in progress.
git clone https://git.tronto.net/h48
Download | Log | Files | Refs | README | LICENSE

commit 4abb800c4b4f3a509c07821ade8d34e3699bdf10
parent 754e632241859b224497ee4e0239670d5d90759f
Author: enricotenuti <tenutz_27@outlook.it>
Date:   Fri, 30 Aug 2024 17:47:48 +0200

format fix

Diffstat:
Msrc/core/moves.h | 7++++---
Msrc/solvers/h48/solve.h | 31+++++++++++++++----------------
2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/core/moves.h b/src/core/moves.h @@ -12,6 +12,7 @@ _static uint32_t allowednextmoveH48(uint8_t *, uint8_t, uint32_t); _static_inline uint8_t inverse_trans(uint8_t); _static_inline uint8_t movebase(uint8_t); _static_inline uint8_t moveaxis(uint8_t); +_static_inline uint32_t disable_moves(uint32_t, uint8_t); _static cube_t move(cube_t, uint8_t); _static cube_t premove(cube_t, uint8_t); @@ -43,10 +44,10 @@ allowednextmove(uint8_t *moves, uint8_t n) return axis[1] != axis[2] || base[0] != base[2]; } -static uint32_t +_static_inline uint32_t disable_moves(uint32_t current_result, uint8_t base_index) { - return current_result & ~((1 << base_index) | (1 << (base_index + 1)) | (1 << (base_index + 2))); + return current_result & ~(7 << base_index); } _static uint32_t @@ -144,7 +145,7 @@ move(cube_t c, uint8_t m) _static cube_t premove(cube_t c, uint8_t m) { - switch (m) { + switch (m) { case _move_U: return _premove(U3, c); case _move_U2: diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h @@ -29,8 +29,7 @@ typedef struct { _static void solve_h48_appendsolution(dfsarg_solveh48_t *); _static_inline bool solve_h48_stop(dfsarg_solveh48_t *); _static int64_t solve_h48_dfs(dfsarg_solveh48_t *); -_static int64_t solve_h48( - cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); +_static int64_t solve_h48(cube_t, int8_t, int8_t, int8_t, uint8_t, uint8_t, const void *, char *); _static int64_t solve_h48stats_dfs(dfsarg_solveh48stats_t *); _static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); @@ -38,26 +37,26 @@ _static int64_t solve_h48stats(cube_t, int8_t, const void *, char [static 12]); _static void solve_h48_appendsolution(dfsarg_solveh48_t *arg) { - int strl; - char *solution = *arg->nextsol; + int strl; + char *solution = *arg->nextsol; - strl = writemoves(arg->moves, arg->nmoves, *arg->nextsol); - *arg->nextsol += strl; + strl = writemoves(arg->moves, arg->nmoves, *arg->nextsol); + *arg->nextsol += strl; - if (arg->npremoves) { - **arg->nextsol = ' '; - (*arg->nextsol)++; + if (arg->npremoves) { + **arg->nextsol = ' '; + (*arg->nextsol)++; uint8_t* invertedpremoves = invertpremoves(arg->premoves, arg->npremoves); - strl = writemoves(invertedpremoves, arg->npremoves, *arg->nextsol); + strl = writemoves(invertedpremoves, arg->npremoves, *arg->nextsol); free(invertedpremoves); - *arg->nextsol += strl; - } - LOG("Solution found: %s\n", solution); + *arg->nextsol += strl; + } + LOG("Solution found: %s\n", solution); - **arg->nextsol = '\n'; - (*arg->nextsol)++; - (*arg->nsols)++; + **arg->nextsol = '\n'; + (*arg->nextsol)++; + (*arg->nsols)++; } _static_inline bool