aboutsummaryrefslogtreecommitdiff
path: root/old/2021-11-10-beforeremovingchecker/steps.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--old/2021-11-10-beforeremovingchecker/steps.c916
1 files changed, 0 insertions, 916 deletions
diff --git a/old/2021-11-10-beforeremovingchecker/steps.c b/old/2021-11-10-beforeremovingchecker/steps.c
deleted file mode 100644
index 7213766..0000000
--- a/old/2021-11-10-beforeremovingchecker/steps.c
+++ /dev/null
@@ -1,916 +0,0 @@
1#include "steps.h"
2
3/* Standard checkers (return lower bound) ************************************/
4
5static int estimate_eoany_HTM(CubeTarget ct);
6static int estimate_eofb_HTM(CubeTarget ct);
7static int estimate_coany_HTM(CubeTarget ct);
8static int estimate_coud_HTM(CubeTarget ct);
9static int estimate_coany_URF(CubeTarget ct);
10static int estimate_coud_URF(CubeTarget ct);
11static int estimate_corners_HTM(CubeTarget ct);
12static int estimate_cornershtr_HTM(CubeTarget ct);
13static int estimate_corners_URF(CubeTarget ct);
14static int estimate_cornershtr_URF(CubeTarget ct);
15static int estimate_drany_HTM(CubeTarget ct);
16static int estimate_drud_HTM(CubeTarget ct);
17static int estimate_drud_eofb(CubeTarget ct);
18static int estimate_dr_eofb(CubeTarget ct);
19static int estimate_drudfin_drud(CubeTarget ct);
20static int estimate_htr_drud(CubeTarget ct);
21static int estimate_htrfin_htr(CubeTarget ct);
22static int estimate_optimal_HTM(CubeTarget ct);
23
24/* Validators ****************************************************************/
25
26static bool always_valid(Alg *alg);
27static bool validate_singlecw_ending(Alg *alg);
28
29/* Pre-transformation detectors **********************************************/
30
31static Trans detect_pretrans_eofb(Cube cube);
32static Trans detect_pretrans_drud(Cube cube);
33
34/* Messages for when cube is not ready ***************************************/
35
36static char check_centers_msg[100] = "cube must be oriented (centers solved)";
37static char check_eo_msg[100] = "EO must be solved on given axis";
38static char check_dr_msg[100] = "DR must be solved on given axis";
39static char check_htr_msg[100] = "HTR must be solved";
40static char check_drany_msg[100] = "DR must be solved on at least one axis";
41
42/* Steps *********************************************************************/
43
44Step
45optimal_HTM = {
46 .shortname = "optimal",
47 .name = "Optimal solve (in HTM)",
48
49 .estimate = estimate_optimal_HTM,
50 .ready = check_centers,
51 .ready_msg = check_centers_msg,
52 .is_valid = always_valid,
53 .moveset = moveset_HTM,
54
55 .pre_trans = uf,
56};
57
58/* EO steps **************************/
59Step
60eoany_HTM = {
61 .shortname = "eo",
62 .name = "EO on any axis",
63
64 .estimate = estimate_eoany_HTM,
65 .ready = check_centers,
66 .ready_msg = check_centers_msg,
67 .is_valid = validate_singlecw_ending,
68 .moveset = moveset_HTM,
69
70 .pre_trans = uf,
71};
72
73Step
74eofb_HTM = {
75 .shortname = "eofb",
76 .name = "EO on F/B",
77
78 .estimate = estimate_eofb_HTM,
79 .ready = check_centers,
80 .ready_msg = check_centers_msg,
81 .is_valid = validate_singlecw_ending,
82 .moveset = moveset_HTM,
83
84 .pre_trans = uf,
85};
86
87Step
88eorl_HTM = {
89 .shortname = "eorl",
90 .name = "EO on R/L",
91
92 .estimate = estimate_eofb_HTM,
93 .ready = check_centers,
94 .ready_msg = check_centers_msg,
95 .is_valid = validate_singlecw_ending,
96 .moveset = moveset_HTM,
97
98 .pre_trans = ur,
99};
100
101Step
102eoud_HTM = {
103 .shortname = "eoud",
104 .name = "EO on U/D",
105
106 .estimate = estimate_eofb_HTM,
107 .ready = check_centers,
108 .ready_msg = check_centers_msg,
109 .is_valid = validate_singlecw_ending,
110 .moveset = moveset_HTM,
111
112 .pre_trans = fd,
113};
114
115/* CO steps **************************/
116Step
117coany_HTM = {
118 .shortname = "co",
119 .name = "CO on any axis",
120
121 .estimate = estimate_coany_HTM,
122 .ready = NULL,
123 .is_valid = validate_singlecw_ending,
124 .moveset = moveset_HTM,
125
126 .pre_trans = uf,
127};
128
129Step
130coud_HTM = {
131 .shortname = "coud",
132 .name = "CO on U/D",
133
134 .estimate = estimate_coud_HTM,
135 .ready = NULL,
136 .is_valid = validate_singlecw_ending,
137 .moveset = moveset_HTM,
138
139 .pre_trans = uf,
140};
141
142Step
143corl_HTM = {
144 .shortname = "corl",
145 .name = "CO on R/L",
146
147 .estimate = estimate_coud_HTM,
148 .ready = NULL,
149 .is_valid = validate_singlecw_ending,
150 .moveset = moveset_HTM,
151
152 .pre_trans = rf,
153};
154
155Step
156cofb_HTM = {
157 .shortname = "cofb",
158 .name = "CO on F/B",
159
160 .estimate = estimate_coud_HTM,
161 .ready = NULL,
162 .is_valid = validate_singlecw_ending,
163 .moveset = moveset_HTM,
164
165 .pre_trans = fd,
166};
167
168Step
169coany_URF = {
170 .shortname = "co-URF",
171 .name = "CO any axis (URF moveset)",
172
173 .estimate = estimate_coany_URF,
174 .ready = NULL,
175 .is_valid = validate_singlecw_ending,
176 .moveset = moveset_URF,
177
178 .pre_trans = uf,
179};
180
181Step
182coud_URF = {
183 .shortname = "coud-URF",
184 .name = "CO on U/D (URF moveset)",
185
186 .estimate = estimate_coud_URF,
187 .ready = NULL,
188 .is_valid = validate_singlecw_ending,
189 .moveset = moveset_URF,
190
191 .pre_trans = uf,
192};
193
194Step
195corl_URF = {
196 .shortname = "corl-URF",
197 .name = "CO on R/L (URF moveset)",
198
199 .estimate = estimate_coud_URF,
200 .ready = NULL,
201 .is_valid = validate_singlecw_ending,
202 .moveset = moveset_URF,
203
204 .pre_trans = rf,
205};
206
207Step
208cofb_URF = {
209 .shortname = "cofb-URF",
210 .name = "CO on F/B (URF moveset)",
211
212 .estimate = estimate_coud_URF,
213 .ready = NULL,
214 .is_valid = validate_singlecw_ending,
215 .moveset = moveset_URF,
216
217 .pre_trans = fd,
218};
219
220/* Misc corner steps *****************/
221Step
222cornershtr_HTM = {
223 .shortname = "chtr",
224 .name = "Solve corners to HTR state",
225
226 .estimate = estimate_cornershtr_HTM,
227 .ready = NULL,
228 .is_valid = validate_singlecw_ending,
229 .moveset = moveset_HTM,
230
231 .pre_trans = uf,
232};
233
234Step
235cornershtr_URF = {
236 .shortname = "chtr-URF",
237 .name = "Solve corners to HTR state (URF moveset)",
238
239 .estimate = estimate_cornershtr_URF,
240 .ready = NULL,
241 .is_valid = validate_singlecw_ending,
242 .moveset = moveset_URF,
243
244 .pre_trans = uf,
245};
246
247Step
248corners_HTM = {
249 .shortname = "corners",
250 .name = "Solve corners",
251
252 .estimate = estimate_corners_HTM,
253 .ready = NULL,
254 .is_valid = always_valid,
255 .moveset = moveset_HTM,
256
257 .pre_trans = uf,
258};
259
260Step
261corners_URF = {
262 .shortname = "corners-URF",
263 .name = "Solve corners (URF moveset)",
264
265 .estimate = estimate_corners_URF,
266 .ready = NULL,
267 .is_valid = always_valid,
268 .moveset = moveset_URF,
269
270 .pre_trans = uf,
271};
272
273/* DR steps **************************/
274Step
275drany_HTM = {
276 .shortname = "dr",
277 .name = "DR on any axis",
278
279 .estimate = estimate_drany_HTM,
280 .ready = check_centers,
281 .ready_msg = check_centers_msg,
282 .is_valid = validate_singlecw_ending,
283 .moveset = moveset_HTM,
284
285 .pre_trans = uf,
286};
287
288Step
289drud_HTM = {
290 .shortname = "drud",
291 .name = "DR on U/D",
292
293 .estimate = estimate_drud_HTM,
294 .ready = check_centers,
295 .ready_msg = check_centers_msg,
296 .is_valid = validate_singlecw_ending,
297 .moveset = moveset_HTM,
298
299 .pre_trans = uf,
300};
301
302Step
303drrl_HTM = {
304 .shortname = "drrl",
305 .name = "DR on R/L",
306
307 .estimate = estimate_drud_HTM,
308 .ready = check_centers,
309 .ready_msg = check_centers_msg,
310 .is_valid = validate_singlecw_ending,
311 .moveset = moveset_HTM,
312
313 .pre_trans = rf,
314};
315
316Step
317drfb_HTM = {
318 .shortname = "drfb",
319 .name = "DR on F/B",
320
321 .estimate = estimate_drud_HTM,
322 .ready = check_centers,
323 .ready_msg = check_centers_msg,
324 .is_valid = validate_singlecw_ending,
325 .moveset = moveset_HTM,
326
327 .pre_trans = fd,
328};
329
330/* DR from EO */
331Step
332dr_eo = {
333 .shortname = "dr-eo",
334 .name = "DR without breaking EO (automatically detected)",
335
336 .estimate = estimate_dr_eofb,
337 .ready = check_eofb,
338 .ready_msg = check_eo_msg,
339 .is_valid = validate_singlecw_ending,
340 .moveset = moveset_eofb,
341
342 .detect = detect_pretrans_eofb,
343};
344
345Step
346dr_eofb = {
347 .shortname = "dr-eofb",
348 .name = "DR on U/D or R/L without breaking EO on F/B",
349
350 .estimate = estimate_dr_eofb,
351 .ready = check_eofb,
352 .ready_msg = check_eo_msg,
353 .is_valid = validate_singlecw_ending,
354 .moveset = moveset_eofb,
355
356 .pre_trans = uf,
357};
358
359Step
360dr_eorl = {
361 .shortname = "dr-eorl",
362 .name = "DR on U/D or F/B without breaking EO on R/L",
363
364 .estimate = estimate_dr_eofb,
365 .ready = check_eofb,
366 .ready_msg = check_eo_msg,
367 .is_valid = validate_singlecw_ending,
368 .moveset = moveset_eofb,
369
370 .pre_trans = ur,
371};
372
373Step
374dr_eoud = {
375 .shortname = "dr-eoud",
376 .name = "DR on R/L or F/B without breaking EO on U/R",
377
378 .estimate = estimate_dr_eofb,
379 .ready = check_eofb,
380 .ready_msg = check_eo_msg,
381 .is_valid = validate_singlecw_ending,
382 .moveset = moveset_eofb,
383
384 .pre_trans = fd,
385};
386
387Step
388drud_eofb = {
389 .shortname = "drud-eofb",
390 .name = "DR on U/D without breaking EO on F/B",
391
392 .estimate = estimate_drud_eofb,
393 .ready = check_eofb,
394 .ready_msg = check_eo_msg,
395 .is_valid = validate_singlecw_ending,
396 .moveset = moveset_eofb,
397
398 .pre_trans = uf,
399};
400
401Step
402drrl_eofb = {
403 .shortname = "drrl-eofb",
404 .name = "DR on R/L without breaking EO on F/B",
405
406 .estimate = estimate_drud_eofb,
407 .ready = check_eofb,
408 .ready_msg = check_eo_msg,
409 .is_valid = validate_singlecw_ending,
410 .moveset = moveset_eofb,
411
412 .pre_trans = rf,
413};
414
415Step
416drud_eorl = {
417 .shortname = "drud-eorl",
418 .name = "DR on U/D without breaking EO on R/L",
419
420 .estimate = estimate_drud_eofb,
421 .ready = check_eofb,
422 .ready_msg = check_eo_msg,
423 .is_valid = validate_singlecw_ending,
424 .moveset = moveset_eofb,
425
426 .pre_trans = ur,
427};
428
429Step
430drfb_eorl = {
431 .shortname = "drfb-eorl",
432 .name = "DR on F/B without breaking EO on R/L",
433
434 .estimate = estimate_drud_eofb,
435 .ready = check_eofb,
436 .ready_msg = check_eo_msg,
437 .is_valid = validate_singlecw_ending,
438 .moveset = moveset_eofb,
439
440 .pre_trans = fr,
441};
442
443Step
444drfb_eoud = {
445 .shortname = "drfb-eoud",
446 .name = "DR on F/B without breaking EO on U/D",
447
448 .estimate = estimate_drud_eofb,
449 .ready = check_eofb,
450 .ready_msg = check_eo_msg,
451 .is_valid = validate_singlecw_ending,
452 .moveset = moveset_eofb,
453
454 .pre_trans = fd,
455};
456
457Step
458drrl_eoud = {
459 .shortname = "drrl-eoud",
460 .name = "DR on R/L without breaking EO on U/D",
461
462 .estimate = estimate_drud_eofb,
463 .ready = check_eofb,
464 .ready_msg = check_eo_msg,
465 .is_valid = validate_singlecw_ending,
466 .moveset = moveset_eofb,
467
468 .pre_trans = rd,
469};
470
471/* DR finish steps */
472Step
473dranyfin_DR = {
474 .shortname = "drfin",
475 .name = "DR finish on any axis without breaking DR",
476
477 .estimate = estimate_drudfin_drud,
478 .ready = check_drud,
479 .ready_msg = check_drany_msg,
480 .is_valid = always_valid,
481 .moveset = moveset_drud,
482
483 .detect = detect_pretrans_drud,
484};
485
486Step
487drudfin_drud = {
488 .shortname = "drudfin",
489 .name = "DR finish on U/D without breaking DR",
490
491 .estimate = estimate_drudfin_drud,
492 .ready = check_drud,
493 .ready_msg = check_dr_msg,
494 .is_valid = always_valid,
495 .moveset = moveset_drud,
496
497 .pre_trans = uf,
498};
499
500Step
501drrlfin_drrl = {
502 .shortname = "drrlfin",
503 .name = "DR finish on R/L without breaking DR",
504
505 .estimate = estimate_drudfin_drud,
506 .ready = check_drud,
507 .ready_msg = check_dr_msg,
508 .is_valid = always_valid,
509 .moveset = moveset_drud,
510
511 .pre_trans = rf,
512};
513
514Step
515drfbfin_drfb = {
516 .shortname = "drfbfin",
517 .name = "DR finish on F/B without breaking DR",
518
519 .estimate = estimate_drudfin_drud,
520 .ready = check_drud,
521 .ready_msg = check_dr_msg,
522 .is_valid = always_valid,
523 .moveset = moveset_drud,
524
525 .pre_trans = fd,
526};
527
528/* HTR from DR */
529Step
530htr_any = {
531 .shortname = "htr",
532 .name = "HTR from DR",
533
534 .estimate = estimate_htr_drud,
535 .ready = check_drud,
536 .ready_msg = check_drany_msg,
537 .is_valid = validate_singlecw_ending,
538 .moveset = moveset_drud,
539
540 .detect = detect_pretrans_drud,
541};
542
543Step
544htr_drud = {
545 .shortname = "htr-drud",
546 .name = "HTR from DR on U/D",
547
548 .estimate = estimate_htr_drud,
549 .ready = check_drud,
550 .ready_msg = check_dr_msg,
551 .is_valid = validate_singlecw_ending,
552 .moveset = moveset_drud,
553
554 .pre_trans = uf,
555};
556
557Step
558htr_drrl = {
559 .shortname = "htr-drrl",
560 .name = "HTR from DR on R/L",
561
562 .estimate = estimate_htr_drud,
563 .ready = check_drud,
564 .ready_msg = check_dr_msg,
565 .is_valid = validate_singlecw_ending,
566 .moveset = moveset_drud,
567
568 .pre_trans = rf,
569};
570
571Step
572htr_drfb = {
573 .shortname = "htr-drfb",
574 .name = "HTR from DR on F/B",
575
576 .estimate = estimate_htr_drud,
577 .ready = check_drud,
578 .ready_msg = check_dr_msg,
579 .is_valid = validate_singlecw_ending,
580 .moveset = moveset_drud,
581
582 .pre_trans = fd,
583};
584
585/* HTR finish */
586Step
587htrfin_htr = {
588 .shortname = "htrfin",
589 .name = "HTR finish without breaking HTR",
590
591 .estimate = estimate_htrfin_htr,
592 .ready = check_htr,
593 .ready_msg = check_htr_msg,
594 .is_valid = always_valid,
595 .moveset = moveset_htr,
596
597 .pre_trans = uf,
598};
599
600Step *steps[NSTEPS] = {
601 &optimal_HTM, /* first is default */
602
603 &eoany_HTM,
604 &eofb_HTM,
605 &eorl_HTM,
606 &eoud_HTM,
607
608 &coany_HTM,
609 &coud_HTM,
610 &corl_HTM,
611 &cofb_HTM,
612
613 &coany_URF,
614 &coud_URF,
615 &corl_URF,
616 &cofb_URF,
617
618 &drany_HTM,
619 &drud_HTM,
620 &drrl_HTM,
621 &drfb_HTM,
622
623 &dr_eo,
624 &dr_eofb,
625 &dr_eorl,
626 &dr_eoud,
627 &drud_eofb,
628 &drrl_eofb,
629 &drud_eorl,
630 &drfb_eorl,
631 &drfb_eoud,
632 &drrl_eoud,
633
634 &dranyfin_DR,
635 &drudfin_drud,
636 &drrlfin_drrl,
637 &drfbfin_drfb,
638
639 &htr_any,
640 &htr_drud,
641 &htr_drrl,
642 &htr_drfb,
643
644 &htrfin_htr,
645
646 &cornershtr_HTM,
647 &cornershtr_URF,
648 &corners_HTM,
649 &corners_URF,
650};
651
652/* Standard checkers (return lower bound) ************************************/
653
654static int
655estimate_eoany_HTM(CubeTarget ct)
656{
657 int r1, r2, r3;
658
659 r1 = ptableval(&pd_eofb_HTM, ct.cube);
660 r2 = ptableval(&pd_eofb_HTM, apply_trans(ur, ct.cube));
661 r3 = ptableval(&pd_eofb_HTM, apply_trans(fd, ct.cube));
662
663 return MIN(r1, MIN(r2, r3));
664}
665
666static int
667estimate_eofb_HTM(CubeTarget ct)
668{
669 return ptableval(&pd_eofb_HTM, ct.cube);
670}
671
672static int
673estimate_coany_HTM(CubeTarget ct)
674{
675 int r1, r2, r3;
676
677 r1 = ptableval(&pd_coud_HTM, ct.cube);
678 r2 = ptableval(&pd_coud_HTM, apply_trans(rf, ct.cube));
679 r3 = ptableval(&pd_coud_HTM, apply_trans(fd, ct.cube));
680
681 return MIN(r1, MIN(r2, r3));
682}
683
684static int
685estimate_coud_HTM(CubeTarget ct)
686{
687 return ptableval(&pd_coud_HTM, ct.cube);
688}
689
690static int
691estimate_coany_URF(CubeTarget ct)
692{
693 int r1, r2, r3;
694 CubeTarget ct2, ct3;
695
696 ct2.cube = apply_trans(rf, ct.cube);
697 ct2.target = ct.target;
698
699 ct3.cube = apply_trans(fd, ct.cube);
700 ct3.target = ct.target;
701
702 r1 = estimate_coud_URF(ct);
703 r2 = estimate_coud_URF(ct2);
704 r3 = estimate_coud_URF(ct3);
705
706 return MIN(r1, MIN(r2, r3));
707}
708
709static int
710estimate_coud_URF(CubeTarget ct)
711{
712 /* TODO: I can improve this by checking first the orientation of
713 * the corner in DBL and use that as a reference */
714
715 CubeTarget ct2 = {.cube = apply_move(z, ct.cube), .target = ct.target};
716 CubeTarget ct3 = {.cube = apply_move(x, ct.cube), .target = ct.target};
717
718 int ud = estimate_coud_HTM(ct);
719 int rl = estimate_coud_HTM(ct2);
720 int fb = estimate_coud_HTM(ct3);
721
722 return MIN(ud, MIN(rl, fb));
723}
724
725static int
726estimate_corners_HTM(CubeTarget ct)
727{
728 return ptableval(&pd_corners_HTM, ct.cube);
729}
730
731static int
732estimate_cornershtr_HTM(CubeTarget ct)
733{
734 return ptableval(&pd_cornershtr_HTM, ct.cube);
735}
736
737static int
738estimate_cornershtr_URF(CubeTarget ct)
739{
740 /* TODO: I can improve this by checking first the corner in DBL
741 * and use that as a reference */
742
743 int c, ret = 15;
744 Trans i;
745
746 for (i = 0; i < NROTATIONS; i++) {
747 ct.cube = apply_alg(rotation_alg(i), ct.cube);
748 c = estimate_cornershtr_HTM(ct);
749 ret = MIN(ret, c);
750 }
751
752 return ret;
753}
754
755static int
756estimate_corners_URF(CubeTarget ct)
757{
758 /* TODO: I can improve this by checking first the corner in DBL
759 * and use that as a reference */
760
761 int c, ret = 15;
762 Trans i;
763
764 for (i = 0; i < NROTATIONS; i++) {
765 ct.cube = apply_alg(rotation_alg(i), ct.cube);
766 c = estimate_corners_HTM(ct);
767 ret = MIN(ret, c);
768 }
769
770 return ret;
771}
772
773static int
774estimate_drany_HTM(CubeTarget ct)
775{
776 int r1, r2, r3;
777
778 r1 = ptableval(&pd_drud_sym16_HTM, ct.cube);
779 r2 = ptableval(&pd_drud_sym16_HTM, apply_trans(rf, ct.cube));
780 r3 = ptableval(&pd_drud_sym16_HTM, apply_trans(fd, ct.cube));
781
782 return MIN(r1, MIN(r2, r3));
783}
784
785static int
786estimate_drud_HTM(CubeTarget ct)
787{
788 return ptableval(&pd_drud_sym16_HTM, ct.cube);
789}
790
791static int
792estimate_drud_eofb(CubeTarget ct)
793{
794 return ptableval(&pd_drud_eofb, ct.cube);
795}
796
797static int
798estimate_dr_eofb(CubeTarget ct)
799{
800 int r1, r2;
801
802 r1 = ptableval(&pd_drud_eofb, ct.cube);
803 r2 = ptableval(&pd_drud_eofb, apply_trans(rf, ct.cube));
804
805 return MIN(r1, r2);
806}
807
808static int
809estimate_drudfin_drud(CubeTarget ct)
810{
811 int val = ptableval(&pd_drudfin_noE_sym16_drud, ct.cube);
812
813 if (val != 0)
814 return val;
815
816 return ct.cube.epose % 24 == 0 ? 0 : 1;
817}
818
819static int
820estimate_htr_drud(CubeTarget ct)
821{
822 return ptableval(&pd_htr_drud, ct.cube);
823}
824
825static int
826estimate_htrfin_htr(CubeTarget ct)
827{
828 return ptableval(&pd_htrfin_htr, ct.cube);
829}
830
831static int
832estimate_optimal_HTM(CubeTarget ct)
833{
834 int dr1, dr2, dr3, cor, ret;
835 Cube cube = ct.cube;
836
837 dr1 = ptableval(&pd_khuge_HTM, cube);
838 cor = estimate_corners_HTM(ct);
839 ret = MAX(dr1, cor);
840
841 if (ret > ct.target)
842 return ret;
843
844 cube = apply_trans(rf, ct.cube);
845 dr2 = ptableval(&pd_khuge_HTM, cube);
846 ret = MAX(ret, dr2);
847
848 if (ret > ct.target)
849 return ret;
850
851 cube = apply_trans(fd, ct.cube);
852 dr3 = ptableval(&pd_khuge_HTM, cube);
853
854 /* Michiel de Bondt's trick */
855 if (dr1 == dr2 && dr2 == dr3 && dr1 != 0)
856 dr3++;
857
858 return MAX(ret, dr3);
859}
860
861/* Validators ****************************************************************/
862
863static bool
864always_valid(Alg *alg)
865{
866 return true;
867}
868
869static bool
870validate_singlecw_ending(Alg *alg)
871{
872 int i;
873 bool nor, inv;
874 Move l2 = NULLMOVE, l1 = NULLMOVE, l2i = NULLMOVE, l1i = NULLMOVE;
875
876 for (i = 0; i < alg->len; i++) {
877 if (alg->inv[i]) {
878 l2i = l1i;
879 l1i = alg->move[i];
880 } else {
881 l2 = l1;
882 l1 = alg->move[i];
883 }
884 }
885
886 nor = l1 ==base_move(l1) && (!commute(l1, l2) ||l2 ==base_move(l2));
887 inv = l1i==base_move(l1i) && (!commute(l1i,l2i)||l2i==base_move(l2i));
888
889 return nor && inv;
890}
891
892/* Pre-transformation detectors **********************************************/
893
894static Trans
895detect_pretrans_eofb(Cube cube)
896{
897 Trans i;
898
899 for (i = 0; i < NROTATIONS; i++)
900 if (check_eofb(apply_trans(i, cube)))
901 return i;
902
903 return 0;
904}
905
906static Trans
907detect_pretrans_drud(Cube cube)
908{
909 Trans i;
910
911 for (i = 0; i < NROTATIONS; i++)
912 if (check_drud(apply_trans(i, cube)))
913 return i;
914
915 return 0;
916}

Generated with cgit - Back to sebastiano.tronto.net