nissy-fmc

A Rubik's cube FMC assistant
git clone https://git.tronto.net/nissy-fmc
Download | Log | Files | Refs | README | LICENSE

commit 4fb970ad4e7d0558f7bf32dbad2333dbf3cb3ab4
parent 4dddac9e257433a8e2f5f763d91470a7e05ff680
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date:   Thu, 23 Dec 2021 19:01:33 +0100

Fixes for yesterday's commit

Diffstat:
MTODO.md | 2++
Mnissy | 0
Msrc/commands.c | 2+-
Msrc/pruning.c | 30++++++++++++++++++++----------
Msrc/shell.c | 6++++++
Msrc/steps.c | 5++++-
6 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/TODO.md b/TODO.md @@ -60,6 +60,8 @@ It's more of a personal reminder than anything else. ### Performance * solve (allow_next): filter out based on base_move; only check once for each triple of moves; how to deal with different movesets? + +### Other optimal solvers * try htr corners + edges in slice but not oriented (300Mb table); de Bondt's trick does not work, but I can use full symmetry and take advantage of the fact that it is a subset invariant under half-turns diff --git a/nissy b/nissy Binary files differ. diff --git a/src/commands.c b/src/commands.c @@ -322,7 +322,7 @@ help_exec(CommandArgs *args) "available commands.\n" "See the manual page for more details. The manual" " page is available with \"man nissy\" on a UNIX" - " system (such a Linux or MacOS) or in pdf and html" + " system (such as Linux or MacOS) or in pdf and html" " format in the docs folder.\n" "Nissy is available for free at " "https://github.com/sebastianotronto/nissy\n" diff --git a/src/pruning.c b/src/pruning.c @@ -127,19 +127,25 @@ findchunk(PruneData *pd, int nchunks, uint64_t i) void genptable(PruneData *pd, int nthreads) { + bool compact; int d, nchunks; - uint64_t oldn; + uint64_t oldn, sz; if (pd->generated) return; /* TODO: check if memory is enough, otherwise maybe exit gracefully? */ - pd->ptable = malloc(ptablesize(pd) * sizeof(entry_group_t)); + sz = ptablesize(pd) * (pd->compact ? 2 : 1); + pd->ptable = malloc(sz * sizeof(entry_group_t)); if (read_ptable_file(pd)) { pd->generated = true; return; } + + /* For the first steps we proceed the same way for compact and not */ + compact = pd->compact; + pd->compact = false; pd->generated = true; nchunks = MIN(ptablesize(pd), 100000); @@ -169,7 +175,7 @@ genptable(PruneData *pd, int nthreads) fprintf(stderr, "Pruning table generated!\n"); genptable_setbase(pd); - if (pd->compact) + if (compact) genptable_compress(pd); if (!write_ptable_file(pd)) @@ -217,18 +223,22 @@ genptable_compress(PruneData *pd) uint64_t i, j; entry_group_t mask, v; - pd->compact = false; + fprintf(stderr, "Compressing table to 2 bits per entry\n"); + for (i = 0; i < pd->coord->max; i += ENTRIES_PER_GROUP_COMPACT) { - mask = 0; + mask = (entry_group_t)0; for (j = 0; j < ENTRIES_PER_GROUP_COMPACT; j++) { + if (i+j >= pd->coord->max) + break; val = ptableval_index(pd, i+j) - pd->base; - v = MIN(3, MAX(0, val)); + v = (entry_group_t)MIN(3, MAX(0, val)); mask |= v << (2*j); } pd->ptable[i/ENTRIES_PER_GROUP_COMPACT] = mask; } + pd->compact = true; - realloc(pd->ptable, sizeof(entry_group_t) * ptablesize(pd)); + pd->ptable = realloc(pd->ptable, sizeof(entry_group_t)*ptablesize(pd)); } static void @@ -390,9 +400,9 @@ ptableval_index(PruneData *pd, uint64_t ind) } e = pd->compact ? ENTRIES_PER_GROUP_COMPACT : ENTRIES_PER_GROUP; - m = pd->compact ? 3 : 15; + m = (entry_group_t)(pd->compact ? 3 : 15); - sh = 4 * (ind % e); + sh = (ind % e) * (pd->compact ? 2 : 4); mask = m << sh; i = ind/e; @@ -402,7 +412,7 @@ ptableval_index(PruneData *pd, uint64_t ind) if (ret) ret += pd->base; else - ret = ptableval_index(pd->fallback, ind % pd->fbmod); + ret = ptableval_index(pd->fallback, ind / pd->fbmod); } return ret; diff --git a/src/shell.c b/src/shell.c @@ -97,6 +97,12 @@ launch(bool batchmode) int main(int argc, char *argv[]) { +/* + init_movesets(); + init_symcoord(); + print_ptable(&pd_nxopt31_HTM); +*/ + if (argc > 1) { if (!strcmp(argv[1], "-b")) { launch(true); diff --git a/src/steps.c b/src/steps.c @@ -1497,6 +1497,9 @@ prepare_step(Step *step, SolveOptions *opts) fprintf(stderr, "Step is final, NISS not used (-n ignored)\n"); } - for (i = 0; i < step->ntables; i++) + for (i = 0; i < step->ntables; i++) { genptable(step->tables[i], opts->nthreads); + if (step->tables[i]->compact) + genptable(step->tables[i]->fallback, opts->nthreads); + } }