diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/alg.c | 2 | ||||
| -rw-r--r-- | src/solve.c | 29 | ||||
| -rw-r--r-- | src/steps.c | 10 |
3 files changed, 22 insertions, 19 deletions
| @@ -632,7 +632,7 @@ void | |||
| 632 | sort_alglist(AlgList *al) | 632 | sort_alglist(AlgList *al) |
| 633 | { | 633 | { |
| 634 | int i, n = al->len; | 634 | int i, n = al->len; |
| 635 | Alg* alg_array[n]; | 635 | Alg* alg_array[n+1]; |
| 636 | AlgListNode *node; | 636 | AlgListNode *node; |
| 637 | 637 | ||
| 638 | for (i = 0, node = al->first; i < n; i++, node = node->next) | 638 | for (i = 0, node = al->first; i < n; i++, node = node->next) |
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; |
diff --git a/src/steps.c b/src/steps.c index 383acaa..e7e4834 100644 --- a/src/steps.c +++ b/src/steps.c | |||
| @@ -33,7 +33,6 @@ static int estimate_cp_drud(DfsArg *arg); | |||
| 33 | static int estimate_htrfin_htr(DfsArg *arg); | 33 | static int estimate_htrfin_htr(DfsArg *arg); |
| 34 | static int estimate_nxopt31_HTM(DfsArg *arg); | 34 | static int estimate_nxopt31_HTM(DfsArg *arg); |
| 35 | static int estimate_light_HTM(DfsArg *arg); | 35 | static int estimate_light_HTM(DfsArg *arg); |
| 36 | |||
| 37 | static int estimate_nxoptlike(DfsArg *arg, PruneData *pd); | 36 | static int estimate_nxoptlike(DfsArg *arg, PruneData *pd); |
| 38 | 37 | ||
| 39 | static bool always_valid(Alg *alg); | 38 | static bool always_valid(Alg *alg); |
| @@ -976,7 +975,7 @@ corners_dr_any = { | |||
| 976 | .shortname = "corners-dr", | 975 | .shortname = "corners-dr", |
| 977 | .name = "Solve corners from DR", | 976 | .name = "Solve corners from DR", |
| 978 | 977 | ||
| 979 | .final = false, | 978 | .final = true, |
| 980 | .is_done = check_corners_HTM, | 979 | .is_done = check_corners_HTM, |
| 981 | .estimate = estimate_cp_drud, | 980 | .estimate = estimate_cp_drud, |
| 982 | .ready = check_coud_HTM, | 981 | .ready = check_coud_HTM, |
| @@ -995,7 +994,7 @@ corners_drud = { | |||
| 995 | .shortname = "corners-drud", | 994 | .shortname = "corners-drud", |
| 996 | .name = "Solve corners from DR on U/D", | 995 | .name = "Solve corners from DR on U/D", |
| 997 | 996 | ||
| 998 | .final = false, | 997 | .final = true, |
| 999 | .is_done = check_corners_HTM, | 998 | .is_done = check_corners_HTM, |
| 1000 | .estimate = estimate_cp_drud, | 999 | .estimate = estimate_cp_drud, |
| 1001 | .ready = check_coud_HTM, | 1000 | .ready = check_coud_HTM, |
| @@ -1014,7 +1013,7 @@ corners_drrl = { | |||
| 1014 | .shortname = "corners-drrl", | 1013 | .shortname = "corners-drrl", |
| 1015 | .name = "Solve corners from DR on R/L", | 1014 | .name = "Solve corners from DR on R/L", |
| 1016 | 1015 | ||
| 1017 | .final = false, | 1016 | .final = true, |
| 1018 | .is_done = check_corners_HTM, | 1017 | .is_done = check_corners_HTM, |
| 1019 | .estimate = estimate_cp_drud, | 1018 | .estimate = estimate_cp_drud, |
| 1020 | .ready = check_coud_HTM, | 1019 | .ready = check_coud_HTM, |
| @@ -1033,7 +1032,7 @@ corners_drfb = { | |||
| 1033 | .shortname = "corners-drfb", | 1032 | .shortname = "corners-drfb", |
| 1034 | .name = "Solve corners from DR on F/B", | 1033 | .name = "Solve corners from DR on F/B", |
| 1035 | 1034 | ||
| 1036 | .final = false, | 1035 | .final = true, |
| 1037 | .is_done = check_corners_HTM, | 1036 | .is_done = check_corners_HTM, |
| 1038 | .estimate = estimate_cp_drud, | 1037 | .estimate = estimate_cp_drud, |
| 1039 | .ready = check_coud_HTM, | 1038 | .ready = check_coud_HTM, |
| @@ -1570,7 +1569,6 @@ estimate_nxoptlike(DfsArg *arg, PruneData *pd) | |||
| 1570 | return arg->ed->oldret = ret; | 1569 | return arg->ed->oldret = ret; |
| 1571 | } | 1570 | } |
| 1572 | 1571 | ||
| 1573 | |||
| 1574 | static bool | 1572 | static bool |
| 1575 | always_valid(Alg *alg) | 1573 | always_valid(Alg *alg) |
| 1576 | { | 1574 | { |
