aboutsummaryrefslogtreecommitdiff
path: root/old/2021-06-23-realizing-bad-tables/steps.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 22:05:00 +0100
committerSebastiano Tronto <sebastiano.tronto@gmail.com>2021-11-11 22:05:00 +0100
commit4fb67201414169a2687f41c4056b2e284b4938cb (patch)
treea68246e3e21435229541f83f485ab41cfb2ba08a /old/2021-06-23-realizing-bad-tables/steps.c
parent3568412f8f230774d0d11d7ed1c897424f95d3ef (diff)
downloadnissy-4fb67201414169a2687f41c4056b2e284b4938cb.tar.gz
nissy-4fb67201414169a2687f41c4056b2e284b4938cb.zip
Removed old files
Diffstat (limited to '')
-rw-r--r--old/2021-06-23-realizing-bad-tables/steps.c486
1 files changed, 0 insertions, 486 deletions
diff --git a/old/2021-06-23-realizing-bad-tables/steps.c b/old/2021-06-23-realizing-bad-tables/steps.c
deleted file mode 100644
index 2b029b8..0000000
--- a/old/2021-06-23-realizing-bad-tables/steps.c
+++ /dev/null
@@ -1,486 +0,0 @@
1#include "steps.h"
2
3/* Check functions ***********************************************************/
4
5static int check_nothing(Cube cube, int target);
6static int check_centers(Cube cube, int target);
7static int check_eofb_HTM(Cube cube, int target);
8static int check_coud_HTM(Cube cube, int target);
9static int check_coud_URF(Cube cube, int target);
10static int check_corners_HTM(Cube cube, int target);
11static int check_cornershtr_HTM(Cube cube, int target);
12static int check_corners_URF(Cube cube, int target);
13static int check_cornershtr_URF(Cube cube, int target);
14static int check_ep_HTM(Cube cube, int target);
15static int check_edges_HTM(Cube cube, int target);
16static int check_drud_HTM(Cube cube, int target);
17static int check_optimal_HTM(Cube cube, int target);
18static int check_corners6eo_HTM(Cube cube, int target);
19static int check_tripleeo_HTM(Cube cube, int target);
20
21
22/* Index functions ***********************************************************/
23
24static uint64_t index_eofb(Cube cube);
25static uint64_t index_coud(Cube cube);
26static uint64_t index_corners(Cube cube);
27static uint64_t index_cornershtr(Cube cube);
28static uint64_t index_ep(Cube cube);
29static uint64_t index_drud(Cube cube);
30static uint64_t index_corners6eo(Cube cube);
31static uint64_t index_tripleeo(Cube cube);
32
33
34/* Steps *********************************************************************/
35
36Step
37eofb_HTM = {
38 .check = check_eofb_HTM,
39 .ready = check_centers,
40 .moveset = moveset_HTM
41};
42
43Step
44coud_HTM = {
45 .check = check_coud_HTM,
46 .ready = check_centers,
47 .moveset = moveset_HTM
48};
49
50Step
51coud_URF = {
52 .check = check_coud_URF,
53 .ready = check_nothing,
54 .moveset = moveset_URF
55};
56
57Step
58corners_HTM = {
59 .check = check_corners_HTM,
60 .ready = check_centers,
61 .moveset = moveset_HTM
62};
63
64Step
65cornershtr_HTM = {
66 .check = check_cornershtr_HTM,
67 .ready = check_centers,
68 .moveset = moveset_HTM
69};
70
71Step
72cornershtr_URF = {
73 .check = check_cornershtr_URF,
74 .ready = check_nothing,
75 .moveset = moveset_URF
76};
77
78Step
79corners_URF = {
80 .check = check_corners_URF,
81 .ready = check_nothing,
82 .moveset = moveset_URF
83};
84
85Step
86edges_HTM = {
87 .check = check_edges_HTM,
88 .ready = check_centers,
89 .moveset = moveset_HTM
90};
91
92Step
93drud_HTM = {
94 .check = check_drud_HTM,
95 .ready = check_centers,
96 .moveset = moveset_HTM
97};
98
99Step
100optimal_HTM = {
101 .check = check_optimal_HTM,
102 .ready = check_centers,
103 .moveset = moveset_HTM
104};
105
106Step
107tripleeo_HTM = {
108 .check = check_tripleeo_HTM,
109 .ready = check_centers,
110 .moveset = moveset_HTM
111};
112
113
114/* Blocks ********************************************************************/
115
116Block
117block_223dl = {
118 .edge = { [DF] = 1, [DL] = 1, [DB] = 1, [FL] = 1, [BL] = 1 },
119 .corner = { [DFL] = 1, [DBL] = 1 },
120 .center = { [D_center] = 1, [L_center] = 1 }
121};
122
123
124/* Pruning tables ************************************************************/
125
126PruneData
127pd_eofb_HTM = {
128 .filename = "ptable_eofb_HTM",
129 .size = POW2TO11,
130 .index = index_eofb,
131 .moveset = moveset_HTM
132};
133
134PruneData
135pd_coud_HTM = {
136 .filename = "ptable_coud_HTM",
137 .size = POW3TO7,
138 .index = index_coud,
139 .moveset = moveset_HTM
140};
141
142PruneData
143pd_cornershtr_HTM = {
144 .filename = "ptable_cornershtr_HTM",
145 .size = POW3TO7 * BINOM8ON4 * 6, /*TODO: check */
146 .index = index_cornershtr,
147 .moveset = moveset_HTM
148};
149
150PruneData
151pd_corners_HTM = {
152 .filename = "ptable_corners_HTM",
153 .size = POW3TO7 * FACTORIAL8,
154 .index = index_corners,
155 .moveset = moveset_HTM
156};
157
158PruneData
159pd_ep_HTM = {
160 .filename = "ptable_ep_HTM",
161 .size = FACTORIAL12,
162 .index = index_ep,
163 .moveset = moveset_HTM
164};
165
166PruneData
167pd_drud_HTM = {
168 .filename = "ptable_drud_HTM",
169 .size = POW2TO11 * POW3TO7 * BINOM12ON4,
170 .index = index_drud,
171 .moveset = moveset_HTM
172};
173
174PruneData
175pd_corners6eo_HTM = {
176 .filename = "ptable_corners6eo_HTM",
177 .size = POW2TO6 * POW3TO7 * FACTORIAL8,
178 .index = index_corners6eo,
179 .moveset = moveset_HTM
180};
181
182PruneData
183pd_tripleeo_HTM = {
184 .filename = "ptable_tripleeo_HTM",
185 .size = BINOM12ON4 * BINOM8ON4 * POW2TO11,
186 .index = index_tripleeo,
187 .moveset = moveset_HTM
188};
189
190
191/* Alg sets ******************************************************************/
192
193/* TODO: remove this (I am only keeping it as an example for future algesets)
194AlgSet
195as_ephtr_HTM = {
196 .filename = "algset_ephtr_HTM",
197 .size = FACTORIAL4 * FACTORIAL4 * FACTORIAL4,
198 .index = index_ephtr,
199 .antindex = index_to_cube_ephtr,
200 .step = (Step) {
201 .check = check_optimal_HTM,
202 .ready = check_htr_solved_corners_HTM,
203 .moveset = moveset_HTM
204 },
205 .opts = (SolveOptions) {
206 .min_moves = 0,
207 .max_moves = 20,
208 .max_solutions = 1,
209 .optimal_only = true,
210 .can_niss = false,
211 .feedback = true,
212 .pre_trans = uf
213 }
214};
215*/
216
217
218/* Check functions implementation ********************************************/
219
220static int
221check_nothing(Cube cube, int target)
222{
223 return 0;
224}
225
226static int
227check_centers(Cube cube, int target)
228{
229 return (cube.cpos == 0) ? 0 : 1;
230}
231
232static int
233check_eofb_HTM(Cube cube, int target)
234{
235 if (!pd_eofb_HTM.generated)
236 genptable(&pd_eofb_HTM);
237
238 return ptableval(&pd_eofb_HTM, cube.eofb);
239}
240
241static int
242check_coud_HTM(Cube cube, int target)
243{
244 if (!pd_coud_HTM.generated)
245 genptable(&pd_coud_HTM);
246
247 return ptableval(&pd_coud_HTM, cube.coud);
248}
249
250static int
251check_coud_URF(Cube cube, int target)
252{
253 /* TODO: I can improve this by checking first the orientation of
254 * the corner in DBL and use that as a reference */
255
256 int ud = check_coud_HTM(cube, target);
257 int rl = check_coud_HTM(apply_move(z, cube), target);
258 int fb = check_coud_HTM(apply_move(x, cube), target);
259
260 return MIN(ud, MIN(rl, fb));
261}
262
263static int
264check_corners_HTM(Cube cube, int target)
265{
266 if (!pd_corners_HTM.generated)
267 genptable(&pd_corners_HTM);
268
269 return ptableval(&pd_corners_HTM, index_corners(cube));
270}
271
272static int
273check_cornershtr_HTM(Cube cube, int target)
274{
275 if (!pd_cornershtr_HTM.generated)
276 genptable(&pd_cornershtr_HTM);
277
278 return ptableval(&pd_cornershtr_HTM, index_cornershtr(cube));
279}
280
281static int
282check_cornershtr_URF(Cube cube, int target)
283{
284 /* TODO: I can improve this by checking first the corner in DBL
285 * and use that as a reference */
286
287 int c, ret = 15;
288 Trans i;
289
290 for (i = 0; i < NROTATIONS; i++) {
291 c = check_cornershtr_HTM(apply_alg(trans_alg(i),cube), target);
292 ret = MIN(ret, c);
293 }
294
295 return ret;
296}
297
298static int
299check_corners_URF(Cube cube, int target)
300{
301 /* TODO: I can improve this by checking first the corner in DBL
302 * and use that as a reference */
303
304 int ret = 15;
305 Trans i;
306
307 for (i = 0; i < NROTATIONS; i++)
308 ret = MIN(ret, check_corners_HTM(
309 apply_alg(trans_alg(i), cube), target));
310
311 return ret;
312}
313
314static int
315check_ep_HTM(Cube cube, int target)
316{
317 if (!pd_ep_HTM.generated)
318 genptable(&pd_ep_HTM);
319
320 return ptableval(&pd_ep_HTM, index_ep(cube));
321}
322
323static int
324check_edges_HTM(Cube cube, int target)
325{
326 return MAX(check_ep_HTM(cube, target),
327 check_tripleeo_HTM(cube, target));
328}
329
330static int
331check_drud_HTM(Cube cube, int target)
332{
333 if (!pd_drud_HTM.generated)
334 genptable(&pd_drud_HTM);
335
336 return ptableval(&pd_drud_HTM, index_drud(cube));
337}
338
339static int
340check_optimal_HTM(Cube cube, int target)
341{
342 int dr1, dr2, dr3, cor, ret;
343 Cube cube2, cube3;
344
345 dr1 = check_drud_HTM(cube, target);
346 /*cor = check_corners6eo_HTM(cube, target);*/
347 cor = check_corners_HTM(cube, target);
348 ret = MAX(dr1, cor);
349
350 if (ret > target)
351 return ret;
352
353 cube2 = apply_trans(rf, cube);
354 dr2 = check_drud_HTM(cube2, target);
355 /*cor = check_corners6eo_HTM(cube2, target);
356 ret = MAX(ret, MAX(dr2, cor));*/
357 ret = MAX(ret, dr2);
358
359 if (ret > target)
360 return ret;
361
362 cube3 = apply_trans(bd, cube);
363 dr3 = check_drud_HTM(cube3, target);
364 /*cor = check_corners6eo_HTM(cube3, target);*/
365
366 if (dr1 == dr2 && dr2 == dr3 && dr1 != 0)
367 dr3++;
368
369 /*ret = MAX(ret, MAX(dr3, cor));*/
370 ret = MAX(ret, dr3);
371
372 if (ret == 0)
373 return (!cube.epose && !cube.eposs && !cube.eposm) ? 0 : 6;
374
375 return ret;
376}
377
378static int
379check_corners6eo_HTM(Cube cube, int target)
380{
381 if (!pd_corners6eo_HTM.generated)
382 genptable(&pd_corners6eo_HTM);
383
384 return ptableval(&pd_corners6eo_HTM, index_corners6eo(cube));
385}
386
387static int
388check_tripleeo_HTM(Cube cube, int target)
389{
390 if (!pd_tripleeo_HTM.generated)
391 genptable(&pd_tripleeo_HTM);
392
393 return ptableval(&pd_tripleeo_HTM, index_tripleeo(cube));
394}
395
396
397/* Index functions implementation ********************************************/
398
399static uint64_t
400index_eofb(Cube cube)
401{
402 return cube.eofb;
403}
404
405static uint64_t
406index_coud(Cube cube)
407{
408 return cube.coud;
409}
410
411static uint64_t
412index_cornershtr(Cube cube)
413{
414 return cube.coud * BINOM8ON4 * 6 + cphtr(cube);
415}
416
417static uint64_t
418index_corners(Cube cube)
419{
420 return cube.coud * FACTORIAL8 + cube.cp;
421}
422
423static uint64_t
424index_ep(Cube cube)
425{
426 uint64_t a, b, c;
427
428 a = cube.epose;
429 b = (cube.eposs % FACTORIAL4) + epos_dependent(cube)*FACTORIAL4;
430 c = cube.eposm % FACTORIAL4;
431
432 b *= FACTORIAL4 * BINOM12ON4;
433 c *= FACTORIAL4 * BINOM12ON4 * FACTORIAL4 * BINOM8ON4;
434
435 return a + b + c;
436}
437
438static uint64_t
439index_drud(Cube cube)
440{
441 uint64_t a, b, c;
442
443 a = cube.eofb;
444 b = cube.coud;
445 c = cube.epose / FACTORIAL4;
446
447 b *= POW2TO11;
448 c *= POW2TO11 * POW3TO7;
449
450 return a + b + c;
451}
452
453static uint64_t
454index_corners6eo(Cube cube)
455{
456 return (cube.coud*FACTORIAL8 + cube.cp)*POW2TO6 + (cube.eofb%POW2TO6);
457}
458
459static uint64_t
460index_tripleeo(Cube cube)
461{
462 uint64_t ee, es;
463
464 ee = cube.epose / FACTORIAL4;
465 es = epos_dependent(cube);
466
467 return (ee * BINOM8ON4 + es) * POW2TO11 + cube.eofb;
468}
469
470
471/* Movesets ******************************************************************/
472
473bool
474moveset_HTM(Move m)
475{
476 return m >= U && m <= B3;
477}
478
479bool
480moveset_URF(Move m)
481{
482 Move b = base_move(m);
483
484 return b == U || b == R || b == F;
485}
486

Generated with cgit - Back to sebastiano.tronto.net