diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-23 11:53:57 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-23 11:53:57 +0100 |
| commit | 83f6533c384a617181e818d1941b08e40aa40b7d (patch) | |
| tree | 336804f869326c560e04a775ce788d7e9f0de14a /src/solvers/coord | |
| parent | 3aba28a34f5fb94e2aff9c437d6b164e3dcc790e (diff) | |
| download | nissy-core-83f6533c384a617181e818d1941b08e40aa40b7d.tar.gz nissy-core-83f6533c384a617181e818d1941b08e40aa40b7d.zip | |
Added cornersx solver
Diffstat (limited to 'src/solvers/coord')
| -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 |
4 files changed, 79 insertions, 1 deletions
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; |
