From 83f6533c384a617181e818d1941b08e40aa40b7d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 23 Dec 2025 11:53:57 +0100 Subject: Added cornersx solver --- src/solvers/coord/coord.h | 1 + src/solvers/coord/cornersx.h | 76 ++++++++++++++++++++++++++++++++++++++++ src/solvers/coord/list.h | 1 + src/solvers/coord/types_macros.h | 2 +- 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/solvers/coord/cornersx.h (limited to 'src/solvers/coord') 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 @@ #include "drfin.h" #include "htr.h" #include "corners.h" +#include "cornersx.h" #include "list.h" #include "utils.h" #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 @@ +STATIC bool is_cornersx_solved(uint64_t, const unsigned char *); + +STATIC coord_t coordinate_cornersx = { + .name = "CORNERSX", + .coord = &coordinate_corners_coord, + .cube = &coordinate_corners_cube, + .isnasty = &coordinate_corners_isnasty, + .gendata = coordinate_corners_gendata, + .max = CLASSES_CP_48 * POW_3_7, + .trans_mask = TM_ALLTRANS, + .moves_mask_gendata = MM18_ALLMOVES, + .moves_mask_solve = MM18_URF, + .is_admissible = &solution_always_valid, + .solution_prune = NULL, + .is_solvable = &cube_true, + .is_solved = &is_cornersx_solved, + .allow_niss = false, + .pruning_distribution = { + [0] = 5, + [1] = 11, + [2] = 42, + [3] = 240, + [4] = 1115, + [5] = 5848, + [6] = 29088, + [7] = 133410, + [8] = 508020, + [9] = 1100543, + [10] = 371364, + [11] = 2322, + }, + .pruning_max = 11, + .sym = { + .classes = CLASSES_CP_48, + .max = FACT_8, + .coord = &coord_cp, + .cube = &invcoord_cp, + .max2 = POW_3_7, + .coord2 = &coord_co, + .cube2 = &invcoord_co, + .merge = &coordinate_merge_cpco, + }, +}; + +STATIC bool +is_cornersx_solved(uint64_t coord, const unsigned char *data) +{ + /* + TODO we use a bit of an ugly trick to check all rotated versions of + the cube. We would like to apply rotations, but our oriented_cube_t + type does not allow to do this directly (we would just be changing + the orientation field, not the cube itself). So we apply slice moves + instead. We should make this less ugly. + */ + static uint8_t mt[] = { + [MOVE_x] = MOVE_M, [MOVE_x2] = MOVE_M2, [MOVE_x3] = MOVE_M3, + [MOVE_y] = MOVE_E, [MOVE_y2] = MOVE_E2, [MOVE_y3] = MOVE_E3, + [MOVE_z] = MOVE_S3, [MOVE_z2] = MOVE_S2, [MOVE_z3] = MOVE_S + }; + + uint8_t i, j; + cube_t cube; + oriented_cube_t oc; + + cube = coordinate_corners_cube(coord, data); + oc.orientation = ORIENTATION_UF; + for (i = ORIENTATION_UF; i <= ORIENTATION_BL; i++) { + oc.cube = cube; + for (j = 0; orientation_moves[i][j] != UINT8_MAX; j++) + oc = move_extended(oc, mt[orientation_moves[i][j]]); + if (coordinate_corners_coord(oc.cube, data) == 0) + return true; + } + + return false; +} 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[] = { &coordinate_cpepe, &coordinate_htr, &coordinate_corners, + &coordinate_cornersx, NULL }; 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 { bool (*is_admissible)(const solution_moves_t[static 1]); bool (*solution_prune)(const solution_moves_t[static 1]); bool (*is_solvable)(cube_t); - /* if is_solved is nulle, coord == 0 is used */ + /* if is_solved is null, coord == 0 is used */ bool (*is_solved)(uint64_t, const unsigned char *); uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; uint8_t pruning_max; -- cgit v1.3