diff options
Diffstat (limited to 'src/solve.c')
| -rw-r--r-- | src/solve.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/solve.c b/src/solve.c index 39437fb..5581964 100644 --- a/src/solve.c +++ b/src/solve.c | |||
| @@ -11,11 +11,11 @@ static bool dfs_check_solved(DfsArg *arg); | |||
| 11 | static bool dfs_switch(DfsArg *arg); | 11 | static bool dfs_switch(DfsArg *arg); |
| 12 | static void dfs_niss(DfsArg *arg); | 12 | static void dfs_niss(DfsArg *arg); |
| 13 | static bool dfs_stop(DfsArg *arg); | 13 | static bool dfs_stop(DfsArg *arg); |
| 14 | static bool dfs_useless_niss(DfsArg *arg); | ||
| 14 | static void * instance_thread(void *arg); | 15 | static void * instance_thread(void *arg); |
| 15 | static void invert_branch(DfsArg *arg); | 16 | static void invert_branch(DfsArg *arg); |
| 16 | static void multidfs(Cube c, Trans t, Step *s, SolveOptions *opts, | 17 | static void multidfs(Cube c, Trans t, Step *s, SolveOptions *opts, |
| 17 | AlgList *sols, int d); | 18 | AlgList *sols, int d); |
| 18 | static bool niss_makes_sense(DfsArg *arg); | ||
| 19 | static bool solvestop(int d, int op, SolveOptions *opts, AlgList *sols); | 19 | static bool solvestop(int d, int op, SolveOptions *opts, AlgList *sols); |
| 20 | 20 | ||
| 21 | /* Local functions ***********************************************************/ | 21 | /* Local functions ***********************************************************/ |
| @@ -97,7 +97,7 @@ dfs(DfsArg *arg) | |||
| 97 | invert_branch(arg); | 97 | invert_branch(arg); |
| 98 | dfs_branch(arg); | 98 | dfs_branch(arg); |
| 99 | 99 | ||
| 100 | if (arg->opts->nisstype == NISS && !arg->niss && niss_makes_sense(arg)) | 100 | if (arg->opts->nisstype == NISS && !arg->niss && !arg->step->final) |
| 101 | dfs_niss(arg); | 101 | dfs_niss(arg); |
| 102 | 102 | ||
| 103 | if (sw) | 103 | if (sw) |
| @@ -139,7 +139,7 @@ dfs_check_solved(DfsArg *arg) | |||
| 139 | if (!arg->step->is_done(arg->cube)) | 139 | if (!arg->step->is_done(arg->cube)) |
| 140 | return false; | 140 | return false; |
| 141 | 141 | ||
| 142 | if (arg->current_alg->len == arg->d) { | 142 | if (arg->current_alg->len == arg->d && !dfs_useless_niss(arg)) { |
| 143 | if ((arg->step->is_valid(arg->current_alg) || arg->opts->all) | 143 | if ((arg->step->is_valid(arg->current_alg) || arg->opts->all) |
| 144 | && (!arg->step->final || !cancel_niss(arg))) { | 144 | && (!arg->step->final || !cancel_niss(arg))) { |
| 145 | 145 | ||
| @@ -233,6 +233,20 @@ dfs_switch(DfsArg *arg) | |||
| 233 | return bi < bn; | 233 | return bi < bn; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | static bool | ||
| 237 | dfs_useless_niss(DfsArg *arg) | ||
| 238 | { | ||
| 239 | Cube c; | ||
| 240 | Move m = arg->last1inv; | ||
| 241 | |||
| 242 | if (m == NULLMOVE || !arg->niss) | ||
| 243 | return false; | ||
| 244 | |||
| 245 | c = apply_move(inverse_move(m), arg->cube); | ||
| 246 | |||
| 247 | return arg->step->is_done(c); | ||
| 248 | } | ||
| 249 | |||
| 236 | static void * | 250 | static void * |
| 237 | instance_thread(void *arg) | 251 | instance_thread(void *arg) |
| 238 | { | 252 | { |
| @@ -363,15 +377,6 @@ multidfs(Cube c, Trans tr, Step *s, SolveOptions *opts, AlgList *sols, int d) | |||
| 363 | } | 377 | } |
| 364 | 378 | ||
| 365 | static bool | 379 | static bool |
| 366 | niss_makes_sense(DfsArg *arg) | ||
| 367 | { | ||
| 368 | Cube testcube; | ||
| 369 | |||
| 370 | testcube = apply_move(inverse_move(arg->last1), (Cube){0}); | ||
| 371 | return arg->current_alg->len == 0 || !arg->step->is_done(testcube); | ||
| 372 | } | ||
| 373 | |||
| 374 | static bool | ||
| 375 | solvestop(int d, int op, SolveOptions *opts, AlgList *sols) | 380 | solvestop(int d, int op, SolveOptions *opts, AlgList *sols) |
| 376 | { | 381 | { |
| 377 | bool opt_done, max_moves_exceeded, max_sols_exceeded; | 382 | bool opt_done, max_moves_exceeded, max_sols_exceeded; |
