diff options
| -rw-r--r-- | doc/solvers.md | 20 | ||||
| -rw-r--r-- | src/core/constants.h | 2 | ||||
| -rw-r--r-- | src/solvers/coord/coord.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/cornersx.h | 76 | ||||
| -rw-r--r-- | src/solvers/coord/list.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/types_macros.h | 2 | ||||
| -rw-r--r-- | src/solvers/dispatch.h | 1 | ||||
| -rw-r--r-- | tools/421_solvetest_cornersx/scrambles.h | 29 | ||||
| -rw-r--r-- | tools/421_solvetest_cornersx/solvetest.c | 9 |
9 files changed, 137 insertions, 4 deletions
diff --git a/doc/solvers.md b/doc/solvers.md index 12df168..b7fe613 100644 --- a/doc/solvers.md +++ b/doc/solvers.md | |||
| @@ -129,17 +129,31 @@ NISS will not be used. | |||
| 129 | * Moveset: {U, U', U2, D, D', D2, R2, L2, F2, B2}. | 129 | * Moveset: {U, U', U2, D, D', D2, R2, L2, F2, B2}. |
| 130 | * Data size: 54MB. | 130 | * Data size: 54MB. |
| 131 | 131 | ||
| 132 | ### Solve corners | 132 | ### Solve corners (fixed centers) |
| 133 | 133 | ||
| 134 | Solve the corners of the cube. Note: centers are considered fixed, | 134 | Solve the corners of the cube. The centers are considered fixed, |
| 135 | this is not the same as solving a 2x2x2 cube. | 135 | this is not the same as solving a 2x2x2 cube. |
| 136 | 136 | ||
| 137 | * Name: `coord_DRFIN_UF`. Other rotations in place of `UF` are allowed, | 137 | * Name: `coord_CORNERS_UF`. Other rotations in place of `UF` are allowed, |
| 138 | but they are irrelevant to the solver. Provided alias: `corners`. | 138 | but they are irrelevant to the solver. Provided alias: `corners`. |
| 139 | * Requisites: none. | 139 | * Requisites: none. |
| 140 | * Moveset: HTM (all 18 basic moves). | 140 | * Moveset: HTM (all 18 basic moves). |
| 141 | * Data size: 1.2MB. | 141 | * Data size: 1.2MB. |
| 142 | 142 | ||
| 143 | ### Solve corners (ignoring centers) | ||
| 144 | |||
| 145 | Solve the corners of the cube relative to each other, ignoring centers. | ||
| 146 | This is the same as solving a 2x2x2 cube. | ||
| 147 | |||
| 148 | * Name: `coord_CORNERSX_UF`. Other rotations in place of `UF` are allowed, | ||
| 149 | but they are irrelevant to the solver. Provided alias: `cornersx`. | ||
| 150 | * Requisites: none. | ||
| 151 | * Moveset: {U, U', U2, R, R', R2, F, F', F2}. Note: if the given cube | ||
| 152 | has an orientation different from the standard `UF` orientation, the | ||
| 153 | solution will use a different moves. The solution will always only use | ||
| 154 | at most 3 different types of moves (as in U, R, F). | ||
| 155 | * Data size: 1.2MB. | ||
| 156 | |||
| 143 | ### Undocumented coordinate solvers | 157 | ### Undocumented coordinate solvers |
| 144 | 158 | ||
| 145 | There are some coordinate solvers that have not been listed above. These | 159 | There are some coordinate solvers that have not been listed above. These |
diff --git a/src/core/constants.h b/src/core/constants.h index d8f2471..076a483 100644 --- a/src/core/constants.h +++ b/src/core/constants.h | |||
| @@ -366,6 +366,8 @@ | |||
| 366 | MM_SINGLE(MOVE_F2) | MM_SINGLE(MOVE_B2)) | 366 | MM_SINGLE(MOVE_F2) | MM_SINGLE(MOVE_B2)) |
| 367 | #define MM18_DR_NOD (MM18_DR & ~MM18_FACE(MOVE_D)) | 367 | #define MM18_DR_NOD (MM18_DR & ~MM18_FACE(MOVE_D)) |
| 368 | #define MM18_HTR (MM18_ALLMOVES & ~MM18_NOHALFTURNS) | 368 | #define MM18_HTR (MM18_ALLMOVES & ~MM18_NOHALFTURNS) |
| 369 | #define MM18_URF (\ | ||
| 370 | MM18_FACE(MOVE_U) | MM18_FACE(MOVE_R) | MM18_FACE(MOVE_F)) | ||
| 369 | 371 | ||
| 370 | #define TM_SINGLE(t) (UINT64_C(1) << (uint64_t)(t)) | 372 | #define TM_SINGLE(t) (UINT64_C(1) << (uint64_t)(t)) |
| 371 | #define TM_ALLTRANS UINT64_C(0xFFFFFFFFFFFF) | 373 | #define TM_ALLTRANS UINT64_C(0xFFFFFFFFFFFF) |
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index 2ef8482..98f4d05 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "drfin.h" | 9 | #include "drfin.h" |
| 10 | #include "htr.h" | 10 | #include "htr.h" |
| 11 | #include "corners.h" | 11 | #include "corners.h" |
| 12 | #include "cornersx.h" | ||
| 12 | #include "list.h" | 13 | #include "list.h" |
| 13 | #include "utils.h" | 14 | #include "utils.h" |
| 14 | #include "gendata.h" | 15 | #include "gendata.h" |
diff --git a/src/solvers/coord/cornersx.h b/src/solvers/coord/cornersx.h new file mode 100644 index 0000000..788db8d --- /dev/null +++ b/src/solvers/coord/cornersx.h | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | STATIC bool is_cornersx_solved(uint64_t, const unsigned char *); | ||
| 2 | |||
| 3 | STATIC coord_t coordinate_cornersx = { | ||
| 4 | .name = "CORNERSX", | ||
| 5 | .coord = &coordinate_corners_coord, | ||
| 6 | .cube = &coordinate_corners_cube, | ||
| 7 | .isnasty = &coordinate_corners_isnasty, | ||
| 8 | .gendata = coordinate_corners_gendata, | ||
| 9 | .max = CLASSES_CP_48 * POW_3_7, | ||
| 10 | .trans_mask = TM_ALLTRANS, | ||
| 11 | .moves_mask_gendata = MM18_ALLMOVES, | ||
| 12 | .moves_mask_solve = MM18_URF, | ||
| 13 | .is_admissible = &solution_always_valid, | ||
| 14 | .solution_prune = NULL, | ||
| 15 | .is_solvable = &cube_true, | ||
| 16 | .is_solved = &is_cornersx_solved, | ||
| 17 | .allow_niss = false, | ||
| 18 | .pruning_distribution = { | ||
| 19 | [0] = 5, | ||
| 20 | [1] = 11, | ||
| 21 | [2] = 42, | ||
| 22 | [3] = 240, | ||
| 23 | [4] = 1115, | ||
| 24 | [5] = 5848, | ||
| 25 | [6] = 29088, | ||
| 26 | [7] = 133410, | ||
| 27 | [8] = 508020, | ||
| 28 | [9] = 1100543, | ||
| 29 | [10] = 371364, | ||
| 30 | [11] = 2322, | ||
| 31 | }, | ||
| 32 | .pruning_max = 11, | ||
| 33 | .sym = { | ||
| 34 | .classes = CLASSES_CP_48, | ||
| 35 | .max = FACT_8, | ||
| 36 | .coord = &coord_cp, | ||
| 37 | .cube = &invcoord_cp, | ||
| 38 | .max2 = POW_3_7, | ||
| 39 | .coord2 = &coord_co, | ||
| 40 | .cube2 = &invcoord_co, | ||
| 41 | .merge = &coordinate_merge_cpco, | ||
| 42 | }, | ||
| 43 | }; | ||
| 44 | |||
| 45 | STATIC bool | ||
| 46 | is_cornersx_solved(uint64_t coord, const unsigned char *data) | ||
| 47 | { | ||
| 48 | /* | ||
| 49 | TODO we use a bit of an ugly trick to check all rotated versions of | ||
| 50 | the cube. We would like to apply rotations, but our oriented_cube_t | ||
| 51 | type does not allow to do this directly (we would just be changing | ||
| 52 | the orientation field, not the cube itself). So we apply slice moves | ||
| 53 | instead. We should make this less ugly. | ||
| 54 | */ | ||
| 55 | static uint8_t mt[] = { | ||
| 56 | [MOVE_x] = MOVE_M, [MOVE_x2] = MOVE_M2, [MOVE_x3] = MOVE_M3, | ||
| 57 | [MOVE_y] = MOVE_E, [MOVE_y2] = MOVE_E2, [MOVE_y3] = MOVE_E3, | ||
| 58 | [MOVE_z] = MOVE_S3, [MOVE_z2] = MOVE_S2, [MOVE_z3] = MOVE_S | ||
| 59 | }; | ||
| 60 | |||
| 61 | uint8_t i, j; | ||
| 62 | cube_t cube; | ||
| 63 | oriented_cube_t oc; | ||
| 64 | |||
| 65 | cube = coordinate_corners_cube(coord, data); | ||
| 66 | oc.orientation = ORIENTATION_UF; | ||
| 67 | for (i = ORIENTATION_UF; i <= ORIENTATION_BL; i++) { | ||
| 68 | oc.cube = cube; | ||
| 69 | for (j = 0; orientation_moves[i][j] != UINT8_MAX; j++) | ||
| 70 | oc = move_extended(oc, mt[orientation_moves[i][j]]); | ||
| 71 | if (coordinate_corners_coord(oc.cube, data) == 0) | ||
| 72 | return true; | ||
| 73 | } | ||
| 74 | |||
| 75 | return false; | ||
| 76 | } | ||
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index f2b7368..6856c13 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -7,6 +7,7 @@ coord_t *all_coordinates[] = { | |||
| 7 | &coordinate_cpepe, | 7 | &coordinate_cpepe, |
| 8 | &coordinate_htr, | 8 | &coordinate_htr, |
| 9 | &coordinate_corners, | 9 | &coordinate_corners, |
| 10 | &coordinate_cornersx, | ||
| 10 | NULL | 11 | NULL |
| 11 | }; | 12 | }; |
| 12 | 13 | ||
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index a9e604c..b75fab8 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -30,7 +30,7 @@ typedef struct { | |||
| 30 | bool (*is_admissible)(const solution_moves_t[static 1]); | 30 | bool (*is_admissible)(const solution_moves_t[static 1]); |
| 31 | bool (*solution_prune)(const solution_moves_t[static 1]); | 31 | bool (*solution_prune)(const solution_moves_t[static 1]); |
| 32 | bool (*is_solvable)(cube_t); | 32 | bool (*is_solvable)(cube_t); |
| 33 | /* if is_solved is nulle, coord == 0 is used */ | 33 | /* if is_solved is null, coord == 0 is used */ |
| 34 | bool (*is_solved)(uint64_t, const unsigned char *); | 34 | bool (*is_solved)(uint64_t, const unsigned char *); |
| 35 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; | 35 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; |
| 36 | uint8_t pruning_max; | 36 | uint8_t pruning_max; |
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h index 8147929..3184a28 100644 --- a/src/solvers/dispatch.h +++ b/src/solvers/dispatch.h | |||
| @@ -66,6 +66,7 @@ const char *solver_aliases[][2] = { | |||
| 66 | { "htr-drrl", "coord_HTR_LF" }, | 66 | { "htr-drrl", "coord_HTR_LF" }, |
| 67 | { "htr-drfb", "coord_HTR_BU" }, | 67 | { "htr-drfb", "coord_HTR_BU" }, |
| 68 | { "corners", "coord_CORNERS_UF" }, | 68 | { "corners", "coord_CORNERS_UF" }, |
| 69 | { "cornersx", "coord_CORNERSX_UF" }, | ||
| 69 | { NULL, NULL } | 70 | { NULL, NULL } |
| 70 | }; | 71 | }; |
| 71 | 72 | ||
diff --git a/tools/421_solvetest_cornersx/scrambles.h b/tools/421_solvetest_cornersx/scrambles.h new file mode 100644 index 0000000..0a3b75c --- /dev/null +++ b/tools/421_solvetest_cornersx/scrambles.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | struct { | ||
| 2 | char *scramble; | ||
| 3 | char *solutions; | ||
| 4 | } s[] = { | ||
| 5 | [0] = { | ||
| 6 | .scramble = "R2 D' F2 B D L2 U L U2 R' D' F2 B2 U F2 D F2 U' L2 D' F2", | ||
| 7 | .solutions = | ||
| 8 | "U R U2 F' U R2 U R F'\n" | ||
| 9 | "U R U' R F R2 F U' F2\n" | ||
| 10 | "U2 R' U F' U F' U R' U2\n" | ||
| 11 | "U R2 U2 F U R' U' F U' F2\n" | ||
| 12 | "U2 F R' F' R2 F' U' F2 U' R\n" | ||
| 13 | "U2 F2 R F' R' U' R U2 F R'\n" | ||
| 14 | "U2 F2 R' U R2 F R' F' U' R\n" | ||
| 15 | "U' F U2 R2 F2 U' F U F' R\n" | ||
| 16 | "U' F' U2 R2 U' R' U' F U' F2\n" | ||
| 17 | "U' F' U2 R2 F2 U F U F' R\n" | ||
| 18 | "R2 U F2 U' R U' F U' R' F2\n" | ||
| 19 | "F' U F2 U F U' F2 R F' U2\n" | ||
| 20 | "F' R' F R' F R' U' R' U' F2\n" | ||
| 21 | }, | ||
| 22 | /* | ||
| 23 | TODO: add more scrambles, use https://or18.github.io/RubiksSolverDemo/2x2x2 | ||
| 24 | to generate test cases. | ||
| 25 | */ | ||
| 26 | { | ||
| 27 | .scramble = "", /* End-of-list signal */ | ||
| 28 | } | ||
| 29 | }; | ||
diff --git a/tools/421_solvetest_cornersx/solvetest.c b/tools/421_solvetest_cornersx/solvetest.c new file mode 100644 index 0000000..6f67d74 --- /dev/null +++ b/tools/421_solvetest_cornersx/solvetest.c | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #define SOLVER "cornersx" | ||
| 2 | #define NISSFLAG NISSY_NISSFLAG_NORMAL | ||
| 3 | #define MINMOVES 0 | ||
| 4 | #define MAXMOVES 20 | ||
| 5 | #define MAXSOLUTIONS 500 | ||
| 6 | #define OPTIMAL 1 | ||
| 7 | |||
| 8 | #include "scrambles.h" | ||
| 9 | #include "../solvetest.h" | ||
