aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 16:57:21 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-30 16:10:29 +0200
commit6cf7cd87a90a1314332aace1d25b9c0f230dc227 (patch)
treec246fbd0d400b34e6461e88a1bb50b4812eae8e5 /src/solvers/coord
parentea0387796a349c91032fbcb10f50c6ad8607b0f6 (diff)
downloadnissy-core-6cf7cd87a90a1314332aace1d25b9c0f230dc227.tar.gz
nissy-core-6cf7cd87a90a1314332aace1d25b9c0f230dc227.zip
added drslice coordinate
Diffstat (limited to 'src/solvers/coord')
-rw-r--r--src/solvers/coord/common.h19
-rw-r--r--src/solvers/coord/coord.h1
-rw-r--r--src/solvers/coord/dr.h5
-rw-r--r--src/solvers/coord/dreo.h5
-rw-r--r--src/solvers/coord/drfinnoe.h42
-rw-r--r--src/solvers/coord/drslice.h113
-rw-r--r--src/solvers/coord/eo.h7
-rw-r--r--src/solvers/coord/gendata.h38
-rw-r--r--src/solvers/coord/list.h1
-rw-r--r--src/solvers/coord/solve.h12
-rw-r--r--src/solvers/coord/types_macros.h6
11 files changed, 197 insertions, 52 deletions
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h
index d38b7d3..901b8bd 100644
--- a/src/solvers/coord/common.h
+++ b/src/solvers/coord/common.h
@@ -10,6 +10,8 @@ STATIC void append_coord_name(const coord_t [static 1], char *);
10STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); 10STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]);
11STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, 11STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *,
12 size_t, const uint8_t *); 12 size_t, const uint8_t *);
13STATIC bool coord_is_solved(
14 const coord_t [static 1], uint64_t, const unsigned char *);
13 15
14STATIC uint64_t 16STATIC uint64_t
15coord_coord_generic( 17coord_coord_generic(
@@ -182,8 +184,11 @@ coord_can_switch(
182 184
183 uint64_t i; 185 uint64_t i;
184 186
185 if (n == 0) 187 DBG_ASSERT(n > 0, "Error: cannot check if coordinate solver "
186 return true; 188 "can use NISS after 0 moves");
189
190 if (!coord->allow_niss)
191 return false;
187 192
188 i = coord->coord(move(SOLVED_CUBE, moves[n-1]), data); 193 i = coord->coord(move(SOLVED_CUBE, moves[n-1]), data);
189 if (i == 0) 194 if (i == 0)
@@ -195,3 +200,13 @@ coord_can_switch(
195 i = coord->coord(move(SOLVED_CUBE, moves[n-1]), data); 200 i = coord->coord(move(SOLVED_CUBE, moves[n-1]), data);
196 return i != 0; 201 return i != 0;
197} 202}
203
204STATIC bool
205coord_is_solved(
206 const coord_t coord[static 1],
207 uint64_t i,
208 const unsigned char *data
209)
210{
211 return coord->is_solved == NULL ? i == 0 : coord->is_solved(i, data);
212}
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h
index e487964..3b42e31 100644
--- a/src/solvers/coord/coord.h
+++ b/src/solvers/coord/coord.h
@@ -4,6 +4,7 @@
4#include "dr.h" 4#include "dr.h"
5#include "dreo.h" 5#include "dreo.h"
6#include "drfinnoe.h" 6#include "drfinnoe.h"
7#include "drslice.h"
7#include "list.h" 8#include "list.h"
8#include "utils.h" 9#include "utils.h"
9#include "gendata.h" 10#include "gendata.h"
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h
index 7f7af4f..487e79c 100644
--- a/src/solvers/coord/dr.h
+++ b/src/solvers/coord/dr.h
@@ -20,7 +20,8 @@ STATIC coord_t coordinate_dr = {
20 .gendata = coordinate_dr_gendata, 20 .gendata = coordinate_dr_gendata,
21 .max = DREOESEP_CLASSES * POW_3_7, 21 .max = DREOESEP_CLASSES * POW_3_7,
22 .trans_mask = TM_UDFIX, 22 .trans_mask = TM_UDFIX,
23 .moves_mask = MM18_ALLMOVES, 23 .moves_mask_gendata = MM18_ALLMOVES,
24 .moves_mask_solve = MM18_ALLMOVES,
24 .axistrans = { 25 .axistrans = {
25 [AXIS_UD] = TRANS_UFr, 26 [AXIS_UD] = TRANS_UFr,
26 [AXIS_RL] = TRANS_RFr, 27 [AXIS_RL] = TRANS_RFr,
@@ -28,6 +29,8 @@ STATIC coord_t coordinate_dr = {
28 }, 29 },
29 .is_admissible = &solution_lastqt_cw, 30 .is_admissible = &solution_lastqt_cw,
30 .is_solvable = &is_eoco_solvable, 31 .is_solvable = &is_eoco_solvable,
32 .is_solved = NULL,
33 .allow_niss = true,
31 .pruning_distribution = { 34 .pruning_distribution = {
32 [0] = 1, 35 [0] = 1,
33 [1] = 1, 36 [1] = 1,
diff --git a/src/solvers/coord/dreo.h b/src/solvers/coord/dreo.h
index 31f7008..8780807 100644
--- a/src/solvers/coord/dreo.h
+++ b/src/solvers/coord/dreo.h
@@ -19,7 +19,8 @@ STATIC coord_t coordinate_dreo = {
19 .gendata = coordinate_dreo_gendata, 19 .gendata = coordinate_dreo_gendata,
20 .max = DRESEP_CLASSES * POW_3_7, 20 .max = DRESEP_CLASSES * POW_3_7,
21 .trans_mask = TM_UDRLFIX, 21 .trans_mask = TM_UDRLFIX,
22 .moves_mask = MM18_EO, 22 .moves_mask_gendata = MM18_EO,
23 .moves_mask_solve = MM18_EO,
23 .axistrans = { 24 .axistrans = {
24 [AXIS_UD] = TRANS_UFr, 25 [AXIS_UD] = TRANS_UFr,
25 [AXIS_RL] = TRANS_RFr, 26 [AXIS_RL] = TRANS_RFr,
@@ -27,6 +28,8 @@ STATIC coord_t coordinate_dreo = {
27 }, 28 },
28 .is_admissible = &solution_lastqt_cw, 29 .is_admissible = &solution_lastqt_cw,
29 .is_solvable = &is_dreo_solvable, 30 .is_solvable = &is_dreo_solvable,
31 .is_solved = NULL,
32 .allow_niss = true,
30 .pruning_distribution = { 33 .pruning_distribution = {
31 [0] = 1, 34 [0] = 1,
32 [1] = 1, 35 [1] = 1,
diff --git a/src/solvers/coord/drfinnoe.h b/src/solvers/coord/drfinnoe.h
index 984b10a..c088ac4 100644
--- a/src/solvers/coord/drfinnoe.h
+++ b/src/solvers/coord/drfinnoe.h
@@ -13,12 +13,7 @@ In the worst case, it is a bug to be fixed, but I find it unlikely.
13 13
14#define CLASSES_CP_16 2768 14#define CLASSES_CP_16 2768
15 15
16STATIC uint64_t coordinate_cp_coord(cube_t);
17STATIC cube_t coordinate_cp_cube(uint64_t);
18STATIC uint64_t coordinate_epud_coord(cube_t);
19STATIC cube_t coordinate_epud_cube(uint64_t);
20STATIC cube_t coordinate_drfinnoe_merge(cube_t, cube_t); 16STATIC cube_t coordinate_drfinnoe_merge(cube_t, cube_t);
21
22STATIC uint64_t coordinate_drfinnoe_coord(cube_t, const unsigned char *); 17STATIC uint64_t coordinate_drfinnoe_coord(cube_t, const unsigned char *);
23STATIC cube_t coordinate_drfinnoe_cube(uint64_t, const unsigned char *); 18STATIC cube_t coordinate_drfinnoe_cube(uint64_t, const unsigned char *);
24STATIC bool coordinate_drfinnoe_isnasty(uint64_t, const unsigned char *); 19STATIC bool coordinate_drfinnoe_isnasty(uint64_t, const unsigned char *);
@@ -34,7 +29,8 @@ STATIC coord_t coordinate_drfinnoe = {
34 .gendata = coordinate_drfinnoe_gendata, 29 .gendata = coordinate_drfinnoe_gendata,
35 .max = CLASSES_CP_16 * FACT_8, 30 .max = CLASSES_CP_16 * FACT_8,
36 .trans_mask = TM_UDFIX, 31 .trans_mask = TM_UDFIX,
37 .moves_mask = MM18_DR, 32 .moves_mask_gendata = MM18_DR,
33 .moves_mask_solve = MM18_DR,
38 .axistrans = { 34 .axistrans = {
39 [AXIS_UD] = TRANS_UFr, 35 [AXIS_UD] = TRANS_UFr,
40 [AXIS_RL] = TRANS_RFr, 36 [AXIS_RL] = TRANS_RFr,
@@ -42,6 +38,8 @@ STATIC coord_t coordinate_drfinnoe = {
42 }, 38 },
43 .is_admissible = &solution_always_valid, 39 .is_admissible = &solution_always_valid,
44 .is_solvable = &is_drfinnoe_solvable, 40 .is_solvable = &is_drfinnoe_solvable,
41 .is_solved = NULL,
42 .allow_niss = false,
45 .pruning_distribution = { 43 .pruning_distribution = {
46 [0] = 1, 44 [0] = 1,
47 [1] = 3, 45 [1] = 3,
@@ -64,39 +62,15 @@ STATIC coord_t coordinate_drfinnoe = {
64 .sym = { 62 .sym = {
65 .classes = CLASSES_CP_16, 63 .classes = CLASSES_CP_16,
66 .max = FACT_8, 64 .max = FACT_8,
67 .coord = &coordinate_cp_coord, 65 .coord = &coord_cp,
68 .cube = &coordinate_cp_cube, 66 .cube = &invcoord_cp,
69 .max2 = FACT_8, 67 .max2 = FACT_8,
70 .coord2 = &coordinate_epud_coord, 68 .coord2 = &coord_epud,
71 .cube2 = &coordinate_epud_cube, 69 .cube2 = &invcoord_epud,
72 .merge = &coordinate_drfinnoe_merge, 70 .merge = &coordinate_drfinnoe_merge,
73 }, 71 },
74}; 72};
75 73
76STATIC uint64_t
77coordinate_cp_coord(cube_t c)
78{
79 return coord_cp(c);
80}
81
82STATIC cube_t
83coordinate_cp_cube(uint64_t i)
84{
85 return invcoord_cp(i);
86}
87
88STATIC uint64_t
89coordinate_epud_coord(cube_t c)
90{
91 return coord_epud(c);
92}
93
94STATIC cube_t
95coordinate_epud_cube(uint64_t i)
96{
97 return invcoord_epud(i);
98}
99
100STATIC cube_t 74STATIC cube_t
101coordinate_drfinnoe_merge(cube_t c1, cube_t c2) 75coordinate_drfinnoe_merge(cube_t c1, cube_t c2)
102{ 76{
diff --git a/src/solvers/coord/drslice.h b/src/solvers/coord/drslice.h
new file mode 100644
index 0000000..4299b30
--- /dev/null
+++ b/src/solvers/coord/drslice.h
@@ -0,0 +1,113 @@
1/*
2The DRSLICE coordinate is almost identical to DRFINNOE, but it allows for
3the centers of the E layer to be off by a rotation. For this reason we reuse
4much of the code of DRFINNOE. We could make the pruning table 4x smaller
5if we reduced the coordinate by rotations. TODO.
6*/
7
8STATIC cube_t coordinate_drslice_merge(cube_t, cube_t);
9STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *);
10STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *);
11STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *);
12STATIC size_t coordinate_drslice_gendata(unsigned char *);
13STATIC bool is_drslice_solvable(cube_t);
14STATIC bool is_drslice_solved(uint64_t, const unsigned char *);
15
16STATIC coord_t coordinate_drslice = {
17 .name = "DRSLICE",
18 .coord = &coordinate_drslice_coord,
19 .cube = &coordinate_drslice_cube,
20 .isnasty = &coordinate_drslice_isnasty,
21 .gendata = coordinate_drslice_gendata,
22 .max = CLASSES_CP_16 * FACT_8,
23 .trans_mask = TM_UDFIX,
24 .moves_mask_gendata = MM18_DR,
25 .moves_mask_solve = MM18_DR_NOD,
26 .axistrans = {
27 [AXIS_UD] = TRANS_UFr,
28 [AXIS_RL] = TRANS_RFr,
29 [AXIS_FB] = TRANS_FDr,
30 },
31 .is_admissible = &solution_always_valid,
32 .is_solvable = &is_drslice_solvable,
33 .is_solved = &is_drslice_solved,
34 .allow_niss = false,
35 .pruning_distribution = {
36 [0] = 3,
37 [1] = 7,
38 [2] = 18,
39 [3] = 111,
40 [4] = 433,
41 [5] = 1618,
42 [6] = 6718,
43 [7] = 29182,
44 [8] = 119873,
45 [9] = 476999,
46 [10] = 1858350,
47 [11] = 6531166,
48 [12] = 18338522,
49 [13] = 32839235,
50 [14] = 34118824,
51 [15] = 17284701
52 },
53 .pruning_max = 15,
54 .sym = {
55 .classes = CLASSES_CP_16,
56 .max = FACT_8,
57 .coord = &coord_cp,
58 .cube = &invcoord_cp,
59 .max2 = FACT_8,
60 .coord2 = &coord_epud,
61 .cube2 = &invcoord_epud,
62 .merge = &coordinate_drslice_merge,
63 },
64};
65
66STATIC cube_t
67coordinate_drslice_merge(cube_t c1, cube_t c2)
68{
69 cube_t merged;
70
71 merged = c1;
72 copy_edges(&merged, c2);
73
74 return merged;
75}
76
77STATIC uint64_t
78coordinate_drslice_coord(cube_t cube, const unsigned char *data)
79{
80 return coord_coord_generic(&coordinate_drslice, cube, data);
81}
82
83STATIC cube_t
84coordinate_drslice_cube(uint64_t i, const unsigned char *data)
85{
86 return coord_cube_generic(&coordinate_drslice, i, data);
87}
88
89STATIC size_t
90coordinate_drslice_gendata(unsigned char *data)
91{
92 return coord_gendata_generic(&coordinate_drslice, data);
93}
94
95STATIC bool
96coordinate_drslice_isnasty(uint64_t i, const unsigned char *data)
97{
98 return coord_isnasty_generic(&coordinate_drslice, i, data);
99}
100
101STATIC bool
102is_drslice_solvable(cube_t cube) {
103 return coord_eo(cube) == 0 &&
104 coord_eo(transform_edges(cube, TRANS_URr)) == 0 &&
105 coord_co(cube) == 0;
106}
107
108STATIC bool
109is_drslice_solved(uint64_t i, const unsigned char *data)
110{
111 /* Pre-computed coordinates of U D' (= U' D up to trans) and U2 D2 */
112 return i == 0 || i == 109779816 || i == 68468527;
113}
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h
index b963832..86e09e9 100644
--- a/src/solvers/coord/eo.h
+++ b/src/solvers/coord/eo.h
@@ -12,7 +12,8 @@ STATIC coord_t coordinate_eo = {
12 .gendata = coordinate_eo_gendata, 12 .gendata = coordinate_eo_gendata,
13 .max = POW_2_11, 13 .max = POW_2_11,
14 .trans_mask = TM_SINGLE(TRANS_UFr), 14 .trans_mask = TM_SINGLE(TRANS_UFr),
15 .moves_mask = MM18_ALLMOVES, 15 .moves_mask_gendata = MM18_ALLMOVES,
16 .moves_mask_solve = MM18_ALLMOVES,
16 .axistrans = { 17 .axistrans = {
17 [AXIS_UD] = TRANS_FDr, 18 [AXIS_UD] = TRANS_FDr,
18 [AXIS_RL] = TRANS_URr, 19 [AXIS_RL] = TRANS_URr,
@@ -20,6 +21,8 @@ STATIC coord_t coordinate_eo = {
20 }, 21 },
21 .is_admissible = &solution_lastqt_cw, 22 .is_admissible = &solution_lastqt_cw,
22 .is_solvable = &is_eo_even, 23 .is_solvable = &is_eo_even,
24 .is_solved = NULL,
25 .allow_niss = true,
23 .pruning_distribution = { 26 .pruning_distribution = {
24 [0] = 1, 27 [0] = 1,
25 [1] = 2, 28 [1] = 2,
@@ -37,7 +40,7 @@ STATIC coord_t coordinate_eo = {
37STATIC uint64_t 40STATIC uint64_t
38coordinate_eo_coord(cube_t c, const unsigned char *data) 41coordinate_eo_coord(cube_t c, const unsigned char *data)
39{ 42{
40 return (uint64_t)coord_eo(c); 43 return coord_eo(c);
41} 44}
42 45
43STATIC cube_t 46STATIC cube_t
diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h
index 678bfd7..75c57e4 100644
--- a/src/solvers/coord/gendata.h
+++ b/src/solvers/coord/gendata.h
@@ -3,6 +3,8 @@ STATIC long long gendata_coord_dispatch(const char *, unsigned long long,
3 unsigned char *); 3 unsigned char *);
4STATIC tableinfo_t genptable_coord( 4STATIC tableinfo_t genptable_coord(
5 const coord_t [static 1], const unsigned char *, unsigned char *); 5 const coord_t [static 1], const unsigned char *, unsigned char *);
6STATIC uint64_t genptable_coord_init_solved(
7 const coord_t [static 1], const unsigned char *, unsigned char *);
6STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t); 8STATIC bool switch_to_fromnew(uint64_t, uint64_t, uint64_t);
7STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1], 9STATIC uint64_t genptable_coord_fillneighbors(const coord_t [static 1],
8 const unsigned char *, uint64_t, uint8_t, unsigned char *); 10 const unsigned char *, uint64_t, uint8_t, unsigned char *);
@@ -118,11 +120,10 @@ genptable_coord(
118 memset(info.distribution, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t)); 120 memset(info.distribution, 0, INFO_DISTRIBUTION_LEN * sizeof(uint64_t));
119 append_coord_name(coord, info.solver); 121 append_coord_name(coord, info.solver);
120 122
121 nm = popcount_u32(coord->moves_mask); 123 tot = info.distribution[0] =
122 i = coord->coord(SOLVED_CUBE, data); 124 genptable_coord_init_solved(coord, data, table);
123 set_coord_pval(coord, table, i, 0); 125 nm = popcount_u32(coord->moves_mask_gendata);
124 info.distribution[0] = 1; 126 for (d = 1; tot < coord->max && d < 15; d++) {
125 for (d = 1, tot = 1; tot < coord->max && d < 15; d++) {
126 t = 0; 127 t = 0;
127 if (switch_to_fromnew(tot, coord->max, nm)) { 128 if (switch_to_fromnew(tot, coord->max, nm)) {
128 for (i = 0; i < coord->max; i++) 129 for (i = 0; i < coord->max; i++)
@@ -153,6 +154,27 @@ genptable_coord(
153 return info; 154 return info;
154} 155}
155 156
157STATIC uint64_t
158genptable_coord_init_solved(
159 const coord_t coord[static 1],
160 const unsigned char *coord_data,
161 unsigned char *table
162)
163{
164 uint64_t i, max_solved, ret;
165
166 max_solved = coord->is_solved == NULL ? 1 : coord->max;
167
168 for (i = 0, ret = 0; i < max_solved; i++) {
169 if (coord_is_solved(coord, i, coord_data)) {
170 set_coord_pval(coord, table, i, 0);
171 ret++;
172 }
173 }
174
175 return ret;
176}
177
156STATIC bool 178STATIC bool
157switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm) 179switch_to_fromnew(uint64_t done, uint64_t max, uint64_t nm)
158{ 180{
@@ -183,7 +205,8 @@ genptable_coord_fillneighbors(
183 c = coord->cube(i, data); 205 c = coord->cube(i, data);
184 tot = 0; 206 tot = 0;
185 for (m = 0; m < NMOVES; m++) { 207 for (m = 0; m < NMOVES; m++) {
186 if (!((UINT32_C(1) << (uint32_t)m) & coord->moves_mask)) 208 if (!((UINT32_C(1) << (uint32_t)m) &
209 coord->moves_mask_gendata))
187 continue; 210 continue;
188 moved = move(c, m); 211 moved = move(c, m);
189 ii = coord->coord(moved, data); 212 ii = coord->coord(moved, data);
@@ -234,7 +257,8 @@ genptable_coord_fillfromnew(
234 for (j = 0, found = false; j < nsim && !found; j++) { 257 for (j = 0, found = false; j < nsim && !found; j++) {
235 c = coord->cube(sim[j], data); 258 c = coord->cube(sim[j], data);
236 for (m = 0; m < NMOVES; m++) { 259 for (m = 0; m < NMOVES; m++) {
237 if (!((UINT32_C(1) << (uint32_t)m) & coord->moves_mask)) 260 if (!((UINT32_C(1) << (uint32_t)m) &
261 coord->moves_mask_gendata))
238 continue; 262 continue;
239 ii = coord->coord(move(c, m), data); 263 ii = coord->coord(move(c, m), data);
240 if (get_coord_pval(coord, table, ii) < d) { 264 if (get_coord_pval(coord, table, ii) < d) {
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h
index a3d3206..929e0fd 100644
--- a/src/solvers/coord/list.h
+++ b/src/solvers/coord/list.h
@@ -3,5 +3,6 @@ coord_t *all_coordinates[] = {
3 &coordinate_dr, 3 &coordinate_dr,
4 &coordinate_dreo, 4 &coordinate_dreo,
5 &coordinate_drfinnoe, 5 &coordinate_drfinnoe,
6 &coordinate_drslice,
6 NULL 7 NULL
7}; 8};
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h
index 75ec200..280ca36 100644
--- a/src/solvers/coord/solve.h
+++ b/src/solvers/coord/solve.h
@@ -76,6 +76,7 @@ coord_continue_onnormal(const dfsarg_solve_coord_t arg[static 1])
76 if (nn + ni == 0) 76 if (nn + ni == 0)
77 return f & (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_MIXED); 77 return f & (NISSY_NISSFLAG_NORMAL | NISSY_NISSFLAG_MIXED);
78 78
79 /* TODO logic here can probably be simplified */
79 if (arg->lastisnormal) 80 if (arg->lastisnormal)
80 return (f & NISSY_NISSFLAG_NORMAL) || 81 return (f & NISSY_NISSFLAG_NORMAL) ||
81 ((f & NISSY_NISSFLAG_MIXED) && (ni > 0 || nn <= th)); 82 ((f & NISSY_NISSFLAG_MIXED) && (ni > 0 || nn <= th));
@@ -98,6 +99,7 @@ coord_continue_oninverse(const dfsarg_solve_coord_t arg[static 1])
98 if (nn + ni == 0) 99 if (nn + ni == 0)
99 return f & (NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED); 100 return f & (NISSY_NISSFLAG_INVERSE | NISSY_NISSFLAG_MIXED);
100 101
102 /* TODO logic here can probably be simplified */
101 if (!arg->lastisnormal) 103 if (!arg->lastisnormal)
102 return (f & NISSY_NISSFLAG_INVERSE) || 104 return (f & NISSY_NISSFLAG_INVERSE) ||
103 ((f & NISSY_NISSFLAG_MIXED) && (nn > 0 || ni < th)); 105 ((f & NISSY_NISSFLAG_MIXED) && (nn > 0 || ni < th));
@@ -118,7 +120,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
118 cube_t backup_cube, backup_inverse; 120 cube_t backup_cube, backup_inverse;
119 121
120 coord = arg->coord->coord(arg->cube, arg->coord_data); 122 coord = arg->coord->coord(arg->cube, arg->coord_data);
121 if (coord == 0) { 123 if (coord_is_solved(arg->coord, coord, arg->coord_data)) {
122 if (!coord_solution_admissible(arg)) 124 if (!coord_solution_admissible(arg))
123 return 0; 125 return 0;
124 return appendsolution(arg->solution_moves, 126 return appendsolution(arg->solution_moves,
@@ -137,7 +139,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
137 ret = 0; 139 ret = 0;
138 if (coord_continue_onnormal(arg)) { 140 if (coord_continue_onnormal(arg)) {
139 l = arg->solution_moves->nmoves; 141 l = arg->solution_moves->nmoves;
140 mm = arg->coord->moves_mask; 142 mm = arg->coord->moves_mask_solve;
141 if (l != 0) { 143 if (l != 0) {
142 m = arg->solution_moves->moves[l-1]; 144 m = arg->solution_moves->moves[l-1];
143 mm &= allowedmask[movebase(m)]; 145 mm &= allowedmask[movebase(m)];
@@ -166,7 +168,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1])
166 168
167 if (coord_continue_oninverse(arg)) { 169 if (coord_continue_oninverse(arg)) {
168 l = arg->solution_moves->npremoves; 170 l = arg->solution_moves->npremoves;
169 mm = arg->coord->moves_mask; 171 mm = arg->coord->moves_mask_solve;
170 if (l != 0) { 172 if (l != 0) {
171 m = arg->solution_moves->premoves[l-1]; 173 m = arg->solution_moves->premoves[l-1];
172 mm &= allowedmask[movebase(m)]; 174 mm &= allowedmask[movebase(m)];
@@ -260,6 +262,7 @@ solve_coord(
260 int8_t d; 262 int8_t d;
261 uint8_t t; 263 uint8_t t;
262 int64_t ndepth; 264 int64_t ndepth;
265 uint64_t i;
263 cube_t c; 266 cube_t c;
264 const unsigned char *coord_data; 267 const unsigned char *coord_data;
265 const unsigned char *ptable; 268 const unsigned char *ptable;
@@ -314,7 +317,8 @@ solve_coord(
314 .nissflag = nissflag, 317 .nissflag = nissflag,
315 }; 318 };
316 319
317 if (coord->coord(c, coord_data) == 0) { 320 i = coord->coord(c, coord_data);
321 if (coord_is_solved(coord, i, coord_data)) {
318 if (minmoves == 0 && !appendsolution(&solution_moves, 322 if (minmoves == 0 && !appendsolution(&solution_moves,
319 &solution_settings, &solution_list)) 323 &solution_settings, &solution_list))
320 goto solve_coord_error_buffer; 324 goto solve_coord_error_buffer;
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h
index 0c7a3a2..2acf146 100644
--- a/src/solvers/coord/types_macros.h
+++ b/src/solvers/coord/types_macros.h
@@ -21,13 +21,17 @@ typedef struct {
21 bool (*isnasty)(uint64_t, const unsigned char *); 21 bool (*isnasty)(uint64_t, const unsigned char *);
22 size_t (*gendata)(unsigned char *); 22 size_t (*gendata)(unsigned char *);
23 uint64_t max; 23 uint64_t max;
24 uint64_t moves_mask; 24 /* moves_mask_gendata must be invariant under trans_mask */
25 uint64_t moves_mask_gendata;
26 uint64_t moves_mask_solve;
25 uint64_t trans_mask; 27 uint64_t trans_mask;
26 uint8_t axistrans[3]; 28 uint8_t axistrans[3];
27 bool (*is_admissible)(const solution_moves_t[static 1]); 29 bool (*is_admissible)(const solution_moves_t[static 1]);
28 bool (*is_solvable)(cube_t); 30 bool (*is_solvable)(cube_t);
31 bool (*is_solved)(uint64_t, const unsigned char *);
29 uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; 32 uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN];
30 uint8_t pruning_max; 33 uint8_t pruning_max;
34 bool allow_niss;
31 struct { 35 struct {
32 size_t classes; 36 size_t classes;
33 uint64_t max; 37 uint64_t max;

Generated with cgit - Back to sebastiano.tronto.net