diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-03-15 15:54:39 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-03-15 15:54:39 +0100 |
| commit | e18f8e4eefadd733d985e99e2710111afa5a710a (patch) | |
| tree | 196033c8f04e760b8b6f4d445c70ca17143e0179 | |
| parent | def25ea64b097d2a994eb33c91dc66248233afec (diff) | |
| download | nissy-e18f8e4eefadd733d985e99e2710111afa5a710a.tar.gz nissy-e18f8e4eefadd733d985e99e2710111afa5a710a.zip | |
Prepare for big changes in coordinates
| -rw-r--r-- | TODO.md | 31 | ||||
| -rwxr-xr-x | nissy | bin | 327072 -> 327640 bytes | |||
| -rw-r--r-- | src/cubetypes.h | 6 | ||||
| -rw-r--r-- | src/moves.c | 22 | ||||
| -rw-r--r-- | src/moves.h | 15 | ||||
| -rw-r--r-- | src/pruning.c | 4 | ||||
| -rw-r--r-- | src/symcoord.c | 32 | ||||
| -rw-r--r-- | src/trans.h | 2 |
8 files changed, 65 insertions, 47 deletions
| @@ -4,11 +4,19 @@ This is a list of things that I would like to add or change at some point. | |||
| 4 | It's more of a personal reminder than anything else. | 4 | It's more of a personal reminder than anything else. |
| 5 | 5 | ||
| 6 | ## For version 2.1 | 6 | ## For version 2.1 |
| 7 | ### Installation | 7 | ### Moving coordinates |
| 8 | * Implement coord->move to apply moves directly on coordinates | 8 | * Implement coord->move to apply moves directly on coordinates |
| 9 | (can this be used to improve solving speed? Applying moves on | 9 | * add transformer to transform coordinate (optional, only for sym coordinates) |
| 10 | three coordinates is better than applying a move on a Cube and | 10 | * For each coordinate, manually disallow "bad" moves, or just ignore the error |
| 11 | then transforming it, but I still need to work with inverses...) | 11 | (probably better to check: low performance cost, detect problems that I might |
| 12 | be overlooking) | ||
| 13 | * remove selsims, do this directly inside transfinder | ||
| 14 | * change genptable where needed | ||
| 15 | * Remove coord->cube (and edit README.md accordingly) | ||
| 16 | * Remove sym_data->rep (but keep transtorep)? | ||
| 17 | * Use this to improve solver: add 2 or 3 helper coordinates to optimal solver, | ||
| 18 | to avoid transforming every time. We still need to transform when checking | ||
| 19 | inverse scramble, though. | ||
| 12 | ### Documentation | 20 | ### Documentation |
| 13 | * Write an examples.md file | 21 | * Write an examples.md file |
| 14 | * More screenshots! | 22 | * More screenshots! |
| @@ -44,14 +52,13 @@ including e.g. solutions that were not shown because -c) | |||
| 44 | (graphical: maybe there is a cubing.js function; command line: ???) | 52 | (graphical: maybe there is a cubing.js function; command line: ???) |
| 45 | 53 | ||
| 46 | ## Distribution | 54 | ## Distribution |
| 47 | |||
| 48 | * Add EXAMPLES.md file | ||
| 49 | * webapp (cgi) | 55 | * webapp (cgi) |
| 50 | * installation: get ptables with curl or similar (on Windows what?) | ||
| 51 | also, keep only one compressed format (+uncompressed?) on server | ||
| 52 | 56 | ||
| 53 | ## Technical stuff | 57 | ## Technical stuff |
| 54 | 58 | ||
| 59 | ### Testing | ||
| 60 | * write some proper tests, move test_coord to the testing module(s) | ||
| 61 | |||
| 55 | ### Memory management | 62 | ### Memory management |
| 56 | * free pruning table after solve is done? if I do this I need to deafault to a | 63 | * free pruning table after solve is done? if I do this I need to deafault to a |
| 57 | small table for < 8 moves solutions or smth | 64 | small table for < 8 moves solutions or smth |
| @@ -65,14 +72,6 @@ including e.g. solutions that were not shown because -c) | |||
| 65 | * Check if memory is enough for loading pruning tables; if not, abort | 72 | * Check if memory is enough for loading pruning tables; if not, abort |
| 66 | * For optimal solver: choose largest that fits in memory between nxopt and light | 73 | * For optimal solver: choose largest that fits in memory between nxopt and light |
| 67 | 74 | ||
| 68 | ### Other optimal solvers | ||
| 69 | * try htr corners + edges in slice but not oriented (300Mb table); | ||
| 70 | de Bondt's trick does not work, but I can use full symmetry and | ||
| 71 | take advantage of the fact that it is a subset invariant under half-turns | ||
| 72 | (like in light optimal solver) | ||
| 73 | * Another idea: DR + cornershtr (5Gb table); same as above, de Bondt's trick | ||
| 74 | does not work but I can use half-turn trick | ||
| 75 | |||
| 76 | ### Structural changes | 75 | ### Structural changes |
| 77 | * client/server architecture: run a server process in the background so that | 76 | * client/server architecture: run a server process in the background so that |
| 78 | multiple client processess can send it queries and get results; this would | 77 | multiple client processess can send it queries and get results; this would |
| Binary files differ | |||
diff --git a/src/cubetypes.h b/src/cubetypes.h index 14e490a..518c727 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -95,6 +95,8 @@ typedef struct threaddatagenpt ThreadDataGenpt; | |||
| 95 | 95 | ||
| 96 | typedef Cube (*AntiIndexer) (uint64_t); | 96 | typedef Cube (*AntiIndexer) (uint64_t); |
| 97 | typedef bool (*Checker) (Cube); | 97 | typedef bool (*Checker) (Cube); |
| 98 | typedef uint64_t (*CoordMover) (Move, uint64_t); | ||
| 99 | typedef uint64_t (*CoordTransformer) (Trans, uint64_t); | ||
| 98 | typedef int (*Estimator) (DfsArg *); | 100 | typedef int (*Estimator) (DfsArg *); |
| 99 | typedef bool (*Validator) (Alg *); | 101 | typedef bool (*Validator) (Alg *); |
| 100 | typedef void (*Exec) (CommandArgs *); | 102 | typedef void (*Exec) (CommandArgs *); |
| @@ -168,7 +170,9 @@ coordinate | |||
| 168 | Indexer index; | 170 | Indexer index; |
| 169 | AntiIndexer cube; | 171 | AntiIndexer cube; |
| 170 | uint64_t max; | 172 | uint64_t max; |
| 171 | TransFinder trans; | 173 | TransFinder transfind; |
| 174 | CoordMover move; | ||
| 175 | CoordTransformer transform; | ||
| 172 | }; | 176 | }; |
| 173 | 177 | ||
| 174 | struct | 178 | struct |
diff --git a/src/moves.c b/src/moves.c index 7c33db4..02880ca 100644 --- a/src/moves.c +++ b/src/moves.c | |||
| @@ -138,17 +138,17 @@ static char equiv_alg_string[100][NMOVES] = { | |||
| 138 | }; | 138 | }; |
| 139 | 139 | ||
| 140 | /* Transition tables, to be loaded up at the beginning */ | 140 | /* Transition tables, to be loaded up at the beginning */ |
| 141 | static int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | 141 | int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; |
| 142 | static int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | 142 | int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; |
| 143 | static int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | 143 | int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; |
| 144 | static int eofb_mtable[NMOVES][POW2TO11]; | 144 | int eofb_mtable[NMOVES][POW2TO11]; |
| 145 | static int eorl_mtable[NMOVES][POW2TO11]; | 145 | int eorl_mtable[NMOVES][POW2TO11]; |
| 146 | static int eoud_mtable[NMOVES][POW2TO11]; | 146 | int eoud_mtable[NMOVES][POW2TO11]; |
| 147 | static int cp_mtable[NMOVES][FACTORIAL8]; | 147 | int cp_mtable[NMOVES][FACTORIAL8]; |
| 148 | static int coud_mtable[NMOVES][POW3TO7]; | 148 | int coud_mtable[NMOVES][POW3TO7]; |
| 149 | static int cofb_mtable[NMOVES][POW3TO7]; | 149 | int cofb_mtable[NMOVES][POW3TO7]; |
| 150 | static int corl_mtable[NMOVES][POW3TO7]; | 150 | int corl_mtable[NMOVES][POW3TO7]; |
| 151 | static int cpos_mtable[NMOVES][FACTORIAL6]; | 151 | int cpos_mtable[NMOVES][FACTORIAL6]; |
| 152 | 152 | ||
| 153 | 153 | ||
| 154 | /* Local functions implementation ********************************************/ | 154 | /* Local functions implementation ********************************************/ |
diff --git a/src/moves.h b/src/moves.h index e7881a4..14ae087 100644 --- a/src/moves.h +++ b/src/moves.h | |||
| @@ -5,6 +5,21 @@ | |||
| 5 | #include "cube.h" | 5 | #include "cube.h" |
| 6 | #include "env.h" | 6 | #include "env.h" |
| 7 | 7 | ||
| 8 | /* | ||
| 9 | * Tables are exposed to allow for faster moves in some cases. | ||
| 10 | */ | ||
| 11 | extern int epose_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | ||
| 12 | extern int eposs_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | ||
| 13 | extern int eposm_mtable[NMOVES][FACTORIAL12/FACTORIAL8]; | ||
| 14 | extern int eofb_mtable[NMOVES][POW2TO11]; | ||
| 15 | extern int eorl_mtable[NMOVES][POW2TO11]; | ||
| 16 | extern int eoud_mtable[NMOVES][POW2TO11]; | ||
| 17 | extern int cp_mtable[NMOVES][FACTORIAL8]; | ||
| 18 | extern int coud_mtable[NMOVES][POW3TO7]; | ||
| 19 | extern int cofb_mtable[NMOVES][POW3TO7]; | ||
| 20 | extern int corl_mtable[NMOVES][POW3TO7]; | ||
| 21 | extern int cpos_mtable[NMOVES][FACTORIAL6]; | ||
| 22 | |||
| 8 | Cube apply_alg(Alg *alg, Cube cube); | 23 | Cube apply_alg(Alg *alg, Cube cube); |
| 9 | Cube apply_alg_generic(Alg *alg, Cube c, PieceFilter f, bool a); | 24 | Cube apply_alg_generic(Alg *alg, Cube c, PieceFilter f, bool a); |
| 10 | Cube apply_move(Move m, Cube cube); | 25 | Cube apply_move(Move m, Cube cube); |
diff --git a/src/pruning.c b/src/pruning.c index c66f8d6..2dea797 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -263,12 +263,12 @@ genptable_fixnasty(PruneData *pd, int d) | |||
| 263 | Cube c, cc; | 263 | Cube c, cc; |
| 264 | Trans t[NTRANS]; | 264 | Trans t[NTRANS]; |
| 265 | 265 | ||
| 266 | if (pd->coord->trans == NULL) | 266 | if (pd->coord->transfind == NULL) |
| 267 | return; | 267 | return; |
| 268 | 268 | ||
| 269 | for (i = 0; i < pd->coord->max; i++) { | 269 | for (i = 0; i < pd->coord->max; i++) { |
| 270 | if (ptableval_index(pd, i) == d) { | 270 | if (ptableval_index(pd, i) == d) { |
| 271 | n = pd->coord->trans(i, t); | 271 | n = pd->coord->transfind(i, t); |
| 272 | if (n == 1) | 272 | if (n == 1) |
| 273 | continue; | 273 | continue; |
| 274 | 274 | ||
diff --git a/src/symcoord.c b/src/symcoord.c index c4349f5..38e13c6 100644 --- a/src/symcoord.c +++ b/src/symcoord.c | |||
| @@ -64,38 +64,38 @@ SymData * all_sd[] = { | |||
| 64 | 64 | ||
| 65 | Coordinate | 65 | Coordinate |
| 66 | coord_eofbepos_sym16 = { | 66 | coord_eofbepos_sym16 = { |
| 67 | .index = index_eofbepos_sym16, | 67 | .index = index_eofbepos_sym16, |
| 68 | .cube = antindex_eofbepos_sym16, | 68 | .cube = antindex_eofbepos_sym16, |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | Coordinate | 71 | Coordinate |
| 72 | coord_cp_sym16 = { | 72 | coord_cp_sym16 = { |
| 73 | .index = index_cp_sym16, | 73 | .index = index_cp_sym16, |
| 74 | .cube = antindex_cp_sym16, | 74 | .cube = antindex_cp_sym16, |
| 75 | }; | 75 | }; |
| 76 | 76 | ||
| 77 | Coordinate | 77 | Coordinate |
| 78 | coord_drud_sym16 = { | 78 | coord_drud_sym16 = { |
| 79 | .index = index_drud_sym16, | 79 | .index = index_drud_sym16, |
| 80 | .cube = antindex_drud_sym16, | 80 | .cube = antindex_drud_sym16, |
| 81 | .max = POW3TO7 * CLASSES_EOFBEPOS_16, | 81 | .max = POW3TO7 * CLASSES_EOFBEPOS_16, |
| 82 | .trans = transfinder_drud_sym16, | 82 | .transfind = transfinder_drud_sym16, |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | Coordinate | 85 | Coordinate |
| 86 | coord_drudfin_noE_sym16 = { | 86 | coord_drudfin_noE_sym16 = { |
| 87 | .index = index_drudfin_noE_sym16, | 87 | .index = index_drudfin_noE_sym16, |
| 88 | .cube = antindex_drudfin_noE_sym16, | 88 | .cube = antindex_drudfin_noE_sym16, |
| 89 | .max = FACTORIAL8 * CLASSES_CP_16, | 89 | .max = FACTORIAL8 * CLASSES_CP_16, |
| 90 | .trans = transfinder_drudfin_noE_sym16, | 90 | .transfind = transfinder_drudfin_noE_sym16, |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | Coordinate | 93 | Coordinate |
| 94 | coord_nxopt31 = { | 94 | coord_nxopt31 = { |
| 95 | .index = index_nxopt31, | 95 | .index = index_nxopt31, |
| 96 | .cube = antindex_nxopt31, | 96 | .cube = antindex_nxopt31, |
| 97 | .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16 , | 97 | .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, |
| 98 | .trans = transfinder_nxopt31, | 98 | .transfind = transfinder_nxopt31, |
| 99 | }; | 99 | }; |
| 100 | 100 | ||
| 101 | /* Functions *****************************************************************/ | 101 | /* Functions *****************************************************************/ |
diff --git a/src/trans.h b/src/trans.h index 13d17d8..51df12f 100644 --- a/src/trans.h +++ b/src/trans.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | #include "moves.h" | 4 | #include "moves.h" |
| 5 | 5 | ||
| 6 | /* | 6 | /* |
| 7 | * Tables are exposed to allow faster partial transofrmations in some | 7 | * Tables are exposed to allow faster partial transformations in some |
| 8 | * specific cases (in symcoord) | 8 | * specific cases (in symcoord) |
| 9 | */ | 9 | */ |
| 10 | extern int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; | 10 | extern int epose_ttable[NTRANS][FACTORIAL12/FACTORIAL8]; |
