diff options
Diffstat (limited to 'src/solvers/coord/solve.h')
| -rw-r--r-- | src/solvers/coord/solve.h | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index 2d040de..b372257 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -20,7 +20,6 @@ STATIC long long solve_coord_dispatch(oriented_cube_t, const char *, unsigned, | |||
| 20 | const unsigned char *, unsigned, char *, | 20 | const unsigned char *, unsigned, char *, |
| 21 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); | 21 | long long [static NISSY_SIZE_SOLVE_STATS], int (*)(void *), void *); |
| 22 | STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [static 1]); | 22 | STATIC bool coord_solution_admissible(const dfsarg_solve_coord_t [static 1]); |
| 23 | STATIC bool solve_coord_dfs_stop(const dfsarg_solve_coord_t [static 1]); | ||
| 24 | STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [static 1]); | 23 | STATIC bool coord_continue_onnormal(const dfsarg_solve_coord_t [static 1]); |
| 25 | STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [static 1]); | 24 | STATIC bool coord_continue_oninverse(const dfsarg_solve_coord_t [static 1]); |
| 26 | STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [static 1]); | 25 | STATIC int64_t solve_coord_dfs(dfsarg_solve_coord_t [static 1]); |
| @@ -39,34 +38,10 @@ coord_solution_admissible(const dfsarg_solve_coord_t arg[static 1]) | |||
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | STATIC bool | 40 | STATIC bool |
| 42 | solve_coord_dfs_stop(const dfsarg_solve_coord_t arg[static 1]) | ||
| 43 | { | ||
| 44 | bool hasnissed; | ||
| 45 | uint8_t n, pval; | ||
| 46 | uint64_t coord; | ||
| 47 | const cube_t *c; | ||
| 48 | |||
| 49 | n = arg->solution_moves->nmoves + arg->solution_moves->npremoves; | ||
| 50 | if (n >= arg->target_depth) | ||
| 51 | return true; | ||
| 52 | |||
| 53 | hasnissed = arg->solution_moves->nmoves > 0 && | ||
| 54 | arg->solution_moves->npremoves > 0; | ||
| 55 | if (!hasnissed && (arg->nissflag & NISSY_NISSFLAG_MIXED)) | ||
| 56 | return false; | ||
| 57 | |||
| 58 | c = arg->lastisnormal ? &arg->cube : &arg->inverse; | ||
| 59 | |||
| 60 | coord = arg->coord->coord(*c, arg->coord_data); | ||
| 61 | pval = get_coord_pval(arg->coord, arg->ptable, coord); | ||
| 62 | |||
| 63 | return n + pval > arg->target_depth; | ||
| 64 | } | ||
| 65 | |||
| 66 | STATIC bool | ||
| 67 | coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) | 41 | coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) |
| 68 | { | 42 | { |
| 69 | uint8_t flag, nn, ni, swbound_n, swbound_i; | 43 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; |
| 44 | uint64_t coord; | ||
| 70 | 45 | ||
| 71 | flag = arg->nissflag; | 46 | flag = arg->nissflag; |
| 72 | nn = arg->solution_moves->nmoves; | 47 | nn = arg->solution_moves->nmoves; |
| @@ -82,6 +57,14 @@ coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) | |||
| 82 | if (nn + ni == 0) | 57 | if (nn + ni == 0) |
| 83 | return true; | 58 | return true; |
| 84 | 59 | ||
| 60 | /* Pruning table check */ | ||
| 61 | if (!(flag & NISSY_NISSFLAG_MIXED) || ni != 0) { | ||
| 62 | coord = arg->coord->coord(arg->cube, arg->coord_data); | ||
| 63 | pval = get_coord_pval(arg->coord, arg->ptable, coord); | ||
| 64 | if (nn + ni + pval > arg->target_depth) | ||
| 65 | return false; | ||
| 66 | } | ||
| 67 | |||
| 85 | if (arg->lastisnormal) { | 68 | if (arg->lastisnormal) { |
| 86 | /* Can continue if we have already switched */ | 69 | /* Can continue if we have already switched */ |
| 87 | if (ni > 0) | 70 | if (ni > 0) |
| @@ -111,7 +94,8 @@ coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1]) | |||
| 111 | STATIC bool | 94 | STATIC bool |
| 112 | coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) | 95 | coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) |
| 113 | { | 96 | { |
| 114 | uint8_t flag, nn, ni, swbound_n, swbound_i; | 97 | uint8_t flag, nn, ni, swbound_n, swbound_i, pval; |
| 98 | uint64_t coord; | ||
| 115 | 99 | ||
| 116 | flag = arg->nissflag; | 100 | flag = arg->nissflag; |
| 117 | nn = arg->solution_moves->nmoves; | 101 | nn = arg->solution_moves->nmoves; |
| @@ -127,6 +111,14 @@ coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1]) | |||
| 127 | if (nn + ni == 0) | 111 | if (nn + ni == 0) |
| 128 | return true; | 112 | return true; |
| 129 | 113 | ||
| 114 | /* Pruning table check */ | ||
| 115 | if (!(flag & NISSY_NISSFLAG_MIXED) || nn != 0) { | ||
| 116 | coord = arg->coord->coord(arg->inverse, arg->coord_data); | ||
| 117 | pval = get_coord_pval(arg->coord, arg->ptable, coord); | ||
| 118 | if (nn + ni + pval > arg->target_depth) | ||
| 119 | return false; | ||
| 120 | } | ||
| 121 | |||
| 130 | if (!arg->lastisnormal) { | 122 | if (!arg->lastisnormal) { |
| 131 | /* Can continue if we have already switched */ | 123 | /* Can continue if we have already switched */ |
| 132 | if (nn > 0) | 124 | if (nn > 0) |
| @@ -157,7 +149,7 @@ STATIC int64_t | |||
| 157 | solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | 149 | solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) |
| 158 | { | 150 | { |
| 159 | bool lastbackup; | 151 | bool lastbackup; |
| 160 | uint8_t m, l, nnbackup, nibackup; | 152 | uint8_t m, l, nnbackup, nibackup, nmoves; |
| 161 | uint32_t mm; | 153 | uint32_t mm; |
| 162 | uint64_t coord; | 154 | uint64_t coord; |
| 163 | int64_t n, ret; | 155 | int64_t n, ret; |
| @@ -171,14 +163,15 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 171 | arg->solution_settings, arg->solution_list); | 163 | arg->solution_settings, arg->solution_list); |
| 172 | } | 164 | } |
| 173 | 165 | ||
| 174 | if (solve_coord_dfs_stop(arg)) | ||
| 175 | return 0; | ||
| 176 | |||
| 177 | backup_cube = arg->cube; | 166 | backup_cube = arg->cube; |
| 178 | backup_inverse = arg->inverse; | 167 | backup_inverse = arg->inverse; |
| 179 | lastbackup = arg->lastisnormal; | 168 | lastbackup = arg->lastisnormal; |
| 180 | nnbackup = arg->solution_moves->nmoves; | 169 | nnbackup = arg->solution_moves->nmoves; |
| 181 | nibackup = arg->solution_moves->npremoves; | 170 | nibackup = arg->solution_moves->npremoves; |
| 171 | nmoves = nnbackup + nibackup; | ||
| 172 | |||
| 173 | if (nmoves >= arg->target_depth) | ||
| 174 | return 0; | ||
| 182 | 175 | ||
| 183 | ret = 0; | 176 | ret = 0; |
| 184 | if (coord_continue_onnormal(arg)) { | 177 | if (coord_continue_onnormal(arg)) { |
