1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
#include "steps.h"
/* Standard checkers (return lower bound) ************************************/
static int estimate_eofb_HTM(CubeTarget ct);
static int estimate_coud_HTM(CubeTarget ct);
static int estimate_coud_URF(CubeTarget ct);
static int estimate_corners_HTM(CubeTarget ct);
static int estimate_cornershtr_HTM(CubeTarget ct);
static int estimate_corners_URF(CubeTarget ct);
static int estimate_cornershtr_URF(CubeTarget ct);
static int estimate_drud_HTM(CubeTarget ct);
static int estimate_optimal_HTM(CubeTarget ct);
/* Steps *********************************************************************/
Step
eofb_HTM = {
.estimate = estimate_eofb_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
Step
coud_HTM = {
.estimate = estimate_coud_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
Step
coud_URF = {
.estimate = estimate_coud_URF,
.ready = check_nothing,
.moveset = moveset_URF
};
Step
corners_HTM = {
.estimate = estimate_corners_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
Step
cornershtr_HTM = {
.estimate = estimate_cornershtr_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
Step
cornershtr_URF = {
.estimate = estimate_cornershtr_URF,
.ready = check_nothing,
.moveset = moveset_URF
};
Step
corners_URF = {
.estimate = estimate_corners_URF,
.ready = check_nothing,
.moveset = moveset_URF
};
Step
drud_HTM = {
.estimate = estimate_drud_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
Step
optimal_HTM = {
.estimate = estimate_optimal_HTM,
.ready = check_centers,
.moveset = moveset_HTM
};
/* Pruning tables ************************************************************/
PruneData
pd_eofb_HTM = {
.filename = "ptable_eofb_HTM",
.coord = &coord_eofb,
.moveset = moveset_HTM,
.ntrans = 1,
.trans = trans_group_trivial
};
PruneData
pd_coud_HTM = {
.filename = "ptable_coud_HTM",
.coord = &coord_coud,
.moveset = moveset_HTM,
.ntrans = 1,
.trans = trans_group_trivial
};
PruneData
pd_cornershtr_HTM = {
.filename = "ptable_cornershtr_withcosets_HTM",
.coord = &coord_cornershtr,
.moveset = moveset_HTM,
.ntrans = 1,
.trans = trans_group_trivial
};
PruneData
pd_corners_HTM = {
.filename = "ptable_corners_HTM",
.coord = &coord_corners,
.moveset = moveset_HTM,
.ntrans = 1,
.trans = trans_group_trivial
};
PruneData
pd_drud_HTM = {
.filename = "ptable_drud_HTM",
.coord = &coord_drud,
.moveset = moveset_HTM,
.ntrans = 1,
.trans = trans_group_trivial
};
PruneData
pd_drud_sym16_HTM = {
.filename = "ptable_drud_sym16_HTM",
.coord = &coord_drud_sym16,
.moveset = moveset_HTM,
.ntrans = 16,
.trans = trans_group_udfix
};
PruneData
pd_khuge_HTM = {
.filename = "ptable_khuge_HTM",
.coord = &coord_khuge,
.moveset = moveset_HTM,
.ntrans = 16,
.trans = trans_group_udfix
};
/* Standard checkers (return lower bound) ************************************/
static int
estimate_eofb_HTM(CubeTarget ct)
{
if (!pd_eofb_HTM.generated)
genptable(&pd_eofb_HTM);
return ptableval(&pd_eofb_HTM, ct.cube);
}
static int
estimate_coud_HTM(CubeTarget ct)
{
if (!pd_coud_HTM.generated)
genptable(&pd_coud_HTM);
return ptableval(&pd_coud_HTM, ct.cube);
}
static int
estimate_coud_URF(CubeTarget ct)
{
/* TODO: I can improve this by checking first the orientation of
* the corner in DBL and use that as a reference */
CubeTarget ct2 = {.cube = apply_move(z, ct.cube), .target = ct.target};
CubeTarget ct3 = {.cube = apply_move(x, ct.cube), .target = ct.target};
int ud = estimate_coud_HTM(ct);
int rl = estimate_coud_HTM(ct2);
int fb = estimate_coud_HTM(ct3);
return MIN(ud, MIN(rl, fb));
}
static int
estimate_corners_HTM(CubeTarget ct)
{
if (!pd_corners_HTM.generated)
genptable(&pd_corners_HTM);
return ptableval(&pd_corners_HTM, ct.cube);
}
static int
estimate_cornershtr_HTM(CubeTarget ct)
{
if (!pd_cornershtr_HTM.generated)
genptable(&pd_cornershtr_HTM);
return ptableval(&pd_cornershtr_HTM, ct.cube);
}
static int
estimate_cornershtr_URF(CubeTarget ct)
{
/* TODO: I can improve this by checking first the corner in DBL
* and use that as a reference */
int c, ret = 15;
Trans i;
for (i = 0; i < NROTATIONS; i++) {
ct.cube = apply_alg(rotation_alg(i), ct.cube);
c = estimate_cornershtr_HTM(ct);
ret = MIN(ret, c);
}
return ret;
}
static int
estimate_corners_URF(CubeTarget ct)
{
/* TODO: I can improve this by checking first the corner in DBL
* and use that as a reference */
int c, ret = 15;
Trans i;
for (i = 0; i < NROTATIONS; i++) {
ct.cube = apply_alg(rotation_alg(i), ct.cube);
c = estimate_corners_HTM(ct);
ret = MIN(ret, c);
}
return ret;
}
static int
estimate_drud_HTM(CubeTarget ct)
{
/*
if (!pd_drud_HTM.generated)
genptable(&pd_drud_HTM);
return ptableval(&pd_drud_HTM, ct.cube);
*/
if (!pd_drud_sym16_HTM.generated)
genptable(&pd_drud_sym16_HTM);
return ptableval(&pd_drud_sym16_HTM, ct.cube);
}
static int
estimate_optimal_HTM(CubeTarget ct)
{
int dr1, dr2, dr3, cor, ret;
Cube cube = ct.cube;
if (!pd_khuge_HTM.generated)
genptable(&pd_khuge_HTM);
dr1 = ptableval(&pd_khuge_HTM, cube);
cor = estimate_corners_HTM(ct);
ret = MAX(dr1, cor);
if (ret > ct.target)
return ret;
cube = apply_trans(rf, ct.cube);
dr2 = ptableval(&pd_khuge_HTM, cube);
ret = MAX(ret, dr2);
if (ret > ct.target)
return ret;
cube = apply_trans(fd, ct.cube);
dr3 = ptableval(&pd_khuge_HTM, cube);
/* Michiel de Bondt's trick */
if (dr1 == dr2 && dr2 == dr3 && dr1 != 0)
dr3++;
return MAX(ret, dr3);
}
|