diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 10:18:08 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 10:18:08 +0100 |
| commit | 3baaef5a55b9dd98ee35658d40c25ee9fedfa3c0 (patch) | |
| tree | 7889a1919a0767f6d876247b93c9d83d0fcba21d | |
| parent | 51dff333ceb5228b8de98dd621c0c2b62ed43441 (diff) | |
| download | nissy-3baaef5a55b9dd98ee35658d40c25ee9fedfa3c0.tar.gz nissy-3baaef5a55b9dd98ee35658d40c25ee9fedfa3c0.zip | |
Transform solutions early so that -v gives meaningful info
| -rw-r--r-- | TODO.md | 2 | ||||
| -rwxr-xr-x | nissy | bin | 321848 -> 321848 bytes | |||
| -rw-r--r-- | src/solve.c | 26 |
3 files changed, 15 insertions, 13 deletions
| @@ -23,8 +23,6 @@ It's more of a personal reminder than anything else. | |||
| 23 | * solve should try up to a small bound without loading the large pruning table | 23 | * solve should try up to a small bound without loading the large pruning table |
| 24 | * drfin for HTR scrambles should try all 3 axis and pick the best solutions; | 24 | * drfin for HTR scrambles should try all 3 axis and pick the best solutions; |
| 25 | in general every step that automatically detects orientation should do this | 25 | in general every step that automatically detects orientation should do this |
| 26 | * for solve -v, solving in different orientation does not give meaningful info, | ||
| 27 | because I need to transform the alg as I go. | ||
| 28 | * for solve -v, print certain info like average branching value | 26 | * for solve -v, print certain info like average branching value |
| 29 | * solve -O n find solutions within n moves from optimal | 27 | * solve -O n find solutions within n moves from optimal |
| 30 | (-o is the same as -O 0) | 28 | (-o is the same as -O 0) |
| Binary files differ | |||
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) | |||
| 139 | if (arg->current_alg->len == arg->d) { | 139 | if (arg->current_alg->len == arg->d) { |
| 140 | if ((arg->step->is_valid(arg->current_alg) || arg->opts->all) | 140 | if ((arg->step->is_valid(arg->current_alg) || arg->opts->all) |
| 141 | && (!arg->step->final || !cancel_niss(arg))) { | 141 | && (!arg->step->final || !cancel_niss(arg))) { |
| 142 | |||
| 142 | pthread_mutex_lock(arg->sols_mutex); | 143 | pthread_mutex_lock(arg->sols_mutex); |
| 143 | if (arg->sols->len < arg->opts->max_solutions) | 144 | |
| 145 | if (arg->sols->len < arg->opts->max_solutions) { | ||
| 144 | append_alg(arg->sols, arg->current_alg); | 146 | append_alg(arg->sols, arg->current_alg); |
| 147 | |||
| 148 | transform_alg( | ||
| 149 | inverse_trans(arg->step->pre_trans), | ||
| 150 | arg->sols->last->alg | ||
| 151 | ); | ||
| 152 | if (arg->step->final) | ||
| 153 | unniss(arg->sols->last->alg); | ||
| 154 | |||
| 155 | if (arg->opts->verbose) | ||
| 156 | print_alg(arg->sols->last->alg, false); | ||
| 157 | } | ||
| 158 | |||
| 145 | pthread_mutex_unlock(arg->sols_mutex); | 159 | pthread_mutex_unlock(arg->sols_mutex); |
| 146 | } | 160 | } |
| 147 | |||
| 148 | if (arg->opts->verbose) | ||
| 149 | print_alg(arg->current_alg, false); | ||
| 150 | } | 161 | } |
| 151 | 162 | ||
| 152 | return true; | 163 | return true; |
| @@ -364,7 +375,6 @@ solve(Cube cube, Step *step, SolveOptions *opts) | |||
| 364 | { | 375 | { |
| 365 | int d; | 376 | int d; |
| 366 | AlgList *sols; | 377 | AlgList *sols; |
| 367 | AlgListNode *node; | ||
| 368 | Cube c; | 378 | Cube c; |
| 369 | 379 | ||
| 370 | prepare_step(step, opts); | 380 | prepare_step(step, opts); |
| @@ -398,11 +408,5 @@ solve(Cube cube, Step *step, SolveOptions *opts) | |||
| 398 | multidfs(c, step, opts, sols, d); | 408 | multidfs(c, step, opts, sols, d); |
| 399 | } | 409 | } |
| 400 | 410 | ||
| 401 | for (node = sols->first; node != NULL; node = node->next) { | ||
| 402 | transform_alg(inverse_trans(step->pre_trans), node->alg); | ||
| 403 | if (step->final) | ||
| 404 | unniss(node->alg); | ||
| 405 | } | ||
| 406 | |||
| 407 | return sols; | 411 | return sols; |
| 408 | } | 412 | } |
