nissy

Where is nissy?
git clone https://git.tronto.net/nissy
Download | Log | Files | Refs | README

commit 3baaef5a55b9dd98ee35658d40c25ee9fedfa3c0
parent 51dff333ceb5228b8de98dd621c0c2b62ed43441
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Sat, 25 Dec 2021 10:18:08 +0100

Transform solutions early so that -v gives meaningful info

Diffstat:
MTODO.md | 2--
Mnissy | 0
Msrc/solve.c | 26+++++++++++++++-----------
3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -23,8 +23,6 @@ It's more of a personal reminder than anything else. * solve should try up to a small bound without loading the large pruning table * drfin for HTR scrambles should try all 3 axis and pick the best solutions; in general every step that automatically detects orientation should do this -* for solve -v, solving in different orientation does not give meaningful info, - because I need to transform the alg as I go. * for solve -v, print certain info like average branching value * solve -O n find solutions within n moves from optimal (-o is the same as -O 0) diff --git a/nissy b/nissy Binary files differ. diff --git a/src/solve.c b/src/solve.c @@ -139,14 +139,25 @@ dfs_check_solved(DfsArg *arg) if (arg->current_alg->len == arg->d) { if ((arg->step->is_valid(arg->current_alg) || arg->opts->all) && (!arg->step->final || !cancel_niss(arg))) { + pthread_mutex_lock(arg->sols_mutex); - if (arg->sols->len < arg->opts->max_solutions) + + if (arg->sols->len < arg->opts->max_solutions) { append_alg(arg->sols, arg->current_alg); + + transform_alg( + inverse_trans(arg->step->pre_trans), + arg->sols->last->alg + ); + if (arg->step->final) + unniss(arg->sols->last->alg); + + if (arg->opts->verbose) + print_alg(arg->sols->last->alg, false); + } + pthread_mutex_unlock(arg->sols_mutex); } - - if (arg->opts->verbose) - print_alg(arg->current_alg, false); } return true; @@ -364,7 +375,6 @@ solve(Cube cube, Step *step, SolveOptions *opts) { int d; AlgList *sols; - AlgListNode *node; Cube c; prepare_step(step, opts); @@ -398,11 +408,5 @@ solve(Cube cube, Step *step, SolveOptions *opts) multidfs(c, step, opts, sols, d); } - for (node = sols->first; node != NULL; node = node->next) { - transform_alg(inverse_trans(step->pre_trans), node->alg); - if (step->final) - unniss(node->alg); - } - return sols; }