diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-06 16:34:21 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-06 16:52:12 +0200 |
| commit | 57a7520545134ab95f7bb0397dcbe991c906a3e9 (patch) | |
| tree | 689e20a92ec3830533d2fb868e5dc141dec45877 /src/solvers | |
| parent | a5c9b857a346343443baf49679eebf12c18b4008 (diff) | |
| download | nissy-core-57a7520545134ab95f7bb0397dcbe991c906a3e9.tar.gz nissy-core-57a7520545134ab95f7bb0397dcbe991c906a3e9.zip | |
Added HTR solver
Diffstat (limited to 'src/solvers')
| -rw-r--r-- | src/solvers/coord/common.h | 24 | ||||
| -rw-r--r-- | src/solvers/coord/coord.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/cpepe.h | 15 | ||||
| -rw-r--r-- | src/solvers/coord/dr.h | 15 | ||||
| -rw-r--r-- | src/solvers/coord/dreo.h | 15 | ||||
| -rw-r--r-- | src/solvers/coord/drfinnoe.h | 15 | ||||
| -rw-r--r-- | src/solvers/coord/drslice.h | 15 | ||||
| -rw-r--r-- | src/solvers/coord/eo.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/htr.h | 125 | ||||
| -rw-r--r-- | src/solvers/coord/list.h | 1 | ||||
| -rw-r--r-- | src/solvers/coord/solve.h | 4 | ||||
| -rw-r--r-- | src/solvers/coord/types_macros.h | 1 |
12 files changed, 164 insertions, 68 deletions
diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index 5b5f57b..5f2435d 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h | |||
| @@ -12,6 +12,9 @@ STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, | |||
| 12 | STATIC bool coord_is_solved( | 12 | STATIC bool coord_is_solved( |
| 13 | const coord_t [static 1], uint64_t, const unsigned char *); | 13 | const coord_t [static 1], uint64_t, const unsigned char *); |
| 14 | 14 | ||
| 15 | STATIC cube_t coordinate_merge_ce(cube_t, cube_t); | ||
| 16 | STATIC cube_t coordinate_merge_ec(cube_t, cube_t); | ||
| 17 | |||
| 15 | STATIC uint64_t | 18 | STATIC uint64_t |
| 16 | coord_coord_generic( | 19 | coord_coord_generic( |
| 17 | const coord_t coord[static 1], | 20 | const coord_t coord[static 1], |
| @@ -19,13 +22,11 @@ coord_coord_generic( | |||
| 19 | const unsigned char *data | 22 | const unsigned char *data |
| 20 | ) | 23 | ) |
| 21 | { | 24 | { |
| 22 | const unsigned char *datanoinfo; | ||
| 23 | const uint32_t *data32; | 25 | const uint32_t *data32; |
| 24 | uint32_t d; | 26 | uint32_t d; |
| 25 | cube_t tr; | 27 | cube_t tr; |
| 26 | 28 | ||
| 27 | datanoinfo = data + INFOSIZE; | 29 | data32 = (const uint32_t *)(data + INFOSIZE); |
| 28 | data32 = (const uint32_t *)datanoinfo; | ||
| 29 | d = data32[coord->sym.coord(c)]; | 30 | d = data32[coord->sym.coord(c)]; |
| 30 | tr = transform(c, COORD_TTREP(d)); | 31 | tr = transform(c, COORD_TTREP(d)); |
| 31 | 32 | ||
| @@ -197,3 +198,20 @@ coord_is_solved( | |||
| 197 | { | 198 | { |
| 198 | return coord->is_solved == NULL ? i == 0 : coord->is_solved(i, data); | 199 | return coord->is_solved == NULL ? i == 0 : coord->is_solved(i, data); |
| 199 | } | 200 | } |
| 201 | |||
| 202 | STATIC cube_t | ||
| 203 | coordinate_merge_ce(cube_t corners, cube_t edges) | ||
| 204 | { | ||
| 205 | cube_t merged; | ||
| 206 | |||
| 207 | merged = corners; | ||
| 208 | copy_edges(&merged, edges); | ||
| 209 | |||
| 210 | return merged; | ||
| 211 | } | ||
| 212 | |||
| 213 | STATIC cube_t | ||
| 214 | coordinate_merge_ec(cube_t edges, cube_t corners) | ||
| 215 | { | ||
| 216 | return coordinate_merge_ce(corners, edges); | ||
| 217 | } | ||
diff --git a/src/solvers/coord/coord.h b/src/solvers/coord/coord.h index beb1b6a..db40239 100644 --- a/src/solvers/coord/coord.h +++ b/src/solvers/coord/coord.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "drslice.h" | 7 | #include "drslice.h" |
| 8 | #include "cpepe.h" | 8 | #include "cpepe.h" |
| 9 | #include "drfin.h" | 9 | #include "drfin.h" |
| 10 | #include "htr.h" | ||
| 10 | #include "list.h" | 11 | #include "list.h" |
| 11 | #include "utils.h" | 12 | #include "utils.h" |
| 12 | #include "gendata.h" | 13 | #include "gendata.h" |
diff --git a/src/solvers/coord/cpepe.h b/src/solvers/coord/cpepe.h index 9c9bffc..7035400 100644 --- a/src/solvers/coord/cpepe.h +++ b/src/solvers/coord/cpepe.h | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | STATIC cube_t coordinate_cpepe_merge(const cube_t, const cube_t); | ||
| 2 | STATIC uint64_t coordinate_cpepe_coord(const cube_t, const unsigned char *); | 1 | STATIC uint64_t coordinate_cpepe_coord(const cube_t, const unsigned char *); |
| 3 | STATIC cube_t coordinate_cpepe_cube(uint64_t, const unsigned char *); | 2 | STATIC cube_t coordinate_cpepe_cube(uint64_t, const unsigned char *); |
| 4 | STATIC bool coordinate_cpepe_isnasty(uint64_t, const unsigned char *); | 3 | STATIC bool coordinate_cpepe_isnasty(uint64_t, const unsigned char *); |
| @@ -15,6 +14,7 @@ STATIC coord_t coordinate_cpepe = { | |||
| 15 | .moves_mask_gendata = MM18_DR, | 14 | .moves_mask_gendata = MM18_DR, |
| 16 | .moves_mask_solve = MM18_DR, | 15 | .moves_mask_solve = MM18_DR, |
| 17 | .is_admissible = &solution_always_valid, | 16 | .is_admissible = &solution_always_valid, |
| 17 | .solution_prune = NULL, | ||
| 18 | .is_solvable = &is_drfinnoe_solvable, | 18 | .is_solvable = &is_drfinnoe_solvable, |
| 19 | .is_solved = NULL, | 19 | .is_solved = NULL, |
| 20 | .allow_niss = false, | 20 | .allow_niss = false, |
| @@ -44,21 +44,10 @@ STATIC coord_t coordinate_cpepe = { | |||
| 44 | .max2 = FACT_4, | 44 | .max2 = FACT_4, |
| 45 | .coord2 = &coord_epe, | 45 | .coord2 = &coord_epe, |
| 46 | .cube2 = &invcoord_epe, | 46 | .cube2 = &invcoord_epe, |
| 47 | .merge = &coordinate_cpepe_merge, | 47 | .merge = &coordinate_merge_ce, |
| 48 | }, | 48 | }, |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | STATIC cube_t | ||
| 52 | coordinate_cpepe_merge(const cube_t c1, const cube_t c2) | ||
| 53 | { | ||
| 54 | cube_t merged; | ||
| 55 | |||
| 56 | merged = c1; | ||
| 57 | copy_edges(&merged, c2); | ||
| 58 | |||
| 59 | return merged; | ||
| 60 | } | ||
| 61 | |||
| 62 | STATIC uint64_t | 51 | STATIC uint64_t |
| 63 | coordinate_cpepe_coord(const cube_t cube, const unsigned char *data) | 52 | coordinate_cpepe_coord(const cube_t cube, const unsigned char *data) |
| 64 | { | 53 | { |
diff --git a/src/solvers/coord/dr.h b/src/solvers/coord/dr.h index 03473df..8100910 100644 --- a/src/solvers/coord/dr.h +++ b/src/solvers/coord/dr.h | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | STATIC uint64_t coord_dreoesep_nosym(cube_t); | 4 | STATIC uint64_t coord_dreoesep_nosym(cube_t); |
| 5 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); | 5 | STATIC cube_t invcoord_dreoesep_nosym(uint64_t); |
| 6 | STATIC cube_t coordinate_dr_merge(cube_t, cube_t); | ||
| 7 | 6 | ||
| 8 | STATIC uint64_t coordinate_dr_coord(cube_t, const unsigned char *); | 7 | STATIC uint64_t coordinate_dr_coord(cube_t, const unsigned char *); |
| 9 | STATIC cube_t coordinate_dr_cube(uint64_t, const unsigned char *); | 8 | STATIC cube_t coordinate_dr_cube(uint64_t, const unsigned char *); |
| @@ -23,6 +22,7 @@ STATIC coord_t coordinate_dr = { | |||
| 23 | .moves_mask_gendata = MM18_ALLMOVES, | 22 | .moves_mask_gendata = MM18_ALLMOVES, |
| 24 | .moves_mask_solve = MM18_ALLMOVES, | 23 | .moves_mask_solve = MM18_ALLMOVES, |
| 25 | .is_admissible = &solution_lastqt_cw, | 24 | .is_admissible = &solution_lastqt_cw, |
| 25 | .solution_prune = NULL, | ||
| 26 | .is_solvable = &is_eoco_solvable, | 26 | .is_solvable = &is_eoco_solvable, |
| 27 | .is_solved = NULL, | 27 | .is_solved = NULL, |
| 28 | .allow_niss = true, | 28 | .allow_niss = true, |
| @@ -50,7 +50,7 @@ STATIC coord_t coordinate_dr = { | |||
| 50 | .max2 = POW_3_7, | 50 | .max2 = POW_3_7, |
| 51 | .coord2 = &coord_co, | 51 | .coord2 = &coord_co, |
| 52 | .cube2 = &invcoord_co, | 52 | .cube2 = &invcoord_co, |
| 53 | .merge = &coordinate_dr_merge, | 53 | .merge = &coordinate_merge_ec, |
| 54 | }, | 54 | }, |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| @@ -79,17 +79,6 @@ invcoord_dreoesep_nosym(uint64_t coord) | |||
| 79 | return cube; | 79 | return cube; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | STATIC cube_t | ||
| 83 | coordinate_dr_merge(cube_t c1, cube_t c2) | ||
| 84 | { | ||
| 85 | cube_t merged; | ||
| 86 | |||
| 87 | merged = c1; | ||
| 88 | copy_corners(&merged, c2); | ||
| 89 | |||
| 90 | return merged; | ||
| 91 | } | ||
| 92 | |||
| 93 | STATIC uint64_t | 82 | STATIC uint64_t |
| 94 | coordinate_dr_coord(cube_t cube, const unsigned char *data) | 83 | coordinate_dr_coord(cube_t cube, const unsigned char *data) |
| 95 | { | 84 | { |
diff --git a/src/solvers/coord/dreo.h b/src/solvers/coord/dreo.h index f563129..c5cacac 100644 --- a/src/solvers/coord/dreo.h +++ b/src/solvers/coord/dreo.h | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | 2 | ||
| 3 | STATIC uint64_t coord_dresep_nosym(cube_t); | 3 | STATIC uint64_t coord_dresep_nosym(cube_t); |
| 4 | STATIC cube_t invcoord_dresep_nosym(uint64_t); | 4 | STATIC cube_t invcoord_dresep_nosym(uint64_t); |
| 5 | STATIC cube_t coordinate_dreo_merge(cube_t, cube_t); | ||
| 6 | 5 | ||
| 7 | STATIC uint64_t coordinate_dreo_coord(cube_t, const unsigned char *); | 6 | STATIC uint64_t coordinate_dreo_coord(cube_t, const unsigned char *); |
| 8 | STATIC cube_t coordinate_dreo_cube(uint64_t, const unsigned char *); | 7 | STATIC cube_t coordinate_dreo_cube(uint64_t, const unsigned char *); |
| @@ -22,6 +21,7 @@ STATIC coord_t coordinate_dreo = { | |||
| 22 | .moves_mask_gendata = MM18_EO, | 21 | .moves_mask_gendata = MM18_EO, |
| 23 | .moves_mask_solve = MM18_EO, | 22 | .moves_mask_solve = MM18_EO, |
| 24 | .is_admissible = &solution_lastqt_cw, | 23 | .is_admissible = &solution_lastqt_cw, |
| 24 | .solution_prune = NULL, | ||
| 25 | .is_solvable = &is_dreo_solvable, | 25 | .is_solvable = &is_dreo_solvable, |
| 26 | .is_solved = NULL, | 26 | .is_solved = NULL, |
| 27 | .allow_niss = true, | 27 | .allow_niss = true, |
| @@ -47,7 +47,7 @@ STATIC coord_t coordinate_dreo = { | |||
| 47 | .max2 = POW_3_7, | 47 | .max2 = POW_3_7, |
| 48 | .coord2 = &coord_co, | 48 | .coord2 = &coord_co, |
| 49 | .cube2 = &invcoord_co, | 49 | .cube2 = &invcoord_co, |
| 50 | .merge = &coordinate_dreo_merge, | 50 | .merge = &coordinate_merge_ec, |
| 51 | }, | 51 | }, |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| @@ -63,17 +63,6 @@ invcoord_dresep_nosym(uint64_t coord) | |||
| 63 | return invcoord_esep(coord * COMB_8_4); | 63 | return invcoord_esep(coord * COMB_8_4); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | STATIC cube_t | ||
| 67 | coordinate_dreo_merge(cube_t c1, cube_t c2) | ||
| 68 | { | ||
| 69 | cube_t merged; | ||
| 70 | |||
| 71 | merged = c1; | ||
| 72 | copy_corners(&merged, c2); | ||
| 73 | |||
| 74 | return merged; | ||
| 75 | } | ||
| 76 | |||
| 77 | STATIC uint64_t | 66 | STATIC uint64_t |
| 78 | coordinate_dreo_coord(cube_t cube, const unsigned char *data) | 67 | coordinate_dreo_coord(cube_t cube, const unsigned char *data) |
| 79 | { | 68 | { |
diff --git a/src/solvers/coord/drfinnoe.h b/src/solvers/coord/drfinnoe.h index 4370779..63f4edf 100644 --- a/src/solvers/coord/drfinnoe.h +++ b/src/solvers/coord/drfinnoe.h | |||
| @@ -13,7 +13,6 @@ 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 | ||
| 16 | STATIC cube_t coordinate_drfinnoe_merge(cube_t, cube_t); | ||
| 17 | STATIC uint64_t coordinate_drfinnoe_coord(cube_t, const unsigned char *); | 16 | STATIC uint64_t coordinate_drfinnoe_coord(cube_t, const unsigned char *); |
| 18 | STATIC cube_t coordinate_drfinnoe_cube(uint64_t, const unsigned char *); | 17 | STATIC cube_t coordinate_drfinnoe_cube(uint64_t, const unsigned char *); |
| 19 | STATIC bool coordinate_drfinnoe_isnasty(uint64_t, const unsigned char *); | 18 | STATIC bool coordinate_drfinnoe_isnasty(uint64_t, const unsigned char *); |
| @@ -32,6 +31,7 @@ STATIC coord_t coordinate_drfinnoe = { | |||
| 32 | .moves_mask_gendata = MM18_DR, | 31 | .moves_mask_gendata = MM18_DR, |
| 33 | .moves_mask_solve = MM18_DR, | 32 | .moves_mask_solve = MM18_DR, |
| 34 | .is_admissible = &solution_always_valid, | 33 | .is_admissible = &solution_always_valid, |
| 34 | .solution_prune = NULL, | ||
| 35 | .is_solvable = &is_drfinnoe_solvable, | 35 | .is_solvable = &is_drfinnoe_solvable, |
| 36 | .is_solved = NULL, | 36 | .is_solved = NULL, |
| 37 | .allow_niss = false, | 37 | .allow_niss = false, |
| @@ -62,21 +62,10 @@ STATIC coord_t coordinate_drfinnoe = { | |||
| 62 | .max2 = FACT_8, | 62 | .max2 = FACT_8, |
| 63 | .coord2 = &coord_epud, | 63 | .coord2 = &coord_epud, |
| 64 | .cube2 = &invcoord_epud, | 64 | .cube2 = &invcoord_epud, |
| 65 | .merge = &coordinate_drfinnoe_merge, | 65 | .merge = &coordinate_merge_ce, |
| 66 | }, | 66 | }, |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | STATIC cube_t | ||
| 70 | coordinate_drfinnoe_merge(cube_t c1, cube_t c2) | ||
| 71 | { | ||
| 72 | cube_t merged; | ||
| 73 | |||
| 74 | merged = c1; | ||
| 75 | copy_edges(&merged, c2); | ||
| 76 | |||
| 77 | return merged; | ||
| 78 | } | ||
| 79 | |||
| 80 | STATIC uint64_t | 69 | STATIC uint64_t |
| 81 | coordinate_drfinnoe_coord(cube_t cube, const unsigned char *data) | 70 | coordinate_drfinnoe_coord(cube_t cube, const unsigned char *data) |
| 82 | { | 71 | { |
diff --git a/src/solvers/coord/drslice.h b/src/solvers/coord/drslice.h index c9403f8..42699f8 100644 --- a/src/solvers/coord/drslice.h +++ b/src/solvers/coord/drslice.h | |||
| @@ -5,7 +5,6 @@ much of the code of DRFINNOE. We could make the pruning table 4x smaller | |||
| 5 | if we reduced the coordinate by rotations. TODO. | 5 | if we reduced the coordinate by rotations. TODO. |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | STATIC cube_t coordinate_drslice_merge(cube_t, cube_t); | ||
| 9 | STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *); | 8 | STATIC uint64_t coordinate_drslice_coord(cube_t, const unsigned char *); |
| 10 | STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *); | 9 | STATIC cube_t coordinate_drslice_cube(uint64_t, const unsigned char *); |
| 11 | STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *); | 10 | STATIC bool coordinate_drslice_isnasty(uint64_t, const unsigned char *); |
| @@ -24,6 +23,7 @@ STATIC coord_t coordinate_drslice = { | |||
| 24 | .moves_mask_gendata = MM18_DR, | 23 | .moves_mask_gendata = MM18_DR, |
| 25 | .moves_mask_solve = MM18_DR_NOD, | 24 | .moves_mask_solve = MM18_DR_NOD, |
| 26 | .is_admissible = &solution_always_valid, | 25 | .is_admissible = &solution_always_valid, |
| 26 | .solution_prune = NULL, | ||
| 27 | .is_solvable = &is_drslice_solvable, | 27 | .is_solvable = &is_drslice_solvable, |
| 28 | .is_solved = &is_drslice_solved, | 28 | .is_solved = &is_drslice_solved, |
| 29 | .allow_niss = false, | 29 | .allow_niss = false, |
| @@ -54,21 +54,10 @@ STATIC coord_t coordinate_drslice = { | |||
| 54 | .max2 = FACT_8, | 54 | .max2 = FACT_8, |
| 55 | .coord2 = &coord_epud, | 55 | .coord2 = &coord_epud, |
| 56 | .cube2 = &invcoord_epud, | 56 | .cube2 = &invcoord_epud, |
| 57 | .merge = &coordinate_drslice_merge, | 57 | .merge = &coordinate_merge_ce, |
| 58 | }, | 58 | }, |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | STATIC cube_t | ||
| 62 | coordinate_drslice_merge(cube_t c1, cube_t c2) | ||
| 63 | { | ||
| 64 | cube_t merged; | ||
| 65 | |||
| 66 | merged = c1; | ||
| 67 | copy_edges(&merged, c2); | ||
| 68 | |||
| 69 | return merged; | ||
| 70 | } | ||
| 71 | |||
| 72 | STATIC uint64_t | 61 | STATIC uint64_t |
| 73 | coordinate_drslice_coord(cube_t cube, const unsigned char *data) | 62 | coordinate_drslice_coord(cube_t cube, const unsigned char *data) |
| 74 | { | 63 | { |
diff --git a/src/solvers/coord/eo.h b/src/solvers/coord/eo.h index 5c823a1..42196af 100644 --- a/src/solvers/coord/eo.h +++ b/src/solvers/coord/eo.h | |||
| @@ -14,6 +14,7 @@ STATIC coord_t coordinate_eo = { | |||
| 14 | .moves_mask_gendata = MM18_ALLMOVES, | 14 | .moves_mask_gendata = MM18_ALLMOVES, |
| 15 | .moves_mask_solve = MM18_ALLMOVES, | 15 | .moves_mask_solve = MM18_ALLMOVES, |
| 16 | .is_admissible = &solution_lastqt_cw, | 16 | .is_admissible = &solution_lastqt_cw, |
| 17 | .solution_prune = NULL, | ||
| 17 | .is_solvable = &is_eo_even, | 18 | .is_solvable = &is_eo_even, |
| 18 | .is_solved = NULL, | 19 | .is_solved = NULL, |
| 19 | .allow_niss = true, | 20 | .allow_niss = true, |
diff --git a/src/solvers/coord/htr.h b/src/solvers/coord/htr.h new file mode 100644 index 0000000..cfd451b --- /dev/null +++ b/src/solvers/coord/htr.h | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | STATIC uint64_t coordinate_htr_coord(cube_t, const unsigned char *); | ||
| 2 | STATIC cube_t coordinate_htr_cube(uint64_t, const unsigned char *); | ||
| 3 | STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *); | ||
| 4 | STATIC size_t coordinate_htr_gendata(unsigned char *); | ||
| 5 | |||
| 6 | STATIC bool htr_checkmoves(bool *, uint8_t, const uint8_t *); | ||
| 7 | STATIC bool htr_solution_prune(const solution_moves_t [static 1]); | ||
| 8 | STATIC bool is_cp_htr(uint64_t, const unsigned char *); | ||
| 9 | |||
| 10 | STATIC coord_t coordinate_htr = { | ||
| 11 | .name = "HTR", | ||
| 12 | .coord = &coordinate_htr_coord, | ||
| 13 | .cube = &coordinate_htr_cube, | ||
| 14 | .isnasty = &coordinate_htr_isnasty, | ||
| 15 | .gendata = coordinate_htr_gendata, | ||
| 16 | .max = CLASSES_CP_16 * COMB_8_4, | ||
| 17 | .trans_mask = TM_UDFIX, | ||
| 18 | .moves_mask_gendata = MM18_DR, | ||
| 19 | .moves_mask_solve = MM18_DRHTR, | ||
| 20 | .is_admissible = &solution_lastqt_cw, | ||
| 21 | .solution_prune = &htr_solution_prune, | ||
| 22 | .is_solvable = &is_drfinnoe_solvable, | ||
| 23 | .is_solved = &is_cp_htr, | ||
| 24 | .allow_niss = true, | ||
| 25 | .pruning_distribution = { | ||
| 26 | [0] = 22, | ||
| 27 | [1] = 18, | ||
| 28 | [2] = 86, | ||
| 29 | [3] = 268, | ||
| 30 | [4] = 920, | ||
| 31 | [5] = 4042, | ||
| 32 | [6] = 12716, | ||
| 33 | [7] = 24852, | ||
| 34 | [8] = 33116, | ||
| 35 | [9] = 45032, | ||
| 36 | [10] = 47144, | ||
| 37 | [11] = 21676, | ||
| 38 | [12] = 3692, | ||
| 39 | [13] = 176 | ||
| 40 | }, | ||
| 41 | .pruning_max = 13, | ||
| 42 | .sym = { | ||
| 43 | .classes = CLASSES_CP_16, | ||
| 44 | .max = FACT_8, | ||
| 45 | .coord = &coord_cp, | ||
| 46 | .cube = &invcoord_cp, | ||
| 47 | .max2 = COMB_8_4, | ||
| 48 | .coord2 = &coord_epudsep, | ||
| 49 | .cube2 = &invcoord_epudsep, | ||
| 50 | .merge = &coordinate_merge_ce, | ||
| 51 | }, | ||
| 52 | }; | ||
| 53 | |||
| 54 | STATIC uint64_t | ||
| 55 | coordinate_htr_coord(cube_t cube, const unsigned char *data) | ||
| 56 | { | ||
| 57 | return coord_coord_generic(&coordinate_htr, cube, data); | ||
| 58 | } | ||
| 59 | |||
| 60 | STATIC cube_t | ||
| 61 | coordinate_htr_cube(uint64_t i, const unsigned char *data) | ||
| 62 | { | ||
| 63 | return coord_cube_generic(&coordinate_htr, i, data); | ||
| 64 | } | ||
| 65 | |||
| 66 | STATIC bool | ||
| 67 | coordinate_htr_isnasty(uint64_t i, const unsigned char *data) | ||
| 68 | { | ||
| 69 | return coord_isnasty_generic(&coordinate_htr, i, data); | ||
| 70 | } | ||
| 71 | |||
| 72 | STATIC size_t | ||
| 73 | coordinate_htr_gendata(unsigned char *data) | ||
| 74 | { | ||
| 75 | return coord_gendata_generic(&coordinate_htr, data); | ||
| 76 | } | ||
| 77 | |||
| 78 | STATIC bool | ||
| 79 | htr_checkmoves(bool *f, uint8_t n, const uint8_t *moves) | ||
| 80 | { | ||
| 81 | uint8_t i; | ||
| 82 | bool is_d, is_u; | ||
| 83 | |||
| 84 | for (i = 0; i < n; i++) { | ||
| 85 | is_d = moves[i] == MOVE_D || moves[i] == MOVE_D3; | ||
| 86 | is_u = moves[i] == MOVE_U || moves[i] == MOVE_U3; | ||
| 87 | if (is_d && *f) | ||
| 88 | return true; | ||
| 89 | *f = *f || is_d || is_u; | ||
| 90 | |||
| 91 | if (i < n-1 && moveaxis(moves[i]) == 0 && | ||
| 92 | parallel(moves[i], moves[i+1])) | ||
| 93 | return true; | ||
| 94 | } | ||
| 95 | |||
| 96 | return false; | ||
| 97 | } | ||
| 98 | |||
| 99 | STATIC bool | ||
| 100 | htr_solution_prune(const solution_moves_t s[static 1]) | ||
| 101 | { | ||
| 102 | bool f; | ||
| 103 | |||
| 104 | f = false; | ||
| 105 | |||
| 106 | return htr_checkmoves(&f, s->nmoves, s->moves) || | ||
| 107 | htr_checkmoves(&f, s->npremoves, s->premoves); | ||
| 108 | } | ||
| 109 | |||
| 110 | STATIC bool | ||
| 111 | is_cp_htr(uint64_t i, const unsigned char *data) | ||
| 112 | { | ||
| 113 | static uint8_t is_cp16_htr_table[DIV_ROUND_UP(CLASSES_CP_16, 8)] = { | ||
| 114 | [0] = 81, [7] = 144, [8] = 16, [25] = 130, [26] = 34, | ||
| 115 | [37] = 64, [38] = 48, [39] = 8, [212] = 20, [226] = 32, | ||
| 116 | [227] = 2, [298] = 160, [300] = 128, [301] = 1 | ||
| 117 | }; | ||
| 118 | |||
| 119 | uint64_t e, c; | ||
| 120 | |||
| 121 | e = i % COMB_8_4; | ||
| 122 | c = i / COMB_8_4; | ||
| 123 | |||
| 124 | return e == 0 && is_cp16_htr_table[c / 8] & (UINT8_C(1) << (c % 8)); | ||
| 125 | } | ||
diff --git a/src/solvers/coord/list.h b/src/solvers/coord/list.h index 7bc8041..9b59969 100644 --- a/src/solvers/coord/list.h +++ b/src/solvers/coord/list.h | |||
| @@ -5,6 +5,7 @@ coord_t *all_coordinates[] = { | |||
| 5 | &coordinate_drfinnoe, | 5 | &coordinate_drfinnoe, |
| 6 | &coordinate_drslice, | 6 | &coordinate_drslice, |
| 7 | &coordinate_cpepe, | 7 | &coordinate_cpepe, |
| 8 | &coordinate_htr, | ||
| 8 | NULL | 9 | NULL |
| 9 | }; | 10 | }; |
| 10 | 11 | ||
diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index 72bc064..54309b1 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h | |||
| @@ -155,6 +155,10 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[static 1]) | |||
| 155 | int64_t n, ret; | 155 | int64_t n, ret; |
| 156 | cube_t backup_cube, backup_inverse; | 156 | cube_t backup_cube, backup_inverse; |
| 157 | 157 | ||
| 158 | if (arg->coord->solution_prune != NULL && | ||
| 159 | arg->coord->solution_prune(arg->solution_moves)) | ||
| 160 | return 0; | ||
| 161 | |||
| 158 | coord = arg->coord->coord(arg->cube, arg->coord_data); | 162 | coord = arg->coord->coord(arg->cube, arg->coord_data); |
| 159 | if (coord_is_solved(arg->coord, coord, arg->coord_data)) { | 163 | if (coord_is_solved(arg->coord, coord, arg->coord_data)) { |
| 160 | if (!coord_solution_admissible(arg)) | 164 | if (!coord_solution_admissible(arg)) |
diff --git a/src/solvers/coord/types_macros.h b/src/solvers/coord/types_macros.h index 73484ba..98f9822 100644 --- a/src/solvers/coord/types_macros.h +++ b/src/solvers/coord/types_macros.h | |||
| @@ -28,6 +28,7 @@ typedef struct { | |||
| 28 | uint64_t moves_mask_solve; | 28 | uint64_t moves_mask_solve; |
| 29 | uint64_t trans_mask; | 29 | uint64_t trans_mask; |
| 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 (*is_solvable)(cube_t); | 32 | bool (*is_solvable)(cube_t); |
| 32 | bool (*is_solved)(uint64_t, const unsigned char *); | 33 | bool (*is_solved)(uint64_t, const unsigned char *); |
| 33 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; | 34 | uint64_t pruning_distribution[INFO_DISTRIBUTION_LEN]; |
