diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2022-05-31 17:29:08 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2022-05-31 17:29:08 +0200 |
| commit | f021ee7fa4975eab02c158451093a28e83a725d9 (patch) | |
| tree | 7ec8d13732d59fa1b53e55b87753ebf35b5e58ad | |
| parent | e18f8e4eefadd733d985e99e2710111afa5a710a (diff) | |
| download | nissy-f021ee7fa4975eab02c158451093a28e83a725d9.tar.gz nissy-f021ee7fa4975eab02c158451093a28e83a725d9.zip | |
Big changes to coordinate system: remove "anti-index" in favor of a more kociemba-like move function for each coordinate. This should speedup the table generation step. WARNING: nissy might not be 100% functional at this stage, TESTING needed!
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | TODO.md | 47 | ||||
| -rwxr-xr-x | nissy | bin | 327640 -> 327792 bytes | |||
| -rw-r--r-- | src/commands.c | 28 | ||||
| -rw-r--r-- | src/coord.c | 560 | ||||
| -rw-r--r-- | src/coord.h | 5 | ||||
| -rw-r--r-- | src/cube.c | 30 | ||||
| -rw-r--r-- | src/cube.h | 3 | ||||
| -rw-r--r-- | src/cubetypes.h | 7 | ||||
| -rw-r--r-- | src/pruning.c | 32 | ||||
| -rw-r--r-- | src/symcoord.c | 344 | ||||
| -rw-r--r-- | www/download/index.html | 4 |
12 files changed, 610 insertions, 451 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd57588 --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| nissy | |||
| @@ -5,24 +5,46 @@ It's more of a personal reminder than anything else. | |||
| 5 | 5 | ||
| 6 | ## For version 2.1 | 6 | ## For version 2.1 |
| 7 | ### Moving coordinates | 7 | ### Moving coordinates |
| 8 | * Implement coord->move to apply moves directly on coordinates | 8 | * general cleanup |
| 9 | * add transformer to transform coordinate (optional, only for sym coordinates) | 9 | ### Changes to Step and Solve |
| 10 | * For each coordinate, manually disallow "bad" moves, or just ignore the error | 10 | * add a list of "helper" coordinates to every step |
| 11 | (probably better to check: low performance cost, detect problems that I might | 11 | * Probably nicer: instead of passing a cube pass a structure "cube description" |
| 12 | be overlooking) | 12 | which can contain coordinates and one or more cubes. |
| 13 | * remove selsims, do this directly inside transfinder | 13 | This can also be used to avoid using index_epud too much in drfin |
| 14 | * change genptable where needed | 14 | (it is slow because it goes through cubearray). |
| 15 | * Remove coord->cube (and edit README.md accordingly) | 15 | * add a step->move(Cube) function, which may apply moves to the cube or just to |
| 16 | * Remove sym_data->rep (but keep transtorep)? | 16 | the coordinates |
| 17 | * Use this to improve solver: add 2 or 3 helper coordinates to optimal solver, | 17 | * optimal solver: move the coordinates for the 3 orientations, but also the |
| 18 | to avoid transforming every time. We still need to transform when checking | 18 | cube so we can check the inverse |
| 19 | inverse scramble, though. | 19 | ### Tables management |
| 20 | * Check files in tables directory, add command to remove old / extraneous files | ||
| 21 | * Add checksum to check that tables are generated / downloaded correctly | ||
| 20 | ### Documentation | 22 | ### Documentation |
| 23 | * Fix README.md with new coordinate system | ||
| 21 | * Write an examples.md file | 24 | * Write an examples.md file |
| 22 | * More screenshots! | 25 | * More screenshots! |
| 23 | ### More | 26 | ### More |
| 24 | * Anything quick and easy from the sections below | 27 | * Anything quick and easy from the sections below |
| 25 | 28 | ||
| 29 | ## Refactor | ||
| 30 | ### Coordinates | ||
| 31 | * Text (README.md) description of coordinate system with 3 (or 4) types of | ||
| 32 | coordinates: basic (+ fundamental), sym, composite (consisting of at most | ||
| 33 | one sym + one or more basic) | ||
| 34 | * Use this to restructure the coordinate part; maybe fundamental coordinates | ||
| 35 | do not need to exist??? | ||
| 36 | * Add also "transform" for every coordinate. For example, for EO and similar | ||
| 37 | only allow transformations that fix the EO axis. | ||
| 38 | * Also: "basic" symcoord do not allow trans, composite coordinates assume | ||
| 39 | the transformation fixes the basic sumcoord | ||
| 40 | * For each coordinate, manually disallow "bad" moves, or just ignore the error | ||
| 41 | (probably better to check: low performance cost, detect problems that I might | ||
| 42 | be overlooking) | ||
| 43 | ### Loading at startup vs dynamically | ||
| 44 | * Consider moving more things to the initial loading phase (i.e. remove | ||
| 45 | many of the "initialized" parts) | ||
| 46 | |||
| 47 | |||
| 26 | ## Commands | 48 | ## Commands |
| 27 | 49 | ||
| 28 | ### Commands that are available in nissy 1.0, but not in this version (yet): | 50 | ### Commands that are available in nissy 1.0, but not in this version (yet): |
| @@ -34,6 +56,7 @@ including e.g. solutions that were not shown because -c) | |||
| 34 | 56 | ||
| 35 | ### More steps for `solve` | 57 | ### More steps for `solve` |
| 36 | * QTM optimal solving | 58 | * QTM optimal solving |
| 59 | * 5-side solve (for robots) | ||
| 37 | * Block-building steps (cross, roux blocks, ...) | 60 | * Block-building steps (cross, roux blocks, ...) |
| 38 | * Other common steps (LSE, ...) | 61 | * Other common steps (LSE, ...) |
| 39 | 62 | ||
| Binary files differ | |||
diff --git a/src/commands.c b/src/commands.c index e704d7a..ed3d46a 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -410,9 +410,11 @@ static void | |||
| 410 | scramble_exec(CommandArgs *args) | 410 | scramble_exec(CommandArgs *args) |
| 411 | { | 411 | { |
| 412 | Cube cube; | 412 | Cube cube; |
| 413 | CubeArray *arr; | ||
| 413 | Alg *scr, *ruf, *aux; | 414 | Alg *scr, *ruf, *aux; |
| 414 | int i, j, eo, ep, co, cp, a[12]; | 415 | int i, j, eo, ep, co, cp, a[12]; |
| 415 | uint64_t ui, uj; | 416 | int eparr[12] = { [8] = 8, [9] = 9, [10] = 10, [11] = 11 }; |
| 417 | uint64_t ui, uj, uk; | ||
| 416 | 418 | ||
| 417 | init_all_movesets(); | 419 | init_all_movesets(); |
| 418 | init_symcoord(); | 420 | init_symcoord(); |
| @@ -429,17 +431,29 @@ scramble_exec(CommandArgs *args) | |||
| 429 | * Moreover we again need to fix parity after * | 431 | * Moreover we again need to fix parity after * |
| 430 | * generating epose manually */ | 432 | * generating epose manually */ |
| 431 | do { | 433 | do { |
| 432 | ui = rand() % coord_drudfin_noE_sym16.max; | 434 | ui = rand() % FACTORIAL8; |
| 433 | uj = rand() % FACTORIAL4; | 435 | uj = rand() % FACTORIAL8; |
| 434 | cube = coord_drudfin_noE_sym16.cube(ui); | 436 | uk = rand() % FACTORIAL4; |
| 435 | cube.epose += uj; | 437 | |
| 438 | index_to_perm(ui, 12, a); | ||
| 439 | arr = malloc(sizeof(CubeArray)); | ||
| 440 | arr->ep = eparr; | ||
| 441 | cube = arrays_to_cube(arr, pf_ep); | ||
| 442 | free(arr); | ||
| 443 | |||
| 444 | cube.cp = uj; | ||
| 445 | cube.epose += uk; | ||
| 436 | } while (!is_admissible(cube)); | 446 | } while (!is_admissible(cube)); |
| 437 | } else if (!strcmp(args->scrtype, "htr")) { | 447 | } else if (!strcmp(args->scrtype, "htr")) { |
| 438 | /* antindex_htrfin() returns a consistent * | 448 | /* antindex_htrfin() returns a consistent * |
| 439 | * cube, except possibly for parity */ | 449 | * cube, except possibly for parity */ |
| 440 | do { | 450 | do { |
| 441 | ui = rand() % coord_htrfin.max; | 451 | ui = rand() % (24*24/6); |
| 442 | cube = coord_htrfin.cube(ui); | 452 | cube = (Cube){0}; |
| 453 | cube.cp = cornershtrfin_ant[ui]; | ||
| 454 | cube.epose = rand() % 24; | ||
| 455 | cube.eposs = rand() % 24; | ||
| 456 | cube.eposm = rand() % 24; | ||
| 443 | } while (!is_admissible(cube)); | 457 | } while (!is_admissible(cube)); |
| 444 | } else { | 458 | } else { |
| 445 | eo = rand() % POW2TO11; | 459 | eo = rand() % POW2TO11; |
diff --git a/src/coord.c b/src/coord.c index 3bbda22..abfa1b9 100644 --- a/src/coord.c +++ b/src/coord.c | |||
| @@ -1,20 +1,5 @@ | |||
| 1 | #include "coord.h" | 1 | #include "coord.h" |
| 2 | 2 | ||
| 3 | static Cube antindex_eofb(uint64_t ind); | ||
| 4 | static Cube antindex_eofbepos(uint64_t ind); | ||
| 5 | static Cube antindex_epud(uint64_t ind); | ||
| 6 | static Cube antindex_coud(uint64_t ind); | ||
| 7 | static Cube antindex_corners(uint64_t ind); | ||
| 8 | static Cube antindex_cp(uint64_t ind); | ||
| 9 | static Cube antindex_cphtr(uint64_t); | ||
| 10 | static Cube antindex_cornershtr(uint64_t ind); | ||
| 11 | static Cube antindex_cornershtrfin(uint64_t ind); | ||
| 12 | static Cube antindex_drud(uint64_t ind); | ||
| 13 | static Cube antindex_drud_eofb(uint64_t ind); | ||
| 14 | static Cube antindex_htr_drud(uint64_t ind); | ||
| 15 | static Cube antindex_htrfin(uint64_t ind); | ||
| 16 | static Cube antindex_cpud_separate(uint64_t ind); | ||
| 17 | |||
| 18 | static uint64_t index_eofb(Cube cube); | 3 | static uint64_t index_eofb(Cube cube); |
| 19 | static uint64_t index_eofbepos(Cube cube); | 4 | static uint64_t index_eofbepos(Cube cube); |
| 20 | static uint64_t index_epud(Cube cube); | 5 | static uint64_t index_epud(Cube cube); |
| @@ -30,10 +15,27 @@ static uint64_t index_htr_drud(Cube cube); | |||
| 30 | static uint64_t index_htrfin(Cube cube); | 15 | static uint64_t index_htrfin(Cube cube); |
| 31 | static uint64_t index_cpud_separate(Cube cube); | 16 | static uint64_t index_cpud_separate(Cube cube); |
| 32 | 17 | ||
| 18 | static uint64_t move_eofb(Move m, uint64_t ind); | ||
| 19 | static uint64_t move_eofbepos(Move m, uint64_t ind); | ||
| 20 | static uint64_t move_epud(Move m, uint64_t ind); | ||
| 21 | static uint64_t move_coud(Move m, uint64_t ind); | ||
| 22 | static uint64_t move_corners(Move m, uint64_t ind); | ||
| 23 | static uint64_t move_cp(Move m, uint64_t ind); | ||
| 24 | static uint64_t move_cphtr(Move m, uint64_t ind); | ||
| 25 | static uint64_t move_cornershtr(Move m, uint64_t ind); | ||
| 26 | static uint64_t move_cornershtrfin(Move m, uint64_t ind); | ||
| 27 | static uint64_t move_drud(Move m, uint64_t ind); | ||
| 28 | static uint64_t move_drud_eofb(Move m, uint64_t ind); | ||
| 29 | static uint64_t move_htr_drud(Move m, uint64_t ind); | ||
| 30 | static uint64_t move_htrfin(Move m, uint64_t ind); | ||
| 31 | static uint64_t move_cpud_separate(Move m, uint64_t ind); | ||
| 32 | |||
| 33 | static void init_cphtr_cosets(); | 33 | static void init_cphtr_cosets(); |
| 34 | static void init_cphtr_left_cosets_bfs(int i, int c); | 34 | static void init_cphtr_left_cosets_bfs(int i, int c); |
| 35 | static void init_cphtr_right_cosets_color(int i, int c); | 35 | static void init_cphtr_right_cosets_color(int i, int c); |
| 36 | static void init_cpud_separate(); | ||
| 36 | static void init_cornershtrfin(); | 37 | static void init_cornershtrfin(); |
| 38 | static void init_htr_eposs(); | ||
| 37 | 39 | ||
| 38 | 40 | ||
| 39 | /* All sorts of useful costants and tables **********************************/ | 41 | /* All sorts of useful costants and tables **********************************/ |
| @@ -41,497 +43,408 @@ static void init_cornershtrfin(); | |||
| 41 | static int cphtr_left_cosets[FACTORIAL8]; | 43 | static int cphtr_left_cosets[FACTORIAL8]; |
| 42 | static int cphtr_right_cosets[FACTORIAL8]; | 44 | static int cphtr_right_cosets[FACTORIAL8]; |
| 43 | static int cphtr_right_rep[BINOM8ON4*6]; | 45 | static int cphtr_right_rep[BINOM8ON4*6]; |
| 46 | int cpud_separate_ind[FACTORIAL8]; | ||
| 47 | int cpud_separate_ant[BINOM8ON4]; | ||
| 44 | static int cornershtrfin_ind[FACTORIAL8]; | 48 | static int cornershtrfin_ind[FACTORIAL8]; |
| 45 | static int cornershtrfin_ant[24*24/6]; | 49 | int cornershtrfin_ant[24*24/6]; |
| 50 | static int htr_eposs_ind[BINOM12ON4]; | ||
| 51 | static int htr_eposs_ant[BINOM8ON4]; | ||
| 46 | 52 | ||
| 47 | /* Coordinates and their implementation **************************************/ | 53 | /* Coordinates and their implementation **************************************/ |
| 48 | 54 | ||
| 49 | Coordinate | 55 | Coordinate |
| 50 | coord_eofb = { | 56 | coord_eofb = { |
| 51 | .index = index_eofb, | 57 | .index = index_eofb, |
| 52 | .cube = antindex_eofb, | ||
| 53 | .max = POW2TO11, | 58 | .max = POW2TO11, |
| 59 | .move = move_eofb, | ||
| 54 | }; | 60 | }; |
| 55 | 61 | ||
| 56 | Coordinate | 62 | Coordinate |
| 57 | coord_eofbepos = { | 63 | coord_eofbepos = { |
| 58 | .index = index_eofbepos, | 64 | .index = index_eofbepos, |
| 59 | .cube = antindex_eofbepos, | ||
| 60 | .max = POW2TO11 * BINOM12ON4, | 65 | .max = POW2TO11 * BINOM12ON4, |
| 66 | .move = move_eofbepos, | ||
| 61 | }; | 67 | }; |
| 62 | 68 | ||
| 63 | Coordinate | 69 | Coordinate |
| 64 | coord_coud = { | 70 | coord_coud = { |
| 65 | .index = index_coud, | 71 | .index = index_coud, |
| 66 | .cube = antindex_coud, | ||
| 67 | .max = POW3TO7, | 72 | .max = POW3TO7, |
| 73 | .move = move_coud, | ||
| 68 | }; | 74 | }; |
| 69 | 75 | ||
| 70 | Coordinate | 76 | Coordinate |
| 71 | coord_corners = { | 77 | coord_corners = { |
| 72 | .index = index_corners, | 78 | .index = index_corners, |
| 73 | .cube = antindex_corners, | ||
| 74 | .max = POW3TO7 * FACTORIAL8, | 79 | .max = POW3TO7 * FACTORIAL8, |
| 80 | .move = move_corners, | ||
| 75 | }; | 81 | }; |
| 76 | 82 | ||
| 77 | Coordinate | 83 | Coordinate |
| 78 | coord_cp = { | 84 | coord_cp = { |
| 79 | .index = index_cp, | 85 | .index = index_cp, |
| 80 | .cube = antindex_cp, | ||
| 81 | .max = FACTORIAL8, | 86 | .max = FACTORIAL8, |
| 87 | .move = move_cp, | ||
| 82 | }; | 88 | }; |
| 83 | 89 | ||
| 84 | Coordinate | 90 | Coordinate |
| 85 | coord_cphtr = { | 91 | coord_cphtr = { |
| 86 | .index = index_cphtr, | 92 | .index = index_cphtr, |
| 87 | .cube = antindex_cphtr, | ||
| 88 | .max = BINOM8ON4 * 6, | 93 | .max = BINOM8ON4 * 6, |
| 94 | .move = move_cphtr, | ||
| 89 | }; | 95 | }; |
| 90 | 96 | ||
| 91 | Coordinate | 97 | Coordinate |
| 92 | coord_cornershtr = { | 98 | coord_cornershtr = { |
| 93 | .index = index_cornershtr, | 99 | .index = index_cornershtr, |
| 94 | .cube = antindex_cornershtr, | ||
| 95 | .max = POW3TO7 * BINOM8ON4 * 6, | 100 | .max = POW3TO7 * BINOM8ON4 * 6, |
| 101 | .move = move_cornershtr, | ||
| 96 | }; | 102 | }; |
| 97 | 103 | ||
| 98 | Coordinate | 104 | Coordinate |
| 99 | coord_cornershtrfin = { | 105 | coord_cornershtrfin = { |
| 100 | .index = index_cornershtrfin, | 106 | .index = index_cornershtrfin, |
| 101 | .cube = antindex_cornershtrfin, | ||
| 102 | .max = 24*24/6, | 107 | .max = 24*24/6, |
| 108 | .move = move_cornershtrfin, | ||
| 103 | }; | 109 | }; |
| 104 | 110 | ||
| 105 | Coordinate | 111 | Coordinate |
| 106 | coord_epud = { | 112 | coord_epud = { |
| 107 | .index = index_epud, | 113 | .index = index_epud, |
| 108 | .cube = antindex_epud, | ||
| 109 | .max = FACTORIAL8, | 114 | .max = FACTORIAL8, |
| 115 | .move = move_epud, | ||
| 110 | }; | 116 | }; |
| 111 | 117 | ||
| 112 | Coordinate | 118 | Coordinate |
| 113 | coord_drud = { | 119 | coord_drud = { |
| 114 | .index = index_drud, | 120 | .index = index_drud, |
| 115 | .cube = antindex_drud, | ||
| 116 | .max = POW2TO11 * POW3TO7 * BINOM12ON4, | 121 | .max = POW2TO11 * POW3TO7 * BINOM12ON4, |
| 122 | .move = move_drud, | ||
| 117 | }; | 123 | }; |
| 118 | 124 | ||
| 119 | Coordinate | 125 | Coordinate |
| 120 | coord_htr_drud = { | 126 | coord_htr_drud = { |
| 121 | .index = index_htr_drud, | 127 | .index = index_htr_drud, |
| 122 | .cube = antindex_htr_drud, | ||
| 123 | .max = BINOM8ON4 * 6 * BINOM8ON4, | 128 | .max = BINOM8ON4 * 6 * BINOM8ON4, |
| 129 | .move = move_htr_drud, | ||
| 124 | }; | 130 | }; |
| 125 | 131 | ||
| 126 | Coordinate | 132 | Coordinate |
| 127 | coord_htrfin = { | 133 | coord_htrfin = { |
| 128 | .index = index_htrfin, | 134 | .index = index_htrfin, |
| 129 | .cube = antindex_htrfin, | ||
| 130 | .max = 24 * 24 * 24 *24 * 24 / 6, /* should be /12 but it's ok */ | 135 | .max = 24 * 24 * 24 *24 * 24 / 6, /* should be /12 but it's ok */ |
| 136 | .move = move_htrfin, | ||
| 131 | }; | 137 | }; |
| 132 | 138 | ||
| 133 | Coordinate | 139 | Coordinate |
| 134 | coord_drud_eofb = { | 140 | coord_drud_eofb = { |
| 135 | .index = index_drud_eofb, | 141 | .index = index_drud_eofb, |
| 136 | .cube = antindex_drud_eofb, | ||
| 137 | .max = POW3TO7 * BINOM12ON4, | 142 | .max = POW3TO7 * BINOM12ON4, |
| 143 | .move = move_drud_eofb, | ||
| 138 | }; | 144 | }; |
| 139 | 145 | ||
| 140 | Coordinate | 146 | Coordinate |
| 141 | coord_cpud_separate = { | 147 | coord_cpud_separate = { |
| 142 | .index = index_cpud_separate, | 148 | .index = index_cpud_separate, |
| 143 | .cube = antindex_cpud_separate, | ||
| 144 | .max = BINOM8ON4, | 149 | .max = BINOM8ON4, |
| 150 | .move = move_cpud_separate, | ||
| 145 | }; | 151 | }; |
| 146 | 152 | ||
| 147 | /* Antindexers ***************************************************************/ | 153 | /* Indexers ******************************************************************/ |
| 148 | 154 | ||
| 149 | static Cube | 155 | static uint64_t |
| 150 | antindex_eofb(uint64_t ind) | 156 | index_eofb(Cube cube) |
| 151 | { | 157 | { |
| 152 | /* The returned cube is consistent */ | 158 | return cube.eofb; |
| 153 | Cube ret = {0}; | ||
| 154 | |||
| 155 | ret.eofb = ind; | ||
| 156 | ret.eorl = ind; | ||
| 157 | ret.eoud = ind; | ||
| 158 | |||
| 159 | return ret; | ||
| 160 | } | 159 | } |
| 161 | 160 | ||
| 162 | static Cube | 161 | static uint64_t |
| 163 | antindex_eofbepos(uint64_t ind) | 162 | index_eofbepos(Cube cube) |
| 164 | { | 163 | { |
| 165 | /* The returned cube is NOT consistent: eoud can be wrong */ | 164 | return (cube.epose / FACTORIAL4) * POW2TO11 + cube.eofb; |
| 166 | Cube ret = {0}; | 165 | } |
| 167 | |||
| 168 | /* We need eorl for sym16 coordinate */ | ||
| 169 | static int initialized = false; | ||
| 170 | static uint64_t eorl_a[POW2TO11][BINOM12ON4]; | ||
| 171 | static int eo_aux[12], ep_aux[12]; | ||
| 172 | unsigned int i, j, k; | ||
| 173 | |||
| 174 | if (!initialized) { | ||
| 175 | for (i = 0; i < POW2TO11; i++) { | ||
| 176 | for (j = 0; j < BINOM12ON4; j++) { | ||
| 177 | int_to_sum_zero_array(i, 2, 12, eo_aux); | ||
| 178 | index_to_subset(j, 12, 4, ep_aux); | ||
| 179 | for (k = 0; k < 12; k++) | ||
| 180 | if ((ep_aux[k] && k < FR) || | ||
| 181 | (!ep_aux[k] && k >= FR)) | ||
| 182 | eo_aux[k] = 1 - eo_aux[k]; | ||
| 183 | eorl_a[i][j] = digit_array_to_int(eo_aux,11,2); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | 166 | ||
| 187 | initialized = true; | 167 | static uint64_t |
| 188 | } | 168 | index_epud(Cube cube) |
| 169 | { | ||
| 170 | uint64_t ret; | ||
| 171 | CubeArray *arr = new_cubearray(cube, pf_ep); | ||
| 189 | 172 | ||
| 190 | ret.eofb = ind % POW2TO11; | 173 | ret = perm_to_index(arr->ep, 8); |
| 191 | ret.epose = (ind / POW2TO11) * 24; | 174 | free_cubearray(arr, pf_ep); |
| 192 | ret.eorl = eorl_a[ret.eofb][ret.epose/24]; | ||
| 193 | 175 | ||
| 194 | return ret; | 176 | return ret; |
| 195 | } | 177 | } |
| 196 | 178 | ||
| 197 | static Cube | 179 | static uint64_t |
| 198 | antindex_epud(uint64_t ind) | 180 | index_coud(Cube cube) |
| 199 | { | 181 | { |
| 200 | /* The returned cube is consistent */ | 182 | return cube.coud; |
| 201 | static bool initialized = false; | ||
| 202 | static Cube epud_aux[FACTORIAL8]; | ||
| 203 | int a[12]; | ||
| 204 | uint64_t ui; | ||
| 205 | CubeArray arr; | ||
| 206 | |||
| 207 | if (!initialized) { | ||
| 208 | a[FR] = FR; | ||
| 209 | a[FL] = FL; | ||
| 210 | a[BL] = BL; | ||
| 211 | a[BR] = BR; | ||
| 212 | for (ui = 0; ui < FACTORIAL8; ui++) { | ||
| 213 | index_to_perm(ui, 8, a); | ||
| 214 | arr.ep = a; | ||
| 215 | epud_aux[ui] = arrays_to_cube(&arr, pf_ep); | ||
| 216 | } | ||
| 217 | |||
| 218 | initialized = true; | ||
| 219 | } | ||
| 220 | |||
| 221 | return epud_aux[ind]; | ||
| 222 | } | 183 | } |
| 223 | 184 | ||
| 224 | static Cube | 185 | static uint64_t |
| 225 | antindex_coud(uint64_t ind) | 186 | index_corners(Cube cube) |
| 226 | { | 187 | { |
| 227 | /* The returned cube is consistent */ | 188 | return cube.coud * FACTORIAL8 + cube.cp; |
| 228 | Cube ret = {0}; | ||
| 229 | |||
| 230 | ret.coud = ind; | ||
| 231 | ret.corl = ind; | ||
| 232 | ret.cofb = ind; | ||
| 233 | |||
| 234 | return ret; | ||
| 235 | } | 189 | } |
| 236 | 190 | ||
| 237 | static Cube | 191 | static uint64_t |
| 238 | antindex_corners(uint64_t ind) | 192 | index_cp(Cube cube) |
| 239 | { | 193 | { |
| 240 | /* The returned cube is NOT consistent: corl and cofb can be wrong */ | 194 | return cube.cp; |
| 241 | /* TODO: remember to make this consistent if I use this for symcoord */ | ||
| 242 | Cube ret = {0}; | ||
| 243 | |||
| 244 | ret.coud = ind / FACTORIAL8; | ||
| 245 | ret.cp = ind % FACTORIAL8; | ||
| 246 | |||
| 247 | return ret; | ||
| 248 | } | 195 | } |
| 249 | 196 | ||
| 250 | static Cube | 197 | static uint64_t |
| 251 | antindex_cp(uint64_t ind) | 198 | index_cphtr(Cube cube) |
| 252 | { | 199 | { |
| 253 | /* The returned cube is NOT consistent: co can be wrong in all axes */ | 200 | return cphtr_right_cosets[cube.cp]; |
| 254 | Cube ret = {0}; | 201 | } |
| 255 | 202 | ||
| 256 | ret.cp = ind; | 203 | static uint64_t |
| 204 | index_cornershtr(Cube cube) | ||
| 205 | { | ||
| 206 | return cube.coud * BINOM8ON4 * 6 + index_cphtr(cube); | ||
| 207 | } | ||
| 257 | 208 | ||
| 258 | return ret; | 209 | static uint64_t |
| 210 | index_cornershtrfin(Cube cube) | ||
| 211 | { | ||
| 212 | return cornershtrfin_ind[cube.cp]; | ||
| 259 | } | 213 | } |
| 260 | 214 | ||
| 261 | static Cube | 215 | static uint64_t |
| 262 | antindex_cphtr(uint64_t ind) | 216 | index_drud(Cube cube) |
| 263 | { | 217 | { |
| 264 | /* The returned cube is NOT consistent: co can be wrong in all axes */ | 218 | uint64_t a, b, c; |
| 265 | Cube ret = {0}; | ||
| 266 | 219 | ||
| 267 | ret.cp = cphtr_right_rep[ind]; | 220 | a = cube.eofb; |
| 221 | b = cube.coud; | ||
| 222 | c = cube.epose / FACTORIAL4; | ||
| 268 | 223 | ||
| 269 | return ret; | 224 | b *= POW2TO11; |
| 225 | c *= POW2TO11 * POW3TO7; | ||
| 226 | |||
| 227 | return a + b + c; | ||
| 270 | } | 228 | } |
| 271 | 229 | ||
| 272 | static Cube | 230 | static uint64_t |
| 273 | antindex_cornershtr(uint64_t ind) | 231 | index_drud_eofb(Cube cube) |
| 274 | { | 232 | { |
| 275 | /* The returned cube is NOT consistent: corl and cofb can be wrong */ | 233 | return index_drud(cube) / POW2TO11; |
| 276 | Cube ret = antindex_cphtr(ind % (BINOM8ON4 * 6)); | ||
| 277 | |||
| 278 | ret.coud = ind / (BINOM8ON4 * 6); | ||
| 279 | |||
| 280 | return ret; | ||
| 281 | } | 234 | } |
| 282 | 235 | ||
| 283 | static Cube | 236 | static uint64_t |
| 284 | antindex_cornershtrfin(uint64_t ind) | 237 | index_htr_drud(Cube cube) |
| 285 | { | 238 | { |
| 286 | /* The returned cube is consistent */ | 239 | uint64_t a, b; |
| 287 | Cube ret = {0}; | ||
| 288 | 240 | ||
| 289 | ret.cp = cornershtrfin_ant[ind]; | 241 | a = index_cphtr(cube); |
| 242 | b = htr_eposs_ind[cube.eposs/24]; | ||
| 290 | 243 | ||
| 291 | return ret; | 244 | return a * BINOM8ON4 + b; |
| 292 | } | 245 | } |
| 293 | 246 | ||
| 294 | static Cube | 247 | static uint64_t |
| 295 | antindex_drud(uint64_t ind) | 248 | index_htrfin(Cube cube) |
| 296 | { | 249 | { |
| 297 | /* The returned cube is NOT consistent in the same way as eofbepos */ | 250 | uint64_t epe, eps, epm, cp, ep; |
| 298 | /* (see above). It works with sym16 coordinates */ | ||
| 299 | uint64_t epos, eofb; | ||
| 300 | Cube ret = {0}; | ||
| 301 | |||
| 302 | eofb = ind % POW2TO11; | ||
| 303 | epos = ind / (POW2TO11 * POW3TO7); | ||
| 304 | ret = antindex_eofbepos(eofb + POW2TO11 * epos); | ||
| 305 | 251 | ||
| 306 | ret.coud = (ind / POW2TO11) % POW3TO7; | 252 | epe = cube.epose % 24; |
| 307 | ret.corl = ret.coud; | 253 | eps = cube.eposs % 24; |
| 308 | ret.cofb = ret.coud; | 254 | epm = cube.eposm % 24; |
| 255 | ep = (epe * 24 + eps) *24 + epm; | ||
| 256 | cp = index_cornershtrfin(cube); | ||
| 309 | 257 | ||
| 310 | return ret; | 258 | return cp * 24 * 24 * 24 + ep; |
| 311 | } | 259 | } |
| 312 | 260 | ||
| 313 | static Cube | 261 | static uint64_t |
| 314 | antindex_drud_eofb(uint64_t ind) | 262 | index_cpud_separate(Cube cube) |
| 315 | { | 263 | { |
| 316 | /* The returned cube is NOT consistent (see antindex_drud) */ | 264 | return cpud_separate_ind[cube.cp]; |
| 317 | return antindex_drud(ind * POW2TO11); | ||
| 318 | } | 265 | } |
| 319 | 266 | ||
| 320 | static Cube | 267 | /* Coordinate movers *********************************************************/ |
| 321 | antindex_htr_drud(uint64_t ind) | ||
| 322 | { | ||
| 323 | /* The returned cube is NOT consistent: corl and cofb can be wrong */ | ||
| 324 | /* (see cphtr) and eposm can be wrong too (not epose because dr). */ | ||
| 325 | Cube ret = {0}; | ||
| 326 | static bool initialized = false; | ||
| 327 | static int aux[BINOM8ON4], ep[12], ep2[12]; | ||
| 328 | static int eps_solved[4] = {UL, UR, DL, DR}; | ||
| 329 | unsigned int i, j, k; | ||
| 330 | 268 | ||
| 331 | if (!initialized) { | 269 | static uint64_t |
| 332 | for (i = 0; i < BINOM8ON4; i++) { | 270 | move_eofb(Move m, uint64_t ind) |
| 333 | for (j = 0; j < 12; j++) | 271 | { |
| 334 | ep[j] = ep2[j] = 0; | 272 | return eofb_mtable[m][ind]; |
| 335 | index_to_subset(i, 8, 4, ep); | ||
| 336 | for (j = 0, k = 0; j < 8; j++) | ||
| 337 | ep2[j] = ep[j/2+4*(j%2)] ? eps_solved[k++] : 0; | ||
| 338 | aux[i] = array_ep_to_epos(ep2, eps_solved); | ||
| 339 | } | ||
| 340 | |||
| 341 | initialized = true; | ||
| 342 | } | ||
| 343 | |||
| 344 | ret = antindex_cphtr(ind / BINOM8ON4); | ||
| 345 | ret.epose = 0; | ||
| 346 | ret.eposs = aux[ind % BINOM8ON4]; | ||
| 347 | |||
| 348 | return ret; | ||
| 349 | } | 273 | } |
| 350 | 274 | ||
| 351 | static Cube | 275 | static uint64_t |
| 352 | antindex_htrfin(uint64_t ind) | 276 | move_eofbepos(Move m, uint64_t ind) |
| 353 | { | 277 | { |
| 354 | /* The returned cube is consistent */ | 278 | uint64_t a, b; |
| 355 | Cube ret = {0}; | ||
| 356 | |||
| 357 | ret = antindex_cornershtrfin(ind/(24*24*24)); | ||
| 358 | 279 | ||
| 359 | ret.eposm = ind % 24; | 280 | a = epose_mtable[m][(ind / POW2TO11)*24]; |
| 360 | ind /= 24; | 281 | b = eofb_mtable[m][ind % POW2TO11]; |
| 361 | ret.eposs = ind % 24; | ||
| 362 | ind /= 24; | ||
| 363 | ret.epose = ind % 24; | ||
| 364 | 282 | ||
| 365 | return ret; | 283 | return a/24 + b; |
| 366 | } | 284 | } |
| 367 | 285 | ||
| 368 | static Cube | 286 | static uint64_t |
| 369 | antindex_cpud_separate(uint64_t ind) | 287 | move_epud(Move m, uint64_t ind) |
| 370 | { | 288 | { |
| 371 | /* Not consistent because of side corner orientations and cp */ | 289 | /* TODO: save to file? */ |
| 372 | unsigned int ui; | ||
| 373 | int i, co[8], cp[8]; | ||
| 374 | Corner u, d; | ||
| 375 | |||
| 376 | static Cube aux[BINOM8ON4]; | ||
| 377 | static bool initialized = false; | 290 | static bool initialized = false; |
| 291 | static int a[12] = { [8] = 8, [9] = 9, [10] = 10, [11] = 11 }; | ||
| 292 | static int shortlist[NMOVES] = { | ||
| 293 | [U] = 0, [U2] = 1, [U3] = 2, [D] = 3, [D2] = 4, [D3] = 5, | ||
| 294 | [R2] = 6, [L2] = 7, [F2] = 8, [B2] = 9 | ||
| 295 | }; | ||
| 296 | static uint64_t aux[10][FACTORIAL8]; | ||
| 297 | uint64_t ui; | ||
| 298 | int j; | ||
| 299 | Move mj; | ||
| 300 | Cube c; | ||
| 301 | CubeArray *arr, *auxarr; | ||
| 302 | |||
| 303 | if (!moveset_drud.allowed(m)) { | ||
| 304 | fprintf(stderr, "Move not allowed for epud\n" | ||
| 305 | "This is a bug, please report\n"); | ||
| 306 | return coord_epud.max; | ||
| 307 | } | ||
| 378 | 308 | ||
| 379 | if (!initialized) { | 309 | if (!initialized) { |
| 380 | for (ui = 0; ui < BINOM8ON4; ui++) { | 310 | auxarr = malloc(sizeof(CubeArray)); |
| 381 | index_to_subset(ui, 8, 4, co); | 311 | auxarr->ep = a; |
| 382 | for (i = 0, u = UFR, d = DFR; i < 8; i++) | 312 | for (ui = 0; ui < coord_epud.max; ui++) { |
| 383 | cp[i] = co[i] ? d++ : u++; | 313 | index_to_perm(ui, 8, a); |
| 384 | aux[ui] = (Cube){.cp = perm_to_index(cp, 8)}; | 314 | c = arrays_to_cube(auxarr, pf_ep); |
| 315 | for (j = 0; moveset_drud.sorted_moves[j] != NULLMOVE; | ||
| 316 | j++) { | ||
| 317 | mj = moveset_drud.sorted_moves[j]; | ||
| 318 | arr = new_cubearray(apply_move(mj, c), pf_ep); | ||
| 319 | aux[shortlist[mj]][ui] = | ||
| 320 | perm_to_index(arr->ep, 8); | ||
| 321 | free_cubearray(arr, pf_ep); | ||
| 322 | } | ||
| 385 | } | 323 | } |
| 324 | free(auxarr); | ||
| 386 | 325 | ||
| 387 | initialized = true; | 326 | initialized = true; |
| 388 | } | 327 | } |
| 389 | 328 | ||
| 390 | return aux[ind]; | 329 | return aux[shortlist[m]][ind]; |
| 391 | } | ||
| 392 | |||
| 393 | /* Indexers ******************************************************************/ | ||
| 394 | |||
| 395 | static uint64_t | ||
| 396 | index_eofb(Cube cube) | ||
| 397 | { | ||
| 398 | return cube.eofb; | ||
| 399 | } | 330 | } |
| 400 | 331 | ||
| 401 | static uint64_t | 332 | static uint64_t |
| 402 | index_eofbepos(Cube cube) | 333 | move_coud(Move m, uint64_t ind) |
| 403 | { | 334 | { |
| 404 | return (cube.epose / FACTORIAL4) * POW2TO11 + cube.eofb; | 335 | return coud_mtable[m][ind]; |
| 405 | } | 336 | } |
| 406 | 337 | ||
| 407 | static uint64_t | 338 | static uint64_t |
| 408 | index_epud(Cube cube) | 339 | move_corners(Move m, uint64_t ind) |
| 409 | { | 340 | { |
| 410 | uint64_t ret; | 341 | uint64_t a, b; |
| 411 | CubeArray *arr = new_cubearray(cube, pf_ep); | ||
| 412 | 342 | ||
| 413 | ret = perm_to_index(arr->ep, 8); | 343 | a = coud_mtable[m][ind / FACTORIAL8]; |
| 414 | free_cubearray(arr, pf_ep); | 344 | b = cp_mtable[m][ind % FACTORIAL8]; |
| 415 | 345 | ||
| 416 | return ret; | 346 | return a * FACTORIAL8 + b; |
| 417 | } | 347 | } |
| 418 | 348 | ||
| 419 | static uint64_t | 349 | static uint64_t |
| 420 | index_coud(Cube cube) | 350 | move_cp(Move m, uint64_t ind) |
| 421 | { | 351 | { |
| 422 | return cube.coud; | 352 | return cp_mtable[m][ind]; |
| 423 | } | 353 | } |
| 424 | 354 | ||
| 425 | static uint64_t | 355 | static uint64_t |
| 426 | index_corners(Cube cube) | 356 | move_cphtr(Move m, uint64_t ind) |
| 427 | { | 357 | { |
| 428 | return cube.coud * FACTORIAL8 + cube.cp; | 358 | static bool initialized = false; |
| 429 | } | 359 | static uint64_t aux[NMOVES][BINOM8ON4*6]; |
| 360 | uint64_t ui; | ||
| 361 | Move j; | ||
| 430 | 362 | ||
| 431 | static uint64_t | 363 | if (!initialized) { |
| 432 | index_cp(Cube cube) | 364 | for (ui = 0; ui < BINOM8ON4*6; ui++) |
| 433 | { | 365 | for (j = U; j < NMOVES; j++) |
| 434 | return cube.cp; | 366 | aux[j][ui] = |
| 435 | } | 367 | cp_mtable[j][cphtr_right_rep[ind]]; |
| 436 | 368 | ||
| 437 | static uint64_t | 369 | initialized = true; |
| 438 | index_cphtr(Cube cube) | 370 | } |
| 439 | { | 371 | |
| 440 | return cphtr_right_cosets[cube.cp]; | 372 | return aux[m][ind]; |
| 441 | } | 373 | } |
| 442 | 374 | ||
| 443 | static uint64_t | 375 | static uint64_t |
| 444 | index_cornershtr(Cube cube) | 376 | move_cornershtr(Move m, uint64_t ind) |
| 445 | { | 377 | { |
| 446 | return cube.coud * BINOM8ON4 * 6 + index_cphtr(cube); | 378 | uint64_t a, b; |
| 379 | |||
| 380 | a = coud_mtable[m][ind/(BINOM8ON4 * 6)]; | ||
| 381 | b = move_cphtr(m, ind % (BINOM8ON4 * 6)); | ||
| 382 | |||
| 383 | return a * BINOM8ON4 * 6 + b; | ||
| 447 | } | 384 | } |
| 448 | 385 | ||
| 449 | static uint64_t | 386 | static uint64_t |
| 450 | index_cornershtrfin(Cube cube) | 387 | move_cornershtrfin(Move m, uint64_t ind) |
| 451 | { | 388 | { |
| 452 | return cornershtrfin_ind[cube.cp]; | 389 | int a; |
| 390 | |||
| 391 | a = cp_mtable[m][cornershtrfin_ant[ind]]; | ||
| 392 | |||
| 393 | return cornershtrfin_ind[a]; | ||
| 453 | } | 394 | } |
| 454 | 395 | ||
| 455 | static uint64_t | 396 | static uint64_t |
| 456 | index_drud(Cube cube) | 397 | move_drud(Move m, uint64_t ind) |
| 457 | { | 398 | { |
| 458 | uint64_t a, b, c; | 399 | uint64_t a, b, c; |
| 459 | 400 | ||
| 460 | a = cube.eofb; | 401 | a = eofb_mtable[m][ind % POW2TO11]; |
| 461 | b = cube.coud; | 402 | b = coud_mtable[m][(ind / POW2TO11) % POW3TO7]; |
| 462 | c = cube.epose / FACTORIAL4; | 403 | c = epose_mtable[m][ind / (POW2TO11 * POW3TO7)]; |
| 463 | |||
| 464 | b *= POW2TO11; | ||
| 465 | c *= POW2TO11 * POW3TO7; | ||
| 466 | 404 | ||
| 467 | return a + b + c; | 405 | return a + (b + c * POW3TO7) * POW2TO11; |
| 468 | } | 406 | } |
| 469 | 407 | ||
| 470 | static uint64_t | 408 | static uint64_t |
| 471 | index_drud_eofb(Cube cube) | 409 | move_drud_eofb(Move m, uint64_t ind) |
| 472 | { | 410 | { |
| 473 | return index_drud(cube) / POW2TO11; | 411 | uint64_t a, b; |
| 412 | |||
| 413 | a = coud_mtable[m][ind % POW3TO7]; | ||
| 414 | b = epose_mtable[m][ind / POW3TO7]; | ||
| 415 | |||
| 416 | return a + b * POW3TO7; | ||
| 474 | } | 417 | } |
| 475 | 418 | ||
| 476 | static uint64_t | 419 | static uint64_t |
| 477 | index_htr_drud(Cube cube) | 420 | move_htr_drud(Move m, uint64_t ind) |
| 478 | { | 421 | { |
| 479 | static bool initialized = false; | 422 | uint64_t a, b; |
| 480 | static int aux[BINOM12ON4], ep[12], ep2[12]; | ||
| 481 | static int eps_solved[4] = {UL, UR, DL, DR}; | ||
| 482 | unsigned int i, j; | ||
| 483 | 423 | ||
| 484 | if (!initialized) { | 424 | a = move_cphtr(m, ind/BINOM8ON4); |
| 485 | for (i = 0; i < BINOM12ON4; i++) { | 425 | b = eposs_mtable[m][htr_eposs_ant[ind%BINOM8ON4]]; |
| 486 | for (j = 0; j < 12; j++) | ||
| 487 | ep[j] = ep2[j] = 0; | ||
| 488 | epos_to_partial_ep(i*24, ep, eps_solved); | ||
| 489 | for (j = 0; j < 8; j++) | ||
| 490 | ep2[j/2 + 4*(j%2)] = ep[j] ? 1 : 0; | ||
| 491 | aux[i] = subset_to_index(ep2, 8, 4); | ||
| 492 | } | ||
| 493 | 426 | ||
| 494 | initialized = true; | 427 | return a*BINOM8ON4 + htr_eposs_ind[b/24]; |
| 495 | } | ||
| 496 | |||
| 497 | return index_cphtr(cube) * BINOM8ON4 + aux[cube.eposs/24]; | ||
| 498 | } | 428 | } |
| 499 | 429 | ||
| 500 | static uint64_t | 430 | static uint64_t |
| 501 | index_htrfin(Cube cube) | 431 | move_htrfin(Move m, uint64_t ind) |
| 502 | { | 432 | { |
| 503 | uint64_t epe, eps, epm, cp, ep; | 433 | uint64_t a, b, bm, bs, be; |
| 504 | 434 | ||
| 505 | epe = cube.epose % 24; | 435 | a = move_cornershtrfin(m, ind % (24*24*24)); |
| 506 | eps = cube.eposs % 24; | 436 | bm = eposm_mtable[m][ind%24] % 24; |
| 507 | epm = cube.eposm % 24; | 437 | bs = eposs_mtable[m][(ind/24)%24] % 24; |
| 508 | ep = (epe * 24 + eps) *24 + epm; | 438 | be = epose_mtable[m][ind/(24*24)] % 24; |
| 509 | cp = index_cornershtrfin(cube); | 439 | b = (be * 24 + bs) * 24 + bm; |
| 510 | 440 | ||
| 511 | return cp * 24 * 24 * 24 + ep; | 441 | return a * (24*24*24) + b; |
| 512 | } | 442 | } |
| 513 | 443 | ||
| 514 | static uint64_t | 444 | static uint64_t |
| 515 | index_cpud_separate(Cube cube) | 445 | move_cpud_separate(Move m, uint64_t ind) |
| 516 | { | 446 | { |
| 517 | unsigned int ui; | 447 | return cpud_separate_ind[cp_mtable[m][cpud_separate_ant[ind]]]; |
| 518 | int i, co[8]; | ||
| 519 | |||
| 520 | static int aux[FACTORIAL8]; | ||
| 521 | static bool initialized = false; | ||
| 522 | |||
| 523 | if (!initialized) { | ||
| 524 | for (ui = 0; ui < FACTORIAL8; ui++) { | ||
| 525 | for (i = 0; i < 8; i++) | ||
| 526 | co[i] = what_corner_at((Cube){.cp=ui},i)>UBR ? | ||
| 527 | 1 : 0; | ||
| 528 | aux[ui] = subset_to_index(co, 8, 4); | ||
| 529 | } | ||
| 530 | |||
| 531 | initialized = true; | ||
| 532 | } | ||
| 533 | |||
| 534 | return aux[cube.cp]; | ||
| 535 | } | 448 | } |
| 536 | 449 | ||
| 537 | /* Init functions implementation *********************************************/ | 450 | /* Init functions implementation *********************************************/ |
| @@ -618,6 +531,20 @@ init_cphtr_right_cosets_color(int i, int d) | |||
| 618 | } | 531 | } |
| 619 | 532 | ||
| 620 | static void | 533 | static void |
| 534 | init_cpud_separate() | ||
| 535 | { | ||
| 536 | unsigned int ui; | ||
| 537 | int i, co[8]; | ||
| 538 | |||
| 539 | for (ui = 0; ui < FACTORIAL8; ui++) { | ||
| 540 | for (i = 0; i < 8; i++) | ||
| 541 | co[i] = what_corner_at((Cube){.cp=ui},i)>UBR ? 1 : 0; | ||
| 542 | cpud_separate_ind[ui] = subset_to_index(co, 8, 4); | ||
| 543 | cpud_separate_ant[cpud_separate_ind[ui]] = ui; | ||
| 544 | } | ||
| 545 | } | ||
| 546 | |||
| 547 | static void | ||
| 621 | init_cornershtrfin() | 548 | init_cornershtrfin() |
| 622 | { | 549 | { |
| 623 | unsigned int i, j; | 550 | unsigned int i, j; |
| @@ -649,28 +576,21 @@ init_cornershtrfin() | |||
| 649 | } | 576 | } |
| 650 | 577 | ||
| 651 | void | 578 | void |
| 652 | test_coord(Coordinate *coord) | 579 | init_htr_eposs() |
| 653 | { | 580 | { |
| 654 | bool passed; | 581 | int ep[12], ep2[12]; |
| 655 | uint64_t ui, failcount; | 582 | int eps_solved[4] = {UL, UR, DL, DR}; |
| 656 | 583 | unsigned int i, j; | |
| 657 | if (!(passed = (coord->index((Cube){0}) == 0))) { | ||
| 658 | printf("Failed: coordinate of solved cube is " | ||
| 659 | "%" PRIu64 "\n", coord->index((Cube){0})); | ||
| 660 | } | ||
| 661 | 584 | ||
| 662 | printf("Testing %" PRIu64 " coordinates\n", coord->max); | 585 | for (i = 0; i < BINOM12ON4; i++) { |
| 663 | for (failcount = 0, ui = 0; ui < coord->max; ui++) { | 586 | for (j = 0; j < 12; j++) |
| 664 | if (!(passed = (coord->index(coord->cube(ui)) == ui))) { | 587 | ep[j] = ep2[j] = 0; |
| 665 | printf("Failed at %" PRIu64 "\n", ui); | 588 | epos_to_partial_ep(i*24, ep, eps_solved); |
| 666 | failcount++; | 589 | for (j = 0; j < 8; j++) |
| 667 | } | 590 | ep2[j/2 + 4*(j%2)] = ep[j] ? 1 : 0; |
| 591 | htr_eposs_ind[i] = subset_to_index(ep2, 8, 4); | ||
| 592 | htr_eposs_ant[htr_eposs_ind[i]] = i*24; | ||
| 668 | } | 593 | } |
| 669 | |||
| 670 | if (passed) | ||
| 671 | printf("Ok\n"); | ||
| 672 | else | ||
| 673 | printf("Test failed in %" PRIu64 " cases\n", failcount); | ||
| 674 | } | 594 | } |
| 675 | 595 | ||
| 676 | void | 596 | void |
| @@ -685,5 +605,7 @@ init_coord() | |||
| 685 | 605 | ||
| 686 | init_cphtr_cosets(); | 606 | init_cphtr_cosets(); |
| 687 | init_cornershtrfin(); | 607 | init_cornershtrfin(); |
| 608 | init_htr_eposs(); | ||
| 609 | init_cpud_separate(); | ||
| 688 | } | 610 | } |
| 689 | 611 | ||
diff --git a/src/coord.h b/src/coord.h index 81e5866..61398a4 100644 --- a/src/coord.h +++ b/src/coord.h | |||
| @@ -18,7 +18,10 @@ extern Coordinate coord_htr_drud; | |||
| 18 | extern Coordinate coord_htrfin; | 18 | extern Coordinate coord_htrfin; |
| 19 | extern Coordinate coord_cpud_separate; | 19 | extern Coordinate coord_cpud_separate; |
| 20 | 20 | ||
| 21 | void test_coord(Coordinate *coord); | 21 | extern int cpud_separate_ant[BINOM8ON4]; |
| 22 | extern int cpud_separate_ind[FACTORIAL8]; | ||
| 23 | extern int cornershtrfin_ant[24*24/6]; | ||
| 24 | |||
| 22 | void init_coord(); | 25 | void init_coord(); |
| 23 | 26 | ||
| 24 | #endif | 27 | #endif |
| @@ -2,8 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | /* Local functions ***********************************************************/ | 3 | /* Local functions ***********************************************************/ |
| 4 | 4 | ||
| 5 | static void fix_eorleoud(CubeArray *arr); | ||
| 6 | static void fix_cofbcorl(CubeArray *arr); | ||
| 7 | static void init_inverse(); | 5 | static void init_inverse(); |
| 8 | static bool read_invtables_file(); | 6 | static bool read_invtables_file(); |
| 9 | static bool write_invtables_file(); | 7 | static bool write_invtables_file(); |
| @@ -126,6 +124,30 @@ cube_to_arrays(Cube cube, CubeArray *arr, PieceFilter f) | |||
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | void | 126 | void |
| 127 | epos_to_compatible_ep(int epos, int *ep, int *ss) | ||
| 128 | { | ||
| 129 | int i, j, k, other[8]; | ||
| 130 | bool flag; | ||
| 131 | |||
| 132 | for (i = 0; i < 12; i++) | ||
| 133 | ep[i] = -1; | ||
| 134 | |||
| 135 | epos_to_partial_ep(epos, ep, ss); | ||
| 136 | |||
| 137 | for (i = 0, j = 0; i < 12; i++) { | ||
| 138 | flag = false; | ||
| 139 | for (k = 0; k < 4; k++) | ||
| 140 | flag = flag || (i == ss[k]); | ||
| 141 | if (!flag) | ||
| 142 | other[j++] = i; | ||
| 143 | } | ||
| 144 | |||
| 145 | for (i = 0, j = 0; i < 12; i++) | ||
| 146 | if (ep[i] == -1) | ||
| 147 | ep[i] = other[j++]; | ||
| 148 | } | ||
| 149 | |||
| 150 | void | ||
| 129 | epos_to_partial_ep(int epos, int *ep, int *ss) | 151 | epos_to_partial_ep(int epos, int *ep, int *ss) |
| 130 | { | 152 | { |
| 131 | int i, is, eposs[12], eps[4]; | 153 | int i, is, eposs[12], eps[4]; |
| @@ -141,7 +163,7 @@ epos_to_partial_ep(int epos, int *ep, int *ss) | |||
| 141 | ep[i] = ss[eps[is++]]; | 163 | ep[i] = ss[eps[is++]]; |
| 142 | } | 164 | } |
| 143 | 165 | ||
| 144 | static void | 166 | void |
| 145 | fix_eorleoud(CubeArray *arr) | 167 | fix_eorleoud(CubeArray *arr) |
| 146 | { | 168 | { |
| 147 | int i; | 169 | int i; |
| @@ -163,7 +185,7 @@ fix_eorleoud(CubeArray *arr) | |||
| 163 | } | 185 | } |
| 164 | } | 186 | } |
| 165 | 187 | ||
| 166 | static void | 188 | void |
| 167 | fix_cofbcorl(CubeArray *arr) | 189 | fix_cofbcorl(CubeArray *arr) |
| 168 | { | 190 | { |
| 169 | int i; | 191 | int i; |
| @@ -23,6 +23,9 @@ bool is_solved_center(Cube cube, Center c); | |||
| 23 | bool is_solved_corner(Cube cube, Corner c); | 23 | bool is_solved_corner(Cube cube, Corner c); |
| 24 | bool is_solved_edge(Cube cube, Edge e); | 24 | bool is_solved_edge(Cube cube, Edge e); |
| 25 | void epos_to_partial_ep(int epos, int *ep, int *ss); | 25 | void epos_to_partial_ep(int epos, int *ep, int *ss); |
| 26 | void epos_to_compatible_ep(int epos, int *ep, int *ss); | ||
| 27 | void fix_eorleoud(CubeArray *arr); | ||
| 28 | void fix_cofbcorl(CubeArray *arr); | ||
| 26 | Cube fourval_to_cube(int eofb, int ep, int coud, int cp); | 29 | Cube fourval_to_cube(int eofb, int ep, int coud, int cp); |
| 27 | void free_cubearray(CubeArray *arr, PieceFilter f); | 30 | void free_cubearray(CubeArray *arr, PieceFilter f); |
| 28 | Cube move_via_arrays(CubeArray *arr, Cube c, PieceFilter pf); | 31 | Cube move_via_arrays(CubeArray *arr, Cube c, PieceFilter pf); |
diff --git a/src/cubetypes.h b/src/cubetypes.h index 518c727..3ba667c 100644 --- a/src/cubetypes.h +++ b/src/cubetypes.h | |||
| @@ -168,11 +168,10 @@ struct | |||
| 168 | coordinate | 168 | coordinate |
| 169 | { | 169 | { |
| 170 | Indexer index; | 170 | Indexer index; |
| 171 | AntiIndexer cube; | ||
| 172 | uint64_t max; | 171 | uint64_t max; |
| 173 | TransFinder transfind; | ||
| 174 | CoordMover move; | 172 | CoordMover move; |
| 175 | CoordTransformer transform; | 173 | CoordTransformer transform; |
| 174 | SymData * sd; | ||
| 176 | }; | 175 | }; |
| 177 | 176 | ||
| 178 | struct | 177 | struct |
| @@ -324,8 +323,10 @@ symdata | |||
| 324 | int ntrans; | 323 | int ntrans; |
| 325 | Trans * trans; | 324 | Trans * trans; |
| 326 | uint64_t * class; | 325 | uint64_t * class; |
| 327 | Cube * rep; | 326 | uint64_t * unsym; |
| 328 | Trans * transtorep; | 327 | Trans * transtorep; |
| 328 | uint64_t * selfsim; | ||
| 329 | CoordTransformer transform; /* TODO: remove, use that of base coord */ | ||
| 329 | }; | 330 | }; |
| 330 | 331 | ||
| 331 | struct | 332 | struct |
diff --git a/src/pruning.c b/src/pruning.c index 2dea797..36445b7 100644 --- a/src/pruning.c +++ b/src/pruning.c | |||
| @@ -258,25 +258,25 @@ genptable_compress(PruneData *pd) | |||
| 258 | static void | 258 | static void |
| 259 | genptable_fixnasty(PruneData *pd, int d) | 259 | genptable_fixnasty(PruneData *pd, int d) |
| 260 | { | 260 | { |
| 261 | uint64_t i; | 261 | uint64_t i, ii, mask; |
| 262 | int j, n; | 262 | Trans t; |
| 263 | Cube c, cc; | ||
| 264 | Trans t[NTRANS]; | ||
| 265 | 263 | ||
| 266 | if (pd->coord->transfind == NULL) | 264 | if (pd->coord->sd == NULL) |
| 267 | return; | 265 | return; |
| 268 | 266 | ||
| 269 | for (i = 0; i < pd->coord->max; i++) { | 267 | for (i = 0; i < pd->coord->max; i++) { |
| 270 | if (ptableval_index(pd, i) == d) { | 268 | if (ptableval_index(pd, i) == d) { |
| 271 | n = pd->coord->transfind(i, t); | 269 | mask = pd->coord->sd->selfsim[i]; |
| 272 | if (n == 1) | 270 | if (mask == (1 << uf)) |
| 273 | continue; | 271 | continue; |
| 274 | 272 | ||
| 275 | c = pd->coord->cube(i); | 273 | for (t = 0; t < NTRANS; t++) { |
| 276 | for (j = 0; j < n; j++) { | 274 | if (!((1 << t) & mask)) |
| 277 | cc = apply_trans(t[j], c); | 275 | continue; |
| 278 | if (ptableval(pd, cc) > d) { | 276 | |
| 279 | ptable_update(pd, cc, d); | 277 | ii = pd->coord->transform(t, i); |
| 278 | if (ptableval_index(pd, ii) > d) { | ||
| 279 | ptable_update_index(pd, ii, d); | ||
| 280 | pd->n++; | 280 | pd->n++; |
| 281 | } | 281 | } |
| 282 | } | 282 | } |
| @@ -306,7 +306,6 @@ instance_bfs(void *arg) | |||
| 306 | ThreadDataGenpt *td; | 306 | ThreadDataGenpt *td; |
| 307 | uint64_t i, ii, blocksize, rmin, rmax, updated; | 307 | uint64_t i, ii, blocksize, rmin, rmax, updated; |
| 308 | int j, pval, ichunk; | 308 | int j, pval, ichunk; |
| 309 | Cube c, cc; | ||
| 310 | Move *ms; | 309 | Move *ms; |
| 311 | 310 | ||
| 312 | td = (ThreadDataGenpt *)arg; | 311 | td = (ThreadDataGenpt *)arg; |
| @@ -324,15 +323,14 @@ instance_bfs(void *arg) | |||
| 324 | pval = ptableval_index(td->pd, i); | 323 | pval = ptableval_index(td->pd, i); |
| 325 | pthread_mutex_unlock(td->mutex[ichunk]); | 324 | pthread_mutex_unlock(td->mutex[ichunk]); |
| 326 | if (pval == td->d) { | 325 | if (pval == td->d) { |
| 327 | c = td->pd->coord->cube(i); | ||
| 328 | for (j = 0; ms[j] != NULLMOVE; j++) { | 326 | for (j = 0; ms[j] != NULLMOVE; j++) { |
| 329 | cc = apply_move(ms[j], c); | 327 | ii = td->pd->coord->move(ms[j], i); |
| 330 | ii = td->pd->coord->index(cc); | ||
| 331 | ichunk = findchunk(td->pd, td->nchunks, ii); | 328 | ichunk = findchunk(td->pd, td->nchunks, ii); |
| 332 | pthread_mutex_lock(td->mutex[ichunk]); | 329 | pthread_mutex_lock(td->mutex[ichunk]); |
| 333 | pval = ptableval_index(td->pd, ii); | 330 | pval = ptableval_index(td->pd, ii); |
| 334 | if (pval > td->d+1) { | 331 | if (pval > td->d+1) { |
| 335 | ptable_update(td->pd, cc, td->d+1); | 332 | ptable_update_index(td->pd, |
| 333 | ii, td->d+1); | ||
| 336 | updated++; | 334 | updated++; |
| 337 | } | 335 | } |
| 338 | pthread_mutex_unlock(td->mutex[ichunk]); | 336 | pthread_mutex_unlock(td->mutex[ichunk]); |
diff --git a/src/symcoord.c b/src/symcoord.c index 38e13c6..83fba0a 100644 --- a/src/symcoord.c +++ b/src/symcoord.c | |||
| @@ -4,27 +4,43 @@ | |||
| 4 | #define CLASSES_CP_16 2768 | 4 | #define CLASSES_CP_16 2768 |
| 5 | #define CLASSES_EOFBEPOS_16 64430 | 5 | #define CLASSES_EOFBEPOS_16 64430 |
| 6 | 6 | ||
| 7 | static Cube antindex_cp_sym16(uint64_t ind); | ||
| 8 | static Cube antindex_eofbepos_sym16(uint64_t ind); | ||
| 9 | static Cube antindex_drud_sym16(uint64_t ind); | ||
| 10 | static Cube antindex_drudfin_noE_sym16(uint64_t ind); | ||
| 11 | static Cube antindex_nxopt31(uint64_t ind); | ||
| 12 | |||
| 13 | static uint64_t index_cp_sym16(Cube cube); | 7 | static uint64_t index_cp_sym16(Cube cube); |
| 14 | static uint64_t index_eofbepos_sym16(Cube cube); | 8 | static uint64_t index_eofbepos_sym16(Cube cube); |
| 15 | static uint64_t index_drud_sym16(Cube cube); | 9 | static uint64_t index_drud_sym16(Cube cube); |
| 16 | static uint64_t index_drudfin_noE_sym16(Cube cube); | 10 | static uint64_t index_drudfin_noE_sym16(Cube cube); |
| 17 | static uint64_t index_nxopt31(Cube cube); | 11 | static uint64_t index_nxopt31(Cube cube); |
| 18 | 12 | ||
| 19 | static int transfinder_drud_sym16(uint64_t ind, Trans *ret); | 13 | static uint64_t move_cp_sym16(Move m, uint64_t ind); |
| 20 | static int transfinder_drudfin_noE_sym16(uint64_t ind, Trans *ret); | 14 | static uint64_t move_eofbepos_sym16(Move m, uint64_t ind); |
| 21 | static int transfinder_nxopt31(uint64_t ind, Trans *ret); | 15 | static uint64_t move_drud_sym16(Move m, uint64_t ind); |
| 16 | static uint64_t move_drudfin_noE_sym16(Move m, uint64_t ind); | ||
| 17 | static uint64_t move_nxopt31(Move m, uint64_t ind); | ||
| 18 | |||
| 19 | static uint64_t transform_cp(Trans t, uint64_t ind); | ||
| 20 | static uint64_t transform_eofbepos(Trans t, uint64_t ind); | ||
| 21 | static uint64_t transform_drud_sym16(Trans t, uint64_t ind); | ||
| 22 | static uint64_t transform_drudfin_noE_sym16(Trans t, uint64_t ind); | ||
| 23 | static uint64_t transform_nxopt31(Trans t, uint64_t ind); | ||
| 22 | 24 | ||
| 23 | static void gensym(SymData *sd); | 25 | static void gensym(SymData *sd); |
| 26 | static void init_symc_moves(); | ||
| 27 | static void init_symc_trans(); | ||
| 24 | static bool read_symdata_file(SymData *sd); | 28 | static bool read_symdata_file(SymData *sd); |
| 25 | static int selfsims(SymData *sd, uint64_t ind, Trans *ret); | ||
| 26 | static bool write_symdata_file(SymData *sd); | 29 | static bool write_symdata_file(SymData *sd); |
| 27 | 30 | ||
| 31 | /* Some tables ***************************************************************/ | ||
| 32 | |||
| 33 | static uint64_t move_cp_16[NMOVES][CLASSES_CP_16]; | ||
| 34 | static uint64_t move_eofbepos_16[NMOVES][CLASSES_EOFBEPOS_16]; | ||
| 35 | |||
| 36 | static int trans_eofbepos[NTRANS][POW2TO11*BINOM12ON4]; | ||
| 37 | static int trans_epud[NTRANS][FACTORIAL8]; | ||
| 38 | static int trans_cpud_separate[NTRANS][BINOM8ON4]; | ||
| 39 | |||
| 40 | static Trans ttrep_move_cp_16[NMOVES][CLASSES_CP_16]; | ||
| 41 | static Trans ttrep_move_eofbepos_16[NMOVES][CLASSES_EOFBEPOS_16]; | ||
| 42 | |||
| 43 | |||
| 28 | /* Transformation groups and symmetry data ***********************************/ | 44 | /* Transformation groups and symmetry data ***********************************/ |
| 29 | 45 | ||
| 30 | static Trans | 46 | static Trans |
| @@ -37,20 +53,22 @@ trans_group_udfix[16] = { | |||
| 37 | 53 | ||
| 38 | static SymData | 54 | static SymData |
| 39 | sd_cp_16 = { | 55 | sd_cp_16 = { |
| 40 | .filename = "sd_cp_16", | 56 | .filename = "sd_cp_16_new", |
| 41 | .coord = &coord_cp, | 57 | .coord = &coord_cp, |
| 42 | .sym_coord = &coord_cp_sym16, | 58 | .sym_coord = &coord_cp_sym16, |
| 43 | .ntrans = 16, | 59 | .ntrans = 16, |
| 44 | .trans = trans_group_udfix | 60 | .trans = trans_group_udfix, |
| 61 | .transform = transform_cp, | ||
| 45 | }; | 62 | }; |
| 46 | 63 | ||
| 47 | static SymData | 64 | static SymData |
| 48 | sd_eofbepos_16 = { | 65 | sd_eofbepos_16 = { |
| 49 | .filename = "sd_eofbepos_16", | 66 | .filename = "sd_eofbepos_16_new", |
| 50 | .coord = &coord_eofbepos, | 67 | .coord = &coord_eofbepos, |
| 51 | .sym_coord = &coord_eofbepos_sym16, | 68 | .sym_coord = &coord_eofbepos_sym16, |
| 52 | .ntrans = 16, | 69 | .ntrans = 16, |
| 53 | .trans = trans_group_udfix | 70 | .trans = trans_group_udfix, |
| 71 | .transform = transform_eofbepos, | ||
| 54 | }; | 72 | }; |
| 55 | 73 | ||
| 56 | SymData * all_sd[] = { | 74 | SymData * all_sd[] = { |
| @@ -65,90 +83,44 @@ SymData * all_sd[] = { | |||
| 65 | Coordinate | 83 | Coordinate |
| 66 | coord_eofbepos_sym16 = { | 84 | coord_eofbepos_sym16 = { |
| 67 | .index = index_eofbepos_sym16, | 85 | .index = index_eofbepos_sym16, |
| 68 | .cube = antindex_eofbepos_sym16, | 86 | .move = move_eofbepos_sym16, |
| 69 | }; | 87 | }; |
| 70 | 88 | ||
| 71 | Coordinate | 89 | Coordinate |
| 72 | coord_cp_sym16 = { | 90 | coord_cp_sym16 = { |
| 73 | .index = index_cp_sym16, | 91 | .index = index_cp_sym16, |
| 74 | .cube = antindex_cp_sym16, | 92 | .move = move_cp_sym16, |
| 75 | }; | 93 | }; |
| 76 | 94 | ||
| 77 | Coordinate | 95 | Coordinate |
| 78 | coord_drud_sym16 = { | 96 | coord_drud_sym16 = { |
| 79 | .index = index_drud_sym16, | 97 | .index = index_drud_sym16, |
| 80 | .cube = antindex_drud_sym16, | 98 | .move = move_drud_sym16, |
| 81 | .max = POW3TO7 * CLASSES_EOFBEPOS_16, | 99 | .max = POW3TO7 * CLASSES_EOFBEPOS_16, |
| 82 | .transfind = transfinder_drud_sym16, | 100 | .transform = transform_drud_sym16, |
| 101 | .sd = &sd_cp_16, | ||
| 83 | }; | 102 | }; |
| 84 | 103 | ||
| 85 | Coordinate | 104 | Coordinate |
| 86 | coord_drudfin_noE_sym16 = { | 105 | coord_drudfin_noE_sym16 = { |
| 87 | .index = index_drudfin_noE_sym16, | 106 | .index = index_drudfin_noE_sym16, |
| 88 | .cube = antindex_drudfin_noE_sym16, | 107 | .move = move_drudfin_noE_sym16, |
| 89 | .max = FACTORIAL8 * CLASSES_CP_16, | 108 | .max = FACTORIAL8 * CLASSES_CP_16, |
| 90 | .transfind = transfinder_drudfin_noE_sym16, | 109 | .transform = transform_drudfin_noE_sym16, |
| 110 | .sd = &sd_eofbepos_16, | ||
| 91 | }; | 111 | }; |
| 92 | 112 | ||
| 93 | Coordinate | 113 | Coordinate |
| 94 | coord_nxopt31 = { | 114 | coord_nxopt31 = { |
| 95 | .index = index_nxopt31, | 115 | .index = index_nxopt31, |
| 96 | .cube = antindex_nxopt31, | 116 | .move = move_nxopt31, |
| 97 | .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, | 117 | .max = POW3TO7 * BINOM8ON4 * CLASSES_EOFBEPOS_16, |
| 98 | .transfind = transfinder_nxopt31, | 118 | .transform = transform_nxopt31, |
| 119 | .sd = &sd_eofbepos_16, | ||
| 99 | }; | 120 | }; |
| 100 | 121 | ||
| 101 | /* Functions *****************************************************************/ | 122 | /* Functions *****************************************************************/ |
| 102 | 123 | ||
| 103 | static Cube | ||
| 104 | antindex_cp_sym16(uint64_t ind) | ||
| 105 | { | ||
| 106 | return sd_cp_16.rep[ind]; | ||
| 107 | } | ||
| 108 | |||
| 109 | static Cube | ||
| 110 | antindex_eofbepos_sym16(uint64_t ind) | ||
| 111 | { | ||
| 112 | return sd_eofbepos_16.rep[ind]; | ||
| 113 | } | ||
| 114 | |||
| 115 | static Cube | ||
| 116 | antindex_drud_sym16(uint64_t ind) | ||
| 117 | { | ||
| 118 | Cube c; | ||
| 119 | |||
| 120 | c = antindex_eofbepos_sym16(ind/POW3TO7); | ||
| 121 | c.coud = ind % POW3TO7; | ||
| 122 | c.cofb = c.coud; | ||
| 123 | c.corl = c.coud; | ||
| 124 | |||
| 125 | return c; | ||
| 126 | } | ||
| 127 | |||
| 128 | static Cube | ||
| 129 | antindex_drudfin_noE_sym16(uint64_t ind) | ||
| 130 | { | ||
| 131 | Cube c1, c2; | ||
| 132 | |||
| 133 | c1 = coord_epud.cube(ind % FACTORIAL8); | ||
| 134 | c2 = antindex_cp_sym16(ind/FACTORIAL8); | ||
| 135 | c1.cp = c2.cp; | ||
| 136 | |||
| 137 | return c1; | ||
| 138 | } | ||
| 139 | |||
| 140 | static Cube | ||
| 141 | antindex_nxopt31(uint64_t ind) | ||
| 142 | { | ||
| 143 | Cube c; | ||
| 144 | |||
| 145 | c = antindex_eofbepos_sym16(ind/(BINOM8ON4*POW3TO7)); | ||
| 146 | c.cp = coord_cpud_separate.cube(ind % BINOM8ON4).cp; | ||
| 147 | c.coud = (ind / BINOM8ON4) % POW3TO7; | ||
| 148 | |||
| 149 | return c; | ||
| 150 | } | ||
| 151 | |||
| 152 | static uint64_t | 124 | static uint64_t |
| 153 | index_cp_sym16(Cube cube) | 125 | index_cp_sym16(Cube cube) |
| 154 | { | 126 | { |
| @@ -198,6 +170,116 @@ index_nxopt31(Cube cube) | |||
| 198 | return a * BINOM8ON4 + coord_cpud_separate.index((Cube){.cp = cp}); | 170 | return a * BINOM8ON4 + coord_cpud_separate.index((Cube){.cp = cp}); |
| 199 | } | 171 | } |
| 200 | 172 | ||
| 173 | static uint64_t | ||
| 174 | move_cp_sym16(Move m, uint64_t ind) | ||
| 175 | { | ||
| 176 | return move_cp_16[m][ind]; | ||
| 177 | } | ||
| 178 | |||
| 179 | static uint64_t | ||
| 180 | move_eofbepos_sym16(Move m, uint64_t ind) | ||
| 181 | { | ||
| 182 | return move_eofbepos_16[m][ind]; | ||
| 183 | } | ||
| 184 | |||
| 185 | static uint64_t | ||
| 186 | move_drud_sym16(Move m, uint64_t ind) | ||
| 187 | { | ||
| 188 | uint64_t coud, eofbepos; | ||
| 189 | Trans ttr; | ||
| 190 | |||
| 191 | eofbepos = move_eofbepos_16[m][ind / POW3TO7]; | ||
| 192 | ttr = ttrep_move_eofbepos_16[m][ind / POW3TO7]; | ||
| 193 | coud = coud_mtable[m][ind % POW3TO7]; | ||
| 194 | coud = co_ttable[ttr][coud]; /* Source is always coud */ | ||
| 195 | |||
| 196 | return eofbepos * POW3TO7 + coud; | ||
| 197 | } | ||
| 198 | |||
| 199 | static uint64_t | ||
| 200 | move_drudfin_noE_sym16(Move m, uint64_t ind) | ||
| 201 | { | ||
| 202 | uint64_t cp, epud; | ||
| 203 | Trans ttr; | ||
| 204 | |||
| 205 | cp = move_cp_16[m][ind / FACTORIAL8]; | ||
| 206 | ttr = ttrep_move_cp_16[m][ind / FACTORIAL8]; | ||
| 207 | epud = coord_epud.move(m, ind % FACTORIAL8); | ||
| 208 | epud = trans_epud[ttr][epud]; | ||
| 209 | |||
| 210 | return cp * FACTORIAL8 + epud; | ||
| 211 | } | ||
| 212 | |||
| 213 | static uint64_t | ||
| 214 | move_nxopt31(Move m, uint64_t ind) | ||
| 215 | { | ||
| 216 | uint64_t eofbepos, cpsep, coud; | ||
| 217 | Trans ttr; | ||
| 218 | |||
| 219 | eofbepos = ind / (POW3TO7 * BINOM8ON4); | ||
| 220 | coud = (ind / BINOM8ON4) % POW3TO7; | ||
| 221 | cpsep = ind % BINOM8ON4; | ||
| 222 | |||
| 223 | eofbepos = move_eofbepos_16[m][eofbepos]; | ||
| 224 | ttr = ttrep_move_eofbepos_16[m][eofbepos]; | ||
| 225 | coud = coud_mtable[m][coud]; | ||
| 226 | coud = co_ttable[ttr][coud]; /* Source is always coud */ | ||
| 227 | cpsep = coord_cpud_separate.move(m, cpsep); | ||
| 228 | cpsep = trans_cpud_separate[ttr][cpsep]; | ||
| 229 | |||
| 230 | return (eofbepos * POW3TO7 + coud) * BINOM8ON4 + cpsep; | ||
| 231 | } | ||
| 232 | |||
| 233 | static uint64_t | ||
| 234 | transform_cp(Trans t, uint64_t ind) | ||
| 235 | { | ||
| 236 | return cp_ttable[t][ind]; | ||
| 237 | } | ||
| 238 | |||
| 239 | static uint64_t | ||
| 240 | transform_eofbepos(Trans t, uint64_t ind) | ||
| 241 | { | ||
| 242 | return trans_eofbepos[t][ind]; | ||
| 243 | } | ||
| 244 | |||
| 245 | static uint64_t | ||
| 246 | transform_drud_sym16(Trans t, uint64_t ind) | ||
| 247 | { | ||
| 248 | uint64_t coud, eofbepos; | ||
| 249 | |||
| 250 | eofbepos = ind / POW3TO7; /* Assum trans fixes eofbepos */ | ||
| 251 | coud = co_ttable[t][ind % POW3TO7]; /* Source is always coud */ | ||
| 252 | |||
| 253 | return eofbepos * POW3TO7 + coud; | ||
| 254 | } | ||
| 255 | |||
| 256 | static uint64_t | ||
| 257 | transform_drudfin_noE_sym16(Trans t, uint64_t ind) | ||
| 258 | { | ||
| 259 | uint64_t cp, epud; | ||
| 260 | |||
| 261 | cp = ind / FACTORIAL8; /* Assume trans fixes eofbepos */ | ||
| 262 | epud = trans_epud[t][ind % FACTORIAL8]; | ||
| 263 | |||
| 264 | return cp * FACTORIAL8 + epud; | ||
| 265 | } | ||
| 266 | |||
| 267 | static uint64_t | ||
| 268 | transform_nxopt31(Trans t, uint64_t ind) | ||
| 269 | { | ||
| 270 | uint64_t eofbepos, cpsep, coud; | ||
| 271 | |||
| 272 | eofbepos = ind / (POW3TO7 * BINOM8ON4); | ||
| 273 | coud = (ind / BINOM8ON4) % POW3TO7; | ||
| 274 | cpsep = ind % BINOM8ON4; | ||
| 275 | |||
| 276 | coud = co_ttable[t][coud]; /* Source is always coud */ | ||
| 277 | cpsep = trans_cpud_separate[t][cpsep]; | ||
| 278 | |||
| 279 | return (eofbepos * POW3TO7 + coud) * BINOM8ON4 + cpsep; | ||
| 280 | } | ||
| 281 | |||
| 282 | /* | ||
| 201 | static int | 283 | static int |
| 202 | transfinder_drud_sym16(uint64_t ind, Trans *ret) | 284 | transfinder_drud_sym16(uint64_t ind, Trans *ret) |
| 203 | { | 285 | { |
| @@ -264,6 +346,8 @@ transfinder_nxopt31(uint64_t ind, Trans *ret) | |||
| 264 | return naux[trueind]; | 346 | return naux[trueind]; |
| 265 | } | 347 | } |
| 266 | 348 | ||
| 349 | */ | ||
| 350 | |||
| 267 | /* Other functions ***********************************************************/ | 351 | /* Other functions ***********************************************************/ |
| 268 | 352 | ||
| 269 | void | 353 | void |
| @@ -271,7 +355,7 @@ free_sd(SymData *sd) | |||
| 271 | { | 355 | { |
| 272 | if (sd->generated) { | 356 | if (sd->generated) { |
| 273 | free(sd->class); | 357 | free(sd->class); |
| 274 | free(sd->rep); | 358 | free(sd->unsym); |
| 275 | free(sd->transtorep); | 359 | free(sd->transtorep); |
| 276 | } | 360 | } |
| 277 | 361 | ||
| @@ -282,15 +366,16 @@ static void | |||
| 282 | gensym(SymData *sd) | 366 | gensym(SymData *sd) |
| 283 | { | 367 | { |
| 284 | uint64_t i, in, nreps = 0; | 368 | uint64_t i, in, nreps = 0; |
| 369 | Trans t; | ||
| 285 | int j; | 370 | int j; |
| 286 | Cube c, d; | ||
| 287 | 371 | ||
| 288 | if (sd->generated) | 372 | if (sd->generated) |
| 289 | return; | 373 | return; |
| 290 | 374 | ||
| 291 | sd->class = malloc(sd->coord->max * sizeof(uint64_t)); | 375 | sd->class = malloc(sd->coord->max * sizeof(uint64_t)); |
| 292 | sd->rep = malloc(sd->coord->max * sizeof(Cube)); | 376 | sd->unsym = malloc(sd->coord->max * sizeof(uint64_t)); |
| 293 | sd->transtorep = malloc(sd->coord->max * sizeof(Trans)); | 377 | sd->transtorep = malloc(sd->coord->max * sizeof(Trans)); |
| 378 | sd->selfsim = malloc(sd->coord->max * sizeof(uint64_t)); | ||
| 294 | 379 | ||
| 295 | if (read_symdata_file(sd)) { | 380 | if (read_symdata_file(sd)) { |
| 296 | sd->generated = true; | 381 | sd->generated = true; |
| @@ -304,16 +389,17 @@ gensym(SymData *sd) | |||
| 304 | 389 | ||
| 305 | for (i = 0; i < sd->coord->max; i++) { | 390 | for (i = 0; i < sd->coord->max; i++) { |
| 306 | if (sd->class[i] == sd->coord->max + 1) { | 391 | if (sd->class[i] == sd->coord->max + 1) { |
| 307 | c = sd->coord->cube(i); | 392 | sd->unsym[nreps] = i; |
| 308 | sd->rep[nreps] = c; | 393 | sd->selfsim[nreps] = 0; |
| 309 | for (j = 0; j < sd->ntrans; j++) { | 394 | for (j = 0; j < sd->ntrans; j++) { |
| 310 | d = apply_trans(sd->trans[j], c); | 395 | t = sd->trans[j]; |
| 311 | in = sd->coord->index(d); | 396 | in = sd->transform(t, i); |
| 312 | 397 | sd->class[in] = nreps; | |
| 313 | if (sd->class[in] == sd->coord->max + 1) { | 398 | if (in == i) { |
| 314 | sd->class[in] = nreps; | 399 | sd->selfsim[nreps] |= (1 << t); |
| 315 | sd->transtorep[in] = | 400 | sd->transtorep[in] = uf; |
| 316 | inverse_trans(sd->trans[j]); | 401 | } else { |
| 402 | sd->transtorep[in] = inverse_trans(t); | ||
| 317 | } | 403 | } |
| 318 | } | 404 | } |
| 319 | nreps++; | 405 | nreps++; |
| @@ -321,7 +407,8 @@ gensym(SymData *sd) | |||
| 321 | } | 407 | } |
| 322 | 408 | ||
| 323 | sd->sym_coord->max = nreps; | 409 | sd->sym_coord->max = nreps; |
| 324 | sd->rep = realloc(sd->rep, nreps * sizeof(Cube)); | 410 | sd->unsym = realloc(sd->unsym, nreps * sizeof(uint64_t)); |
| 411 | sd->selfsim = realloc(sd->selfsim, nreps * sizeof(uint64_t)); | ||
| 325 | sd->generated = true; | 412 | sd->generated = true; |
| 326 | 413 | ||
| 327 | fprintf(stderr, "Found %" PRIu64 " classes\n", nreps); | 414 | fprintf(stderr, "Found %" PRIu64 " classes\n", nreps); |
| @@ -350,7 +437,8 @@ read_symdata_file(SymData *sd) | |||
| 350 | return false; | 437 | return false; |
| 351 | 438 | ||
| 352 | r = r && fread(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; | 439 | r = r && fread(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; |
| 353 | r = r && fread(sd->rep, sizeof(Cube), *sn, f) == *sn; | 440 | r = r && fread(sd->unsym, sizeof(uint64_t), *sn, f) == *sn; |
| 441 | r = r && fread(sd->selfsim, sizeof(uint64_t), *sn, f) == *sn; | ||
| 354 | r = r && fread(sd->class, sizeof(uint64_t), n, f) == n; | 442 | r = r && fread(sd->class, sizeof(uint64_t), n, f) == n; |
| 355 | r = r && fread(sd->transtorep, sizeof(Trans), n, f) == n; | 443 | r = r && fread(sd->transtorep, sizeof(Trans), n, f) == n; |
| 356 | 444 | ||
| @@ -358,6 +446,7 @@ read_symdata_file(SymData *sd) | |||
| 358 | return r; | 446 | return r; |
| 359 | } | 447 | } |
| 360 | 448 | ||
| 449 | /* | ||
| 361 | static int | 450 | static int |
| 362 | selfsims(SymData *sd, uint64_t ind, Trans *ret) | 451 | selfsims(SymData *sd, uint64_t ind, Trans *ret) |
| 363 | { | 452 | { |
| @@ -376,6 +465,7 @@ selfsims(SymData *sd, uint64_t ind, Trans *ret) | |||
| 376 | 465 | ||
| 377 | return n; | 466 | return n; |
| 378 | } | 467 | } |
| 468 | */ | ||
| 379 | 469 | ||
| 380 | static bool | 470 | static bool |
| 381 | write_symdata_file(SymData *sd) | 471 | write_symdata_file(SymData *sd) |
| @@ -395,7 +485,8 @@ write_symdata_file(SymData *sd) | |||
| 395 | return false; | 485 | return false; |
| 396 | 486 | ||
| 397 | r = r && fwrite(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; | 487 | r = r && fwrite(&sd->sym_coord->max, sizeof(uint64_t), 1, f) == 1; |
| 398 | r = r && fwrite(sd->rep, sizeof(Cube), *sn, f) == *sn; | 488 | r = r && fwrite(sd->unsym, sizeof(uint64_t), *sn, f) == *sn; |
| 489 | r = r && fwrite(sd->selfsim, sizeof(uint64_t), *sn, f) == *sn; | ||
| 399 | r = r && fwrite(sd->class, sizeof(uint64_t), n, f) == n; | 490 | r = r && fwrite(sd->class, sizeof(uint64_t), n, f) == n; |
| 400 | r = r && fwrite(sd->transtorep, sizeof(Trans), n, f) == n; | 491 | r = r && fwrite(sd->transtorep, sizeof(Trans), n, f) == n; |
| 401 | 492 | ||
| @@ -403,6 +494,83 @@ write_symdata_file(SymData *sd) | |||
| 403 | return r; | 494 | return r; |
| 404 | } | 495 | } |
| 405 | 496 | ||
| 497 | static void | ||
| 498 | init_symc_moves() | ||
| 499 | { | ||
| 500 | uint64_t i, ii; | ||
| 501 | Move j; | ||
| 502 | |||
| 503 | for (i = 0; i < CLASSES_CP_16; i++) { | ||
| 504 | ii = sd_cp_16.unsym[i]; | ||
| 505 | for (j = 0; j < NMOVES; j++) { | ||
| 506 | move_cp_16[j][i] = sd_cp_16.coord->move(j, ii); | ||
| 507 | ttrep_move_cp_16[j][i] = sd_cp_16.transtorep[ii]; | ||
| 508 | } | ||
| 509 | } | ||
| 510 | |||
| 511 | for (i = 0; i < CLASSES_EOFBEPOS_16; i++) { | ||
| 512 | ii = sd_eofbepos_16.unsym[i]; | ||
| 513 | for (j = 0; j < NMOVES; j++) { | ||
| 514 | move_eofbepos_16[j][i] = | ||
| 515 | sd_eofbepos_16.coord->move(j, ii); | ||
| 516 | ttrep_move_eofbepos_16[j][i] = | ||
| 517 | sd_eofbepos_16.transtorep[ii]; | ||
| 518 | } | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | void | ||
| 523 | init_symc_trans() | ||
| 524 | { | ||
| 525 | uint64_t i; | ||
| 526 | int j, cp; | ||
| 527 | int epe[4] = {FR, FL, BL, BR}; | ||
| 528 | int a[12] = { [8] = 8, [9] = 9, [10] = 10, [11] = 11 }; | ||
| 529 | Cube c; | ||
| 530 | CubeArray *arr, *aux; | ||
| 531 | Trans t; | ||
| 532 | |||
| 533 | for (i = 0; i < POW2TO11*BINOM12ON4; i++) { | ||
| 534 | for (j = 0; j < 16; j++) { | ||
| 535 | t = trans_group_udfix[j]; | ||
| 536 | |||
| 537 | arr = new_cubearray((Cube){0}, pf_edges); | ||
| 538 | int_to_sum_zero_array(i/BINOM12ON4, 2, 12, arr->eofb); | ||
| 539 | epos_to_compatible_ep((i%BINOM12ON4)*24, arr->ep, epe); | ||
| 540 | fix_eorleoud(arr); | ||
| 541 | c = arrays_to_cube(arr, pf_edges); | ||
| 542 | free_cubearray(arr, pf_edges); | ||
| 543 | |||
| 544 | c = apply_trans(t, c); | ||
| 545 | trans_eofbepos[t][i] = | ||
| 546 | c.eofb * BINOM12ON4 + (c.epose / 24); | ||
| 547 | } | ||
| 548 | } | ||
| 549 | |||
| 550 | aux = malloc(sizeof(CubeArray)); | ||
| 551 | aux->ep = a; | ||
| 552 | for (i = 0; i < FACTORIAL8; i++) { | ||
| 553 | index_to_perm(i, 8, a); | ||
| 554 | c = arrays_to_cube(aux, pf_ep); | ||
| 555 | for (j = 0; j < 16; j++) { | ||
| 556 | t = trans_group_udfix[j]; | ||
| 557 | arr = new_cubearray(apply_trans(t, c), pf_ep); | ||
| 558 | trans_epud[t][i] = perm_to_index(arr->ep, 8); | ||
| 559 | free_cubearray(arr, pf_ep); | ||
| 560 | } | ||
| 561 | } | ||
| 562 | free(aux); | ||
| 563 | |||
| 564 | for (i = 0; i < BINOM8ON4; i++) { | ||
| 565 | cp = cpud_separate_ant[i]; | ||
| 566 | for (j = 0; j < 16; j++) { | ||
| 567 | t = trans_group_udfix[j]; | ||
| 568 | trans_cpud_separate[j][i] = | ||
| 569 | cpud_separate_ind[cp_ttable[t][cp]]; | ||
| 570 | } | ||
| 571 | } | ||
| 572 | } | ||
| 573 | |||
| 406 | void | 574 | void |
| 407 | init_symcoord() | 575 | init_symcoord() |
| 408 | { | 576 | { |
| @@ -415,7 +583,11 @@ init_symcoord() | |||
| 415 | 583 | ||
| 416 | init_coord(); | 584 | init_coord(); |
| 417 | 585 | ||
| 586 | init_symc_trans(); | ||
| 587 | |||
| 418 | for (i = 0; all_sd[i] != NULL; i++) | 588 | for (i = 0; all_sd[i] != NULL; i++) |
| 419 | gensym(all_sd[i]); | 589 | gensym(all_sd[i]); |
| 590 | |||
| 591 | init_symc_moves(); | ||
| 420 | } | 592 | } |
| 421 | 593 | ||
diff --git a/www/download/index.html b/www/download/index.html index 2618719..ff824f8 100644 --- a/www/download/index.html +++ b/www/download/index.html | |||
| @@ -98,7 +98,7 @@ followed by | |||
| 98 | </p> | 98 | </p> |
| 99 | <pre><code>make install</code></pre> | 99 | <pre><code>make install</code></pre> |
| 100 | <p> | 100 | <p> |
| 101 | Then ollow the instructions below to install the pruning tables. | 101 | Then follow the instructions below to install the pruning tables. |
| 102 | </p> | 102 | </p> |
| 103 | 103 | ||
| 104 | <h3>Tables</h3> | 104 | <h3>Tables</h3> |
| @@ -114,7 +114,7 @@ Then ollow the instructions below to install the pruning tables. | |||
| 114 | </table> | 114 | </table> |
| 115 | <p> | 115 | <p> |
| 116 | <strong>Note:</strong> the version 2.0 at the end of the file name is | 116 | <strong>Note:</strong> the version 2.0 at the end of the file name is |
| 117 | only indicative. Later versionw will use the same tables, unless | 117 | only indicative. Later versions will use the same tables, unless |
| 118 | otherwise specified. | 118 | otherwise specified. |
| 119 | </p> | 119 | </p> |
| 120 | 120 | ||
