From 10b65003102675bd19c0e5174ff249be2a163bc7 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Wed, 11 Sep 2024 19:48:57 +0200 Subject: Simplified solver --- src/solvers/h48/gendata_h48.h | 3 ++- src/solvers/h48/solve.h | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/solvers/h48') diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index f276eca..066c650 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h @@ -152,13 +152,14 @@ gendata_h48(gendata_h48_arg_t *arg) goto gendata_h48_error; } - if (arg->buf == 0) + if (arg->buf == NULL) goto gendata_h48_return_size; if (!readtableinfo(arg->buf, &cocsepinfo)) { LOG("gendata_h48: could not read info for cocsep table\n"); goto gendata_h48_error; } + cocsepinfo.next = cocsepsize; if (!writetableinfo(&cocsepinfo, arg->buf)) { LOG("gendata_h48: could not write info for cocsep table" diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 26847b2..4bf55ca 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -31,7 +31,7 @@ STATIC uint32_t allowednextmove_h48(uint8_t *, uint8_t, uint32_t); 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, 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]); @@ -176,22 +176,26 @@ solve_h48( int8_t minmoves, int8_t maxmoves, int8_t maxsolutions, - uint8_t h, - uint8_t k, const void *data, char *solutions ) { int64_t nsols; dfsarg_solveh48_t arg; + tableinfo_t info; + + if(!readtableinfo_n(data, 2, &info)) { + LOG("solve_h48: error reading table\n"); + return 0; + } arg = (dfsarg_solveh48_t) { .cube = cube, .inverse = inverse(cube), .nsols = &nsols, .maxsolutions = maxsolutions, - .h = h, - .k = k, + .h = info.h48h, + .k = info.bits, .cocsepdata = get_cocsepdata_ptr(data), .h48data = get_h48data_ptr(data), .nextsol = &solutions -- cgit v1.3