aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/constants.h2
-rw-r--r--src/solvers/coord/coord.h1
-rw-r--r--src/solvers/coord/cornersx.h76
-rw-r--r--src/solvers/coord/list.h1
-rw-r--r--src/solvers/coord/types_macros.h2
-rw-r--r--src/solvers/dispatch.h1
6 files changed, 82 insertions, 1 deletions
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 @@
1STATIC bool is_cornersx_solved(uint64_t, const unsigned char *);
2
3STATIC 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
45STATIC bool
46is_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

Generated with cgit - Back to sebastiano.tronto.net