From 3baaef5a55b9dd98ee35658d40c25ee9fedfa3c0 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 25 Dec 2021 10:18:08 +0100 Subject: Transform solutions early so that -v gives meaningful info --- src/solve.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/solve.c b/src/solve.c index a2ca2ad..931dc02 100644 --- 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; } -- cgit v1.3