diff options
Diffstat (limited to '')
| -rw-r--r-- | doc/solvers.md | 11 | ||||
| -rw-r--r-- | src/arch/avx2.h | 12 | ||||
| -rw-r--r-- | src/arch/common.h | 1 | ||||
| -rw-r--r-- | src/arch/neon.h | 10 | ||||
| -rw-r--r-- | src/arch/portable.h | 13 | ||||
| -rw-r--r-- | src/core/cube.h | 9 | ||||
| -rw-r--r-- | src/solvers/coord/common.h | 12 | ||||
| -rw-r--r-- | src/solvers/coord/coord.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/corners.h | 72 | ||||
| -rw-r--r-- | src/solvers/coord/list.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/types_macros.h | 1 | ||||
| -rw-r--r-- | src/solvers/dispatch.h | 1 | ||||
| -rw-r--r-- | src/solvers/solvers.h | 2 |
13 files changed, 144 insertions, 2 deletions
diff --git a/doc/solvers.md b/doc/solvers.md index 837cec6..12df168 100644 --- a/doc/solvers.md +++ b/doc/solvers.md | |||
| @@ -129,6 +129,17 @@ 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 | ||
| 133 | |||
| 134 | Solve the corners of the cube. Note: centers are considered fixed, | ||
| 135 | this is not the same as solving a 2x2x2 cube. | ||
| 136 | |||
| 137 | * Name: `coord_DRFIN_UF`. Other rotations in place of `UF` are allowed, | ||
| 138 | but they are irrelevant to the solver. Provided alias: `corners`. | ||
| 139 | * Requisites: none. | ||
| 140 | * Moveset: HTM (all 18 basic moves). | ||
| 141 | * Data size: 1.2MB. | ||
| 142 | |||
| 132 | ### Undocumented coordinate solvers | 143 | ### Undocumented coordinate solvers |
| 133 | 144 | ||
| 134 | There are some coordinate solvers that have not been listed above. These | 145 | There are some coordinate solvers that have not been listed above. These |
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 5a62213..b80b0fb 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -160,6 +160,16 @@ coord_co(cube_t c) | |||
| 160 | return ret; | 160 | return ret; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | STATIC_INLINE void | ||
| 164 | copy_co(cube_t cube[static 1], cube_t co) | ||
| 165 | { | ||
| 166 | cube_t coclean; | ||
| 167 | |||
| 168 | coclean = _mm256_and_si256(co, CO2_AVX2); | ||
| 169 | *cube = _mm256_andnot_si256(CO2_AVX2, *cube); | ||
| 170 | *cube = _mm256_or_si256(*cube, coclean); | ||
| 171 | } | ||
| 172 | |||
| 163 | STATIC_INLINE cube_t | 173 | STATIC_INLINE cube_t |
| 164 | invcoord_co(uint64_t coord) | 174 | invcoord_co(uint64_t coord) |
| 165 | { | 175 | { |
| @@ -174,7 +184,7 @@ invcoord_co(uint64_t coord) | |||
| 174 | 184 | ||
| 175 | cc = _mm256_loadu_si256((__m256i *)mem); | 185 | cc = _mm256_loadu_si256((__m256i *)mem); |
| 176 | cube = SOLVED_CUBE; | 186 | cube = SOLVED_CUBE; |
| 177 | copy_corners(&cube, cc); | 187 | copy_co(&cube, cc); |
| 178 | 188 | ||
| 179 | return cube; | 189 | return cube; |
| 180 | } | 190 | } |
diff --git a/src/arch/common.h b/src/arch/common.h index f06f8d7..4412562 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -35,6 +35,7 @@ STATIC_INLINE cube_t invcoord_epudsep(uint64_t); | |||
| 35 | STATIC_INLINE bool is_eo_even(cube_t); | 35 | STATIC_INLINE bool is_eo_even(cube_t); |
| 36 | 36 | ||
| 37 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); | 37 | STATIC_INLINE void copy_corners(cube_t [static 1], cube_t); |
| 38 | STATIC_INLINE void copy_co(cube_t [static 1], cube_t); | ||
| 38 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); | 39 | STATIC_INLINE void copy_edges(cube_t [static 1], cube_t); |
| 39 | STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); | 40 | STATIC_INLINE void set_eo(cube_t [static 1], uint64_t); |
| 40 | 41 | ||
diff --git a/src/arch/neon.h b/src/arch/neon.h index 9871125..f997813 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -232,6 +232,16 @@ coord_co(cube_t c) | |||
| 232 | return ret; | 232 | return ret; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | STATIC_INLINE void | ||
| 236 | copy_co(cube_t cube[static 1], cube_t co) | ||
| 237 | { | ||
| 238 | uint8x8_t coclean; | ||
| 239 | |||
| 240 | coclean = vand_u8(co.corner, CO2_NEON); | ||
| 241 | cube->corner = vbic_u8(cube->corner, CO2_NEON); | ||
| 242 | cube->corner = vorr_u8(cube->corner, coclean); | ||
| 243 | } | ||
| 244 | |||
| 235 | STATIC_INLINE cube_t | 245 | STATIC_INLINE cube_t |
| 236 | invcoord_co(uint64_t coord) | 246 | invcoord_co(uint64_t coord) |
| 237 | { | 247 | { |
diff --git a/src/arch/portable.h b/src/arch/portable.h index c7f2de0..4b66fb6 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -154,6 +154,19 @@ inverse(cube_t cube) | |||
| 154 | return ret; | 154 | return ret; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | STATIC_INLINE void | ||
| 158 | copy_co(cube_t cube[static 1], cube_t co) | ||
| 159 | { | ||
| 160 | uint8_t c; | ||
| 161 | size_t i; | ||
| 162 | |||
| 163 | for (i = 0; i < 8; i++) { | ||
| 164 | c = cube->corner[i] & COBITS; | ||
| 165 | cube->corner[i] ^= c; | ||
| 166 | cube->corner[i] |= co.corner[i] & COBITS; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 157 | STATIC_INLINE uint64_t | 170 | STATIC_INLINE uint64_t |
| 158 | coord_co(cube_t c) | 171 | coord_co(cube_t c) |
| 159 | { | 172 | { |
diff --git a/src/core/cube.h b/src/core/cube.h index 3ba282e..9e79dda 100644 --- a/src/core/cube.h +++ b/src/core/cube.h | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | STATIC bool cube_true(cube_t); | ||
| 2 | |||
| 1 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 3 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); |
| 2 | STATIC bool isconsistent(oriented_cube_t); | 4 | STATIC bool isconsistent(oriented_cube_t); |
| 3 | STATIC bool issolvable(oriented_cube_t); | 5 | STATIC bool issolvable(oriented_cube_t); |
| @@ -19,6 +21,13 @@ STATIC uint8_t b32tocorner(char); | |||
| 19 | STATIC char edgetob32(uint8_t); | 21 | STATIC char edgetob32(uint8_t); |
| 20 | STATIC char cornertob32(uint8_t); | 22 | STATIC char cornertob32(uint8_t); |
| 21 | 23 | ||
| 24 | /* Used e.g. by the CORNERS coordinate, when a function pointer is needed */ | ||
| 25 | STATIC bool | ||
| 26 | cube_true(cube_t cube) | ||
| 27 | { | ||
| 28 | return true; | ||
| 29 | } | ||
| 30 | |||
| 22 | STATIC cube_t | 31 | STATIC cube_t |
| 23 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | 32 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) |
| 24 | { | 33 | { |
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index 5f2435d..d154636 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -14,6 +14,7 @@ STATIC bool coord_is_solved( | |||
| 14 | 14 | ||
| 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); | 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); |
| 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); | 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); |
| 17 | STATIC cube_t coordinate_merge_cpco(cube_t, cube_t); | ||
| 17 | 18 | ||
| 18 | STATIC uint64_t | 19 | STATIC uint64_t |
| 19 | coord_coord_generic( | 20 | coord_coord_generic( |
| @@ -215,3 +216,14 @@ coordinate_merge_ec(cube_t edges, cube_t corners) | |||
| 215 | { | 216 | { |
| 216 | return coordinate_merge_ce(corners, edges); | 217 | return coordinate_merge_ce(corners, edges); |
| 217 | } | 218 | } |
| 219 | |||
| 220 | STATIC cube_t | ||
| 221 | coordinate_merge_cpco(cube_t cp, cube_t co) | ||
| 222 | { | ||
| 223 | cube_t merged; | ||
| 224 | |||
| 225 | merged = cp; | ||
| 226 | copy_co(&merged, co); | ||
| 227 | |||
| 228 | return merged; | ||
| 229 | } | ||
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index db40239..2ef8482 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "cpepe.h" | 8 | #include "cpepe.h" |
| 9 | #include "drfin.h" | 9 | #include "drfin.h" |
| 10 | #include "htr.h" | 10 | #include "htr.h" |
| 11 | #include "corners.h" | ||
| 11 | #include "list.h" | 12 | #include "list.h" |
| 12 | #include "utils.h" | 13 | #include "utils.h" |
| 13 | #include "gendata.h" | 14 | #include "gendata.h" |
diff --git a/src/solvers/coord/corners.h b/src/solvers/coord/corners.h new file mode 100644 index 0000000..cc0d9a5 --- /dev/null +++ b/src/solvers/coord/corners.h | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | #define CLASSES_CP_48 984 | ||
| 2 | |||
| 3 | STATIC uint64_t coordinate_corners_coord(const cube_t, const unsigned char *); | ||
| 4 | STATIC cube_t coordinate_corners_cube(uint64_t, const unsigned char *); | ||
| 5 | STATIC bool coordinate_corners_isnasty(uint64_t, const unsigned char *); | ||
| 6 | STATIC size_t coordinate_corners_gendata(unsigned char *); | ||
| 7 | |||
| 8 | STATIC coord_t coordinate_corners = { | ||
| 9 | .name = "CORNERS", | ||
| 10 | .coord = &coordinate_corners_coord, | ||
| 11 | .cube = &coordinate_corners_cube, | ||
| 12 | .isnasty = &coordinate_corners_isnasty, | ||
| 13 | .gendata = coordinate_corners_gendata, | ||
| 14 | .max = CLASSES_CP_48 * POW_3_7, | ||
| 15 | .trans_mask = TM_ALLTRANS, | ||
| 16 | .moves_mask_gendata = MM18_ALLMOVES, | ||
| 17 | .moves_mask_solve = MM18_ALLMOVES, | ||
| 18 | .is_admissible = &solution_always_valid, | ||
| 19 | .solution_prune = NULL, | ||
| 20 | .is_solvable = &cube_true, | ||
| 21 | .is_solved = NULL, | ||
| 22 | .allow_niss = false, | ||
| 23 | .pruning_distribution = { | ||
| 24 | [0] = 1, | ||
| 25 | [1] = 2, | ||
| 26 | [2] = 9, | ||
| 27 | [3] = 76, | ||
| 28 | [4] = 708, | ||
| 29 | [5] = 5022, | ||
| 30 | [6] = 28248, | ||
| 31 | [7] = 132076, | ||
| 32 | [8] = 505705, | ||
| 33 | [9] = 1102421, | ||
| 34 | [10] = 375380, | ||
| 35 | [11] = 2360, | ||
| 36 | }, | ||
| 37 | .pruning_max = 11, | ||
| 38 | .sym = { | ||
| 39 | .classes = CLASSES_CP_48, | ||
| 40 | .max = FACT_8, | ||
| 41 | .coord = &coord_cp, | ||
| 42 | .cube = &invcoord_cp, | ||
| 43 | .max2 = POW_3_7, | ||
| 44 | .coord2 = &coord_co, | ||
| 45 | .cube2 = &invcoord_co, | ||
| 46 | .merge = &coordinate_merge_cpco, | ||
| 47 | }, | ||
| 48 | }; | ||
| 49 | |||
| 50 | STATIC uint64_t | ||
| 51 | coordinate_corners_coord(const cube_t cube, const unsigned char *data) | ||
| 52 | { | ||
| 53 | return coord_coord_generic(&coordinate_corners, cube, data); | ||
| 54 | } | ||
| 55 | |||
| 56 | STATIC cube_t | ||
| 57 | coordinate_corners_cube(uint64_t i, const unsigned char *data) | ||
| 58 | { | ||
| 59 | return coord_cube_generic(&coordinate_corners, i, data); | ||
| 60 | } | ||
| 61 | |||
| 62 | STATIC bool | ||
| 63 | coordinate_corners_isnasty(uint64_t i, const unsigned char *data) | ||
| 64 | { | ||
| 65 | return coord_isnasty_generic(&coordinate_corners, i, data); | ||
| 66 | } | ||
| 67 | |||
| 68 | STATIC size_t | ||
| 69 | coordinate_corners_gendata(unsigned char *data) | ||
| 70 | { | ||
| 71 | return coord_gendata_generic(&coordinate_corners, data); | ||
| 72 | } | ||
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index 9b59969..f2b7368 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -6,6 +6,7 @@ coord_t *all_coordinates[] = { | |||
| 6 | &coordinate_drslice, | 6 | &coordinate_drslice, |
| 7 | &coordinate_cpepe, | 7 | &coordinate_cpepe, |
| 8 | &coordinate_htr, | 8 | &coordinate_htr, |
| 9 | &coordinate_corners, | ||
| 9 | NULL | 10 | NULL |
| 10 | }; | 11 | }; |
| 11 | 12 | ||
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index 98f9822..a9e604c 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -30,6 +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 | bool (*is_solved)(uint64_t, const unsigned char *); | 34 | bool (*is_solved)(uint64_t, const unsigned char *); |
| 34 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; | 35 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; |
| 35 | uint8_t pruning_max; | 36 | uint8_t pruning_max; |
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h index 71b3947..8147929 100644 --- a/src/solvers/dispatch.h +++ b/src/solvers/dispatch.h | |||
| @@ -65,6 +65,7 @@ const char *solver_aliases[][2] = { | |||
| 65 | { "htr-drud", "coord_HTR_UF" }, | 65 | { "htr-drud", "coord_HTR_UF" }, |
| 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 | { NULL, NULL } | 69 | { NULL, NULL } |
| 69 | }; | 70 | }; |
| 70 | 71 | ||
diff --git a/src/solvers/solvers.h b/src/solvers/solvers.h index 27ae627..e19b08a 100644 --- a/src/solvers/solvers.h +++ b/src/solvers/solvers.h | |||
| @@ -3,6 +3,6 @@ | |||
| 3 | #include "tables_types_macros.h" | 3 | #include "tables_types_macros.h" |
| 4 | #include "tables.h" | 4 | #include "tables.h" |
| 5 | #include "distribution.h" | 5 | #include "distribution.h" |
| 6 | #include "h48/h48.h" | ||
| 7 | #include "coord/coord.h" | 6 | #include "coord/coord.h" |
| 7 | #include "h48/h48.h" | ||
| 8 | #include "dispatch.h" | 8 | #include "dispatch.h" |
