aboutsummaryrefslogtreecommitdiff
path: root/src/solvers/coord/htr.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-08-06 16:34:21 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-08-06 16:52:12 +0200
commit57a7520545134ab95f7bb0397dcbe991c906a3e9 (patch)
tree689e20a92ec3830533d2fb868e5dc141dec45877 /src/solvers/coord/htr.h
parenta5c9b857a346343443baf49679eebf12c18b4008 (diff)
downloadnissy-core-57a7520545134ab95f7bb0397dcbe991c906a3e9.tar.gz
nissy-core-57a7520545134ab95f7bb0397dcbe991c906a3e9.zip
Added HTR solver
Diffstat (limited to 'src/solvers/coord/htr.h')
-rw-r--r--src/solvers/coord/htr.h125
1 files changed, 125 insertions, 0 deletions
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 @@
1STATIC uint64_t coordinate_htr_coord(cube_t, const unsigned char *);
2STATIC cube_t coordinate_htr_cube(uint64_t, const unsigned char *);
3STATIC bool coordinate_htr_isnasty(uint64_t, const unsigned char *);
4STATIC size_t coordinate_htr_gendata(unsigned char *);
5
6STATIC bool htr_checkmoves(bool *, uint8_t, const uint8_t *);
7STATIC bool htr_solution_prune(const solution_moves_t [static 1]);
8STATIC bool is_cp_htr(uint64_t, const unsigned char *);
9
10STATIC 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
54STATIC uint64_t
55coordinate_htr_coord(cube_t cube, const unsigned char *data)
56{
57 return coord_coord_generic(&coordinate_htr, cube, data);
58}
59
60STATIC cube_t
61coordinate_htr_cube(uint64_t i, const unsigned char *data)
62{
63 return coord_cube_generic(&coordinate_htr, i, data);
64}
65
66STATIC bool
67coordinate_htr_isnasty(uint64_t i, const unsigned char *data)
68{
69 return coord_isnasty_generic(&coordinate_htr, i, data);
70}
71
72STATIC size_t
73coordinate_htr_gendata(unsigned char *data)
74{
75 return coord_gendata_generic(&coordinate_htr, data);
76}
77
78STATIC bool
79htr_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
99STATIC bool
100htr_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
110STATIC bool
111is_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}

Generated with cgit - Back to sebastiano.tronto.net