aboutsummaryrefslogtreecommitdiff
path: root/src/solve.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/solve.c')
-rw-r--r--src/solve.c29
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);
11static bool dfs_switch(DfsArg *arg); 11static bool dfs_switch(DfsArg *arg);
12static void dfs_niss(DfsArg *arg); 12static void dfs_niss(DfsArg *arg);
13static bool dfs_stop(DfsArg *arg); 13static bool dfs_stop(DfsArg *arg);
14static bool dfs_useless_niss(DfsArg *arg);
14static void * instance_thread(void *arg); 15static void * instance_thread(void *arg);
15static void invert_branch(DfsArg *arg); 16static void invert_branch(DfsArg *arg);
16static void multidfs(Cube c, Trans t, Step *s, SolveOptions *opts, 17static void multidfs(Cube c, Trans t, Step *s, SolveOptions *opts,
17 AlgList *sols, int d); 18 AlgList *sols, int d);
18static bool niss_makes_sense(DfsArg *arg);
19static bool solvestop(int d, int op, SolveOptions *opts, AlgList *sols); 19static 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
236static bool
237dfs_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
236static void * 250static void *
237instance_thread(void *arg) 251instance_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
365static bool 379static bool
366niss_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
374static bool
375solvestop(int d, int op, SolveOptions *opts, AlgList *sols) 380solvestop(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;

Generated with cgit - Back to sebastiano.tronto.net