73 #include "../common/mesh_extras.hpp" 84 static int nstep_ = 6;
85 static int count_ = 0;
86 static int logging_ = 0;
88 static double cosa_ = cos(0.5 * M_PI / nstep_);
89 static double sina_ = sin(0.5 * M_PI / nstep_);
112 static RubikState rubik;
114 static int edge_colors_[24] =
121 static int corn_colors_[24] =
123 4,1,0, 2,1,0, 2,3,0, 4,3,0,
124 4,1,5, 2,1,5, 2,3,5, 4,3,5
150 void anim_move(
char axis,
int tier,
int increment,
158 anim_move(move.axis, move.tier, move.incr, mesh, color, sock);
164 int * c0 = NULL,
int * c1 = NULL);
167 bool cw,
int * c0 = NULL,
int * c1 = NULL,
int * c2 = NULL);
170 int * e0,
int * e1,
int * e2);
176 int n,
int * e0 = NULL,
int * e1 = NULL,
177 int * e2 = NULL,
int * e3 = NULL);
187 int main(
int argc,
char *argv[])
190 bool visualization =
true;
193 args.
AddOption(&anim,
"-anim",
"--animation",
"-no-anim",
195 "Enable or disable GLVis animation.");
196 args.
AddOption(&logging_,
"-l",
"--log-level",
197 "Control the amount of logging information.");
198 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
199 "--no-visualization",
200 "Enable or disable GLVis visualization.");
211 if (!visualization) { anim =
false; }
216 Mesh mesh(3, 16 * 27, 27 * 6);
226 for (
int i=1; i<=7; i++) { pwCoef(i) = (double)(i-1)/6.0; }
232 oss <<
"rubik-init.mesh";
233 ofstream ofs(oss.str().c_str());
246 sock <<
"solution\n" << mesh << color <<
"keys Amaa\n" 247 <<
"palette 25\n" <<
"autoscale off\n" << flush;
253 cout <<
"Enter axis (x, y, z), tier index (1, 2, 3), " 254 <<
"and rotation (0, 1, 2, 3) with no spaces: ";
256 if ( axis ==
'x' || axis ==
'y' || axis ==
'z' )
261 if (tier >= 1 && tier <= 3)
263 anim_move(axis, tier, incr, mesh, color, sock);
267 cout <<
"tier index must be 1, 2, or 3." << endl;
270 else if ( axis ==
'r' )
278 for (
int i=0; i<num; i++)
283 else if ( axis ==
'p' )
287 else if ( axis ==
'c' )
291 else if ( axis ==
't' )
297 else if ( axis ==
'e' )
303 else if ( axis ==
'f' )
307 if (n == 2 || n == 4)
313 cout <<
"Can only flip 2 or 4 edges at a time." << endl;
316 else if ( axis ==
'R' )
320 else if ( axis ==
'T' )
324 else if ( axis ==
'M' )
328 else if ( axis ==
'B' )
332 else if ( axis ==
's' || axis ==
'S')
334 solve(mesh, color, sock);
336 else if ( axis ==
'h' || axis ==
'H')
340 else if ( axis ==
'q' || axis ==
'Q')
346 cout << endl <<
"Unrecognized command. " 347 "Enter 'x', 'y', 'z' followed by '1', '2', or '3' to proceed " 348 "or enter 'q' to quit: ";
362 cout <<
"\nInteractive Commands\n" 363 <<
" [xyz][1,2,3][0-3]\n" 364 <<
"\tRotate the specified tier (first integer) of the cube\n" 365 <<
"\tabout the given axis (initial character) in the clockwise\n" 366 <<
"\tdirection (looking from the tip of the axis vector towards\n" 367 <<
"\tthe origin) by so many increments (final integer).\n" 369 <<
"\tInitiate a random sequence of moves. The integer\n" 370 <<
"\tfollowing 'r' is the number of desired moves.\n" 372 <<
"\tPrint the current state of the cube.\n" 374 <<
"\tSwap the corners in the 0th and 1st positions.\n" 376 <<
"\tTwist the corners of the bottom tier in the clockwise '1'\n" 377 <<
"\tor counter-clockwise '0' direction leaving the 3rd corner\n" 380 <<
"\tPermute the edges of the bottom tier in the clockwise '1'\n" 381 <<
"\tor counter-clockwise '0' direction leaving the 3rd edge\n" 384 <<
"\tFlip the edges of the bottom tier while keeping them in\n" 385 <<
"\tplace. The integer '2' indicates flipping the 0th and 2nd\n" 386 <<
"\tedges while '4' indicates flipping all four edges.\n" 388 <<
"\tResets (or Repaints) the cube to its original configuration.\n" 390 <<
"\tSolve the top tier only.\n" 392 <<
"\tSolve the middle tier only (assumes the top tier has already\n" 393 <<
"\tbeen solved.)\n" 395 <<
"\tSolve the bottom tier only (assumes the top two tiers have\n" 396 <<
"\talready been solved.)\n" 398 <<
"\tSolve the cube starting from the top tier and working down.\n" 400 <<
"\tPrint this message.\n" 413 for (
int k=0; k<3; k++)
415 for (
int j=0; j<3; j++)
417 for (
int i=0; i<3; i++)
467 c[0] = -1.5 + i + 0.25;
468 c[1] = -1.5 + j + 0.25;
469 c[2] = -1.5 + k + 0.25;
473 c[0] = -1.5 + i + 0.75;
474 c[1] = -1.5 + j + 0.25;
475 c[2] = -1.5 + k + 0.25;
479 c[0] = -1.5 + i + 0.75;
480 c[1] = -1.5 + j + 0.75;
481 c[2] = -1.5 + k + 0.25;
485 c[0] = -1.5 + i + 0.25;
486 c[1] = -1.5 + j + 0.75;
487 c[2] = -1.5 + k + 0.25;
491 c[0] = -1.5 + i + 0.25;
492 c[1] = -1.5 + j + 0.25;
493 c[2] = -1.5 + k + 0.75;
497 c[0] = -1.5 + i + 0.75;
498 c[1] = -1.5 + j + 0.25;
499 c[2] = -1.5 + k + 0.75;
503 c[0] = -1.5 + i + 0.75;
504 c[1] = -1.5 + j + 0.75;
505 c[2] = -1.5 + k + 0.75;
509 c[0] = -1.5 + i + 0.25;
510 c[1] = -1.5 + j + 0.75;
511 c[2] = -1.5 + k + 0.75;
516 vh[0] = v[ 0]; vh[1] = v[ 1]; vh[2] = v[ 2]; vh[3] = v[ 3];
517 vh[4] = v[ 8]; vh[5] = v[ 9]; vh[6] = v[10]; vh[7] = v[11];
518 mesh.
AddHex(vh, k==0 ? 6 : 1);
521 vh[0] = v[12]; vh[1] = v[13]; vh[2] = v[14]; vh[3] = v[15];
522 vh[4] = v[ 4]; vh[5] = v[ 5]; vh[6] = v[ 6]; vh[7] = v[ 7];
523 mesh.
AddHex(vh, k==2 ? 7 : 1);
526 vh[0] = v[ 0]; vh[1] = v[ 4]; vh[2] = v[ 5]; vh[3] = v[ 1];
527 vh[4] = v[ 8]; vh[5] = v[12]; vh[6] = v[13]; vh[7] = v[ 9];
528 mesh.
AddHex(vh, j==0 ? 4 : 1);
531 vh[0] = v[11]; vh[1] = v[15]; vh[2] = v[14]; vh[3] = v[10];
532 vh[4] = v[ 3]; vh[5] = v[ 7]; vh[6] = v[ 6]; vh[7] = v[ 2];
533 mesh.
AddHex(vh, j==2 ? 5 : 1);
536 vh[0] = v[ 0]; vh[1] = v[ 3]; vh[2] = v[ 7]; vh[3] = v[ 4];
537 vh[4] = v[ 8]; vh[5] = v[11]; vh[6] = v[15]; vh[7] = v[12];
538 mesh.
AddHex(vh, i==0 ? 3 : 1);
541 vh[0] = v[ 9]; vh[1] = v[10]; vh[2] = v[14]; vh[3] = v[13];
542 vh[4] = v[ 1]; vh[5] = v[ 2]; vh[6] = v[ 6]; vh[7] = v[ 5];
543 mesh.
AddHex(vh, i==2 ? 2 : 1);
554 for (
int i=0; i<6; i++) { rubik.cent_[i] = i; }
555 for (
int i=0; i<24; i++) { rubik.edge_[i] = edge_colors_[i]; }
556 for (
int i=0; i<24; i++) { rubik.corn_[i] = corn_colors_[i]; }
562 int i = (axis ==
'x') ? 0 : ((axis ==
'y') ? 1 : 2);
563 int i0 = 0 + i * (i - 1) / 2;
564 int i1 = 1 + i * (i + 1) / 2;
565 int i3 = 3 - i * (3 * i - 5) / 2;
566 int i5 = 5 - i * (i - 1);
571 std::swap(rubik.cent_[i3], rubik.cent_[i0]);
572 std::swap(rubik.cent_[i5], rubik.cent_[i3]);
573 std::swap(rubik.cent_[i1], rubik.cent_[i5]);
576 std::swap(rubik.cent_[i0], rubik.cent_[i5]);
577 std::swap(rubik.cent_[i1], rubik.cent_[i3]);
580 std::swap(rubik.cent_[i1], rubik.cent_[i0]);
581 std::swap(rubik.cent_[i5], rubik.cent_[i1]);
582 std::swap(rubik.cent_[i3], rubik.cent_[i5]);
590 if (tier == 2) {
return; }
592 int i = (axis ==
'x') ? 0 : ((axis ==
'y') ? 1 : 2);
601 int i09 = 9 - i * ( 6 * i - 10);
602 int i21 = 21 - i * ( 3 * i + 7) / 2;
603 int i12 = 12 + i * (15 * i - 31) / 2;
605 int i01 = 1 - i * ( 3 * i - 5) / 2;
606 int i10 = 10 - i * (15 * i - 23) / 2;
607 int i22 = 22 - i * ( 3 * i + 2);
608 int i13 = 13 + i * ( 6 * i - 14);
610 int i02 = 2 + i * ( 3 * i - 7) / 2;
611 int i11 = 11 - i * ( 9 * i - 11) / 2;
612 int i23 = 23 - 8 * i;
613 int i14 = 14 + i * ( 9 * i - 20);
619 std::swap(rubik.corn_[i09], rubik.corn_[i00]);
620 std::swap(rubik.corn_[i21], rubik.corn_[i09]);
621 std::swap(rubik.corn_[i12], rubik.corn_[i21]);
624 std::swap(rubik.corn_[i11], rubik.corn_[i01]);
625 std::swap(rubik.corn_[i22], rubik.corn_[i11]);
626 std::swap(rubik.corn_[i14], rubik.corn_[i22]);
629 std::swap(rubik.corn_[i10], rubik.corn_[i02]);
630 std::swap(rubik.corn_[i23], rubik.corn_[i10]);
631 std::swap(rubik.corn_[i13], rubik.corn_[i23]);
635 std::swap(rubik.corn_[i00], rubik.corn_[i21]);
636 std::swap(rubik.corn_[i09], rubik.corn_[i12]);
637 std::swap(rubik.corn_[i01], rubik.corn_[i22]);
638 std::swap(rubik.corn_[i11], rubik.corn_[i14]);
639 std::swap(rubik.corn_[i02], rubik.corn_[i23]);
640 std::swap(rubik.corn_[i10], rubik.corn_[i13]);
644 std::swap(rubik.corn_[i12], rubik.corn_[i00]);
645 std::swap(rubik.corn_[i21], rubik.corn_[i12]);
646 std::swap(rubik.corn_[i09], rubik.corn_[i21]);
649 std::swap(rubik.corn_[i14], rubik.corn_[i01]);
650 std::swap(rubik.corn_[i22], rubik.corn_[i14]);
651 std::swap(rubik.corn_[i11], rubik.corn_[i22]);
654 std::swap(rubik.corn_[i13], rubik.corn_[i02]);
655 std::swap(rubik.corn_[i23], rubik.corn_[i13]);
656 std::swap(rubik.corn_[i10], rubik.corn_[i23]);
666 int i03 = 3 - i * ( 3 * i - 17) / 2;
667 int i06 = 6 - i * (21 * i - 53) / 2;
669 int i15 = 15 + i * (12 * i - 20);
671 int i04 = 4 - i * ( 3 * i - 10);
672 int i07 = 7 - i * (12 * i - 28);
673 int i19 = 19 - i * ( 3 * i - 5) / 2;
674 int i16 = 16 + i * (21 * i - 37) / 2;
677 int i08 = 8 - i * ( 9 * i - 22);
678 int i20 = 20 + i * ( 3 * i - 7) / 2;
679 int i17 = 17 + i * (27 * i - 49) / 2;
685 std::swap(rubik.corn_[i06], rubik.corn_[i03]);
686 std::swap(rubik.corn_[i18], rubik.corn_[i06]);
687 std::swap(rubik.corn_[i15], rubik.corn_[i18]);
690 std::swap(rubik.corn_[i08], rubik.corn_[i04]);
691 std::swap(rubik.corn_[i19], rubik.corn_[i08]);
692 std::swap(rubik.corn_[i17], rubik.corn_[i19]);
695 std::swap(rubik.corn_[i07], rubik.corn_[i05]);
696 std::swap(rubik.corn_[i20], rubik.corn_[i07]);
697 std::swap(rubik.corn_[i16], rubik.corn_[i20]);
701 std::swap(rubik.corn_[i03], rubik.corn_[i18]);
702 std::swap(rubik.corn_[i15], rubik.corn_[i06]);
703 std::swap(rubik.corn_[i04], rubik.corn_[i19]);
704 std::swap(rubik.corn_[i17], rubik.corn_[i08]);
705 std::swap(rubik.corn_[i05], rubik.corn_[i20]);
706 std::swap(rubik.corn_[i16], rubik.corn_[i07]);
710 std::swap(rubik.corn_[i15], rubik.corn_[i03]);
711 std::swap(rubik.corn_[i18], rubik.corn_[i15]);
712 std::swap(rubik.corn_[i06], rubik.corn_[i18]);
715 std::swap(rubik.corn_[i17], rubik.corn_[i04]);
716 std::swap(rubik.corn_[i19], rubik.corn_[i17]);
717 std::swap(rubik.corn_[i08], rubik.corn_[i19]);
720 std::swap(rubik.corn_[i16], rubik.corn_[i05]);
721 std::swap(rubik.corn_[i20], rubik.corn_[i16]);
722 std::swap(rubik.corn_[i07], rubik.corn_[i20]);
731 int i = (axis ==
'x') ? 0 : ((axis ==
'y') ? 1 : 2);
735 int i06 = 6 - i * (13 * i - 23);
736 int i14 = 14 - i * ( 9 * i - 13);
737 int i16 = 16 + i * (11 * i - 27);
738 int i22 = 22 + i * ( 4 * i - 18);
744 std::swap(rubik.edge_[i22], rubik.edge_[i06]);
745 std::swap(rubik.edge_[i14+1], rubik.edge_[i22]);
746 std::swap(rubik.edge_[i16+1], rubik.edge_[i14+1]);
748 std::swap(rubik.edge_[i22+1], rubik.edge_[i06+1]);
749 std::swap(rubik.edge_[i14], rubik.edge_[i22+1]);
750 std::swap(rubik.edge_[i16], rubik.edge_[i14]);
754 std::swap(rubik.edge_[i06], rubik.edge_[i14+1]);
755 std::swap(rubik.edge_[i06+1], rubik.edge_[i14]);
756 std::swap(rubik.edge_[i16], rubik.edge_[i22+1]);
757 std::swap(rubik.edge_[i16+1], rubik.edge_[i22]);
761 std::swap(rubik.edge_[i16+1], rubik.edge_[i06]);
762 std::swap(rubik.edge_[i14+1], rubik.edge_[i16+1]);
763 std::swap(rubik.edge_[i22], rubik.edge_[i14+1]);
765 std::swap(rubik.edge_[i16], rubik.edge_[i06+1]);
766 std::swap(rubik.edge_[i14], rubik.edge_[i16]);
767 std::swap(rubik.edge_[i22+1], rubik.edge_[i14]);
776 int i00 = 0 + i * ( 2 * i + 4);
777 int i04 = 4 - i * ( 3 * i - 13);
778 int i08 = 8 + i * (13 * i - 19);
779 int i12 = 12 + i * ( 6 * i - 8);
785 std::swap(rubik.edge_[i04], rubik.edge_[i00]);
786 std::swap(rubik.edge_[i12], rubik.edge_[i04]);
787 std::swap(rubik.edge_[i08], rubik.edge_[i12]);
789 std::swap(rubik.edge_[i04+1], rubik.edge_[i00+1]);
790 std::swap(rubik.edge_[i12+1], rubik.edge_[i04+1]);
791 std::swap(rubik.edge_[i08+1], rubik.edge_[i12+1]);
795 std::swap(rubik.edge_[i00], rubik.edge_[i12]);
796 std::swap(rubik.edge_[i00+1], rubik.edge_[i12+1]);
797 std::swap(rubik.edge_[i04], rubik.edge_[i08]);
798 std::swap(rubik.edge_[i04+1], rubik.edge_[i08+1]);
802 std::swap(rubik.edge_[i08], rubik.edge_[i00]);
803 std::swap(rubik.edge_[i12], rubik.edge_[i08]);
804 std::swap(rubik.edge_[i04], rubik.edge_[i12]);
806 std::swap(rubik.edge_[i08+1], rubik.edge_[i00+1]);
807 std::swap(rubik.edge_[i12+1], rubik.edge_[i08+1]);
808 std::swap(rubik.edge_[i04+1], rubik.edge_[i12+1]);
817 int i02 = 2 - i * (17 * i - 37);
818 int i10 = 10 - i * ( 9 * i - 19);
819 int i18 = 18 + i * (12 * i - 26);
820 int i20 = 20 + i * ( 3 * i - 11);
826 std::swap(rubik.edge_[i20], rubik.edge_[i02]);
827 std::swap(rubik.edge_[i10+1], rubik.edge_[i20]);
828 std::swap(rubik.edge_[i18+1], rubik.edge_[i10+1]);
830 std::swap(rubik.edge_[i20+1], rubik.edge_[i02+1]);
831 std::swap(rubik.edge_[i10], rubik.edge_[i20+1]);
832 std::swap(rubik.edge_[i18], rubik.edge_[i10]);
836 std::swap(rubik.edge_[i02], rubik.edge_[i10+1]);
837 std::swap(rubik.edge_[i02+1], rubik.edge_[i10]);
838 std::swap(rubik.edge_[i18], rubik.edge_[i20+1]);
839 std::swap(rubik.edge_[i18+1], rubik.edge_[i20]);
843 std::swap(rubik.edge_[i18+1], rubik.edge_[i02]);
844 std::swap(rubik.edge_[i10+1], rubik.edge_[i18+1]);
845 std::swap(rubik.edge_[i20], rubik.edge_[i10+1]);
847 std::swap(rubik.edge_[i18], rubik.edge_[i02+1]);
848 std::swap(rubik.edge_[i10], rubik.edge_[i18]);
849 std::swap(rubik.edge_[i20+1], rubik.edge_[i10]);
858 if (incr == 0) {
return; }
878 out_stream <<
"Rubik's Cube State:\n";
879 out_stream <<
" Centers: ";
880 for (
int i=0; i<6; i++)
882 out_stream <<
" " << rubik.cent_[i];
885 out_stream <<
" Edges: ";
886 for (
int i=0; i<12; i++)
888 out_stream <<
" " << rubik.edge_[2 * i + 0]
889 <<
":" << rubik.edge_[2 * i + 1];
892 out_stream <<
" Corners: ";
893 for (
int i=0; i<8; i++)
895 out_stream <<
" " << rubik.corn_[3 * i + 0]
896 <<
":" << rubik.corn_[3 * i + 1]
897 <<
":" << rubik.corn_[3 * i + 2];
910 for (
int i=0; i<mesh.
GetNBE(); i++)
915 for (
int j=0; j<v.
Size(); j++)
927 if (x[0] > 1.5 - eps)
929 color[elem] = 1.0 / 6.0;
931 else if (x[0] < -1.5 + eps)
933 color[elem] = 2.0 / 6.0;
935 else if (x[1] < -1.5 + eps)
937 color[elem] = 3.0 / 6.0;
939 else if (x[1] > 1.5 - eps)
941 color[elem] = 4.0 / 6.0;
943 else if (x[2] < -1.5 + eps)
945 color[elem] = 5.0 / 6.0;
947 else if (x[2] > 1.5 - eps)
952 sock <<
"solution\n" << mesh << color << flush;
959 MFEM_ASSERT(0 <= min_ind && max_ind <= 6,
"Maximum center index of " 960 << max_ind <<
" is out of range.");
962 for (
int i=min_ind; i<max_ind; i++)
964 if (rubik.cent_[i] != i) {
return false; }
971 MFEM_ASSERT(0 <= min_ind && max_ind <= 12,
"Maximum edge index of " 972 << max_ind <<
" is out of range.");
974 for (
int i=min_ind; i<max_ind; i++)
976 if (rubik.edge_[2 * i + 0] != edge_colors_[2 * i + 0] ||
977 rubik.edge_[2 * i + 1] != edge_colors_[2 * i + 1])
987 MFEM_ASSERT(0 <= min_ind && max_ind <= 8,
"Maximum corner index of " 988 << max_ind <<
" is out of range.");
990 for (
int i=min_ind; i<max_ind; i++)
992 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0] ||
993 rubik.corn_[3 * i + 1] != corn_colors_[3 * i + 1] ||
994 rubik.corn_[3 * i + 2] != corn_colors_[3 * i + 2])
1005 if (incr == 0) {
return; }
1020 xVec[1] = cosa_ * yVec[1] + sina_ * yVec[2];
1021 xVec[2] = -sina_ * yVec[1] + cosa_ * yVec[2];
1024 xVec[1] = cosa_ * yVec[1] + sina_ * yVec[2];
1025 xVec[2] = -sina_ * yVec[1] + cosa_ * yVec[2];
1028 xVec[1] = cosa_ * yVec[1] - sina_ * yVec[2];
1029 xVec[2] = sina_ * yVec[1] + cosa_ * yVec[2];
1039 xVec[2] = cosa_ * yVec[2] + sina_ * yVec[0];
1040 xVec[0] = -sina_ * yVec[2] + cosa_ * yVec[0];
1043 xVec[2] = cosa_ * yVec[2] + sina_ * yVec[0];
1044 xVec[0] = -sina_ * yVec[2] + cosa_ * yVec[0];
1047 xVec[2] = cosa_ * yVec[2] - sina_ * yVec[0];
1048 xVec[0] = sina_ * yVec[2] + cosa_ * yVec[0];
1058 xVec[0] = cosa_ * yVec[0] + sina_ * yVec[1];
1059 xVec[1] = -sina_ * yVec[0] + cosa_ * yVec[1];
1062 xVec[0] = cosa_ * yVec[0] + sina_ * yVec[1];
1063 xVec[1] = -sina_ * yVec[0] + cosa_ * yVec[1];
1066 xVec[0] = cosa_ * yVec[0] - sina_ * yVec[1];
1067 xVec[1] = sina_ * yVec[0] + cosa_ * yVec[1];
1078 if (incr == 0) { step_ = 0;
return false; }
1079 if (incr != 2 && step_ == nstep_) { step_ = 0;
return false; }
1080 if (incr == 2 && step_ == 2 * nstep_) { step_ = 0;
return false; }
1082 std::set<int> verts;
1084 for (
int i=0; i<mesh.
GetNE(); i++)
1090 for (
int j=0; j<v.
Size(); j++)
1095 for (std::set<int>::iterator sit = verts.begin(); sit!=verts.end(); sit++)
1112 for (
int i=0; i<mesh.
GetNE(); i++)
1117 for (
int j=0; j<v.
Size(); j++)
1127 if ( x[0] > -2.5 + tier && x[0] < -1.5 + tier )
1138 if ( x[1] > -2.5 + tier && x[1] < -1.5 + tier )
1149 if ( x[2] > -2.5 + tier && x[2] < -1.5 + tier )
1171 sock <<
"solution\n" << mesh << color << flush;
1178 for (
int i=0; i<moves.
Size(); i++)
1180 double ran = double(rand()) / RAND_MAX;
1181 int ir = (int)(26 * ran);
1182 int incr = (ir % 3) + 1; ir /= 3;
1183 int tier = (ir % 3) + 1; ir /= 3;
1184 char axis = (ir == 0)?
'x' : ((ir == 1) ?
'y' :
'z');
1188 moves[i].axis = axis;
1189 moves[i].tier = tier;
1190 moves[i].incr = incr;
1192 else if (axis == moves[i-1].axis)
1194 if (tier == moves[i-1].tier)
1196 int new_incr = (moves[i-1].incr + incr) % 4;
1199 moves[i-1].incr = new_incr;
1203 else if (incr == moves[i-1].incr)
1205 moves[i-1].tier = 6 - moves[i-1].tier - tier;
1206 moves[i-1].incr = 4 - incr;
1212 moves[i].axis = axis;
1213 moves[i].tier = tier;
1214 moves[i].incr = incr;
1223 for (
int i=0; i<6; i++)
1225 if (rubik.cent_[i] == 5)
1234 anim_move(
'x', 2, 2, mesh, color, sock);
1237 anim_move(
'x', 2, 1, mesh, color, sock);
1240 anim_move(
'y', 2, 1, mesh, color, sock);
1243 anim_move(
'x', 2, 3, mesh, color, sock);
1246 anim_move(
'y', 2, 3, mesh, color, sock);
1259 bool allWrong =
true;
1260 bool allRight =
true;
1261 for (
int i=0; i<6; i++)
1263 if (rubik.cent_[i] == i)
1274 if (allRight) {
return; }
1282 if (rubik.cent_[2] == 2)
1286 switch (rubik.cent_[0])
1299 else if (rubik.cent_[1] == 1)
1303 switch (rubik.cent_[0])
1320 switch (rubik.cent_[1])
1333 anim_move(axis, 2, incr, mesh, color, sock);
1339 for (
int i=1; i<6; i++)
1341 if (rubik.cent_[i] == 0)
1353 axis =
'x'; incr = 3;
1356 axis =
'y'; incr = 3;
1359 axis =
'x'; incr = 1;
1362 axis =
'y'; incr = 1;
1365 axis =
'x'; incr = 2;
1368 anim_move(axis, 2, incr, mesh, color, sock);
1378 for (
int i=0; i<8; i++)
1380 if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 0] &&
1381 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 1] &&
1382 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 2])
1386 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 1] &&
1387 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 2] &&
1388 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 0])
1392 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 2] &&
1393 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 0] &&
1394 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 1])
1398 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 2] &&
1399 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 1] &&
1400 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 0])
1404 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 1] &&
1405 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 0] &&
1406 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 2])
1410 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 0] &&
1411 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 2] &&
1412 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 1])
1430 anim_move(
'x', 1, 3, mesh, color, sock);
1431 anim_move(
'z', 1, 3, mesh, color, sock);
1432 anim_move(
'x', 1, 1, mesh, color, sock);
1435 anim_move(
'y', 1, 1, mesh, color, sock);
1436 anim_move(
'z', 1, 3, mesh, color, sock);
1437 anim_move(
'y', 1, 3, mesh, color, sock);
1438 anim_move(
'x', 1, 3, mesh, color, sock);
1439 anim_move(
'z', 1, 2, mesh, color, sock);
1440 anim_move(
'x', 1, 1, mesh, color, sock);
1443 anim_move(
'y', 1, 1, mesh, color, sock);
1444 anim_move(
'z', 1, 1, mesh, color, sock);
1445 anim_move(
'y', 1, 3, mesh, color, sock);
1453 anim_move(
'x', 2, 1, mesh, color, sock);
1454 anim_move(
'y', 1, 2, mesh, color, sock);
1455 anim_move(
'x', 2, 3, mesh, color, sock);
1458 anim_move(
'z', 1, 1, mesh, color, sock);
1459 anim_move(
'x', 2, 1, mesh, color, sock);
1460 anim_move(
'y', 1, 3, mesh, color, sock);
1461 anim_move(
'x', 2, 3, mesh, color, sock);
1464 anim_move(
'x', 1, 3, mesh, color, sock);
1465 anim_move(
'z', 1, 1, mesh, color, sock);
1466 anim_move(
'x', 1, 1, mesh, color, sock);
1474 anim_move(
'y', 1, 1, mesh, color, sock);
1475 anim_move(
'z', 1, 2, mesh, color, sock);
1476 anim_move(
'y', 1, 3, mesh, color, sock);
1479 anim_move(
'x', 3, 1, mesh, color, sock);
1480 anim_move(
'z', 1, 1, mesh, color, sock);
1481 anim_move(
'x', 3, 3, mesh, color, sock);
1482 anim_move(
'x', 2, 1, mesh, color, sock);
1483 anim_move(
'y', 1, 3, mesh, color, sock);
1484 anim_move(
'x', 2, 3, mesh, color, sock);
1487 anim_move(
'x', 1, 3, mesh, color, sock);
1488 anim_move(
'z', 1, 2, mesh, color, sock);
1489 anim_move(
'x', 1, 1, mesh, color, sock);
1497 anim_move(
'y', 2, 3, mesh, color, sock);
1498 anim_move(
'x', 1, 2, mesh, color, sock);
1499 anim_move(
'y', 2, 1, mesh, color, sock);
1502 anim_move(
'y', 1, 1, mesh, color, sock);
1503 anim_move(
'z', 1, 3, mesh, color, sock);
1504 anim_move(
'y', 1, 3, mesh, color, sock);
1507 anim_move(
'z', 1, 3, mesh, color, sock);
1508 anim_move(
'y', 1, 1, mesh, color, sock);
1509 anim_move(
'z', 1, 1, mesh, color, sock);
1510 anim_move(
'y', 1, 3, mesh, color, sock);
1518 anim_move(
'y', 1, 1, mesh, color, sock);
1519 anim_move(
'z', 1, 1, mesh, color, sock);
1520 anim_move(
'y', 1, 3, mesh, color, sock);
1521 anim_move(
'z', 1, 3, mesh, color, sock);
1522 anim_move(
'y', 1, 1, mesh, color, sock);
1523 anim_move(
'z', 1, 1, mesh, color, sock);
1524 anim_move(
'y', 1, 3, mesh, color, sock);
1527 anim_move(
'x', 1, 3, mesh, color, sock);
1528 anim_move(
'z', 1, 3, mesh, color, sock);
1529 anim_move(
'x', 1, 1, mesh, color, sock);
1530 anim_move(
'z', 1, 1, mesh, color, sock);
1531 anim_move(
'x', 1, 3, mesh, color, sock);
1532 anim_move(
'z', 1, 3, mesh, color, sock);
1533 anim_move(
'x', 1, 1, mesh, color, sock);
1541 anim_move(
'x', 2, 1, mesh, color, sock);
1542 anim_move(
'y', 1, 1, mesh, color, sock);
1543 anim_move(
'x', 2, 3, mesh, color, sock);
1546 anim_move(
'x', 3, 3, mesh, color, sock);
1547 anim_move(
'z', 1, 1, mesh, color, sock);
1548 anim_move(
'x', 3, 1, mesh, color, sock);
1549 anim_move(
'x', 1, 3, mesh, color, sock);
1550 anim_move(
'z', 1, 3, mesh, color, sock);
1551 anim_move(
'x', 1, 1, mesh, color, sock);
1554 anim_move(
'y', 1, 3, mesh, color, sock);
1555 anim_move(
'z', 1, 3, mesh, color, sock);
1556 anim_move(
'y', 1, 2, mesh, color, sock);
1557 anim_move(
'z', 1, 2, mesh, color, sock);
1558 anim_move(
'y', 1, 3, mesh, color, sock);
1566 anim_move(
'y', 1, 1, mesh, color, sock);
1567 anim_move(
'y', 3, 3, mesh, color, sock);
1568 anim_move(
'z', 1, 2, mesh, color, sock);
1569 anim_move(
'y', 3, 1, mesh, color, sock);
1570 anim_move(
'y', 1, 3, mesh, color, sock);
1573 anim_move(
'x', 3, 1, mesh, color, sock);
1574 anim_move(
'z', 1, 1, mesh, color, sock);
1575 anim_move(
'x', 3, 3, mesh, color, sock);
1576 anim_move(
'x', 1, 3, mesh, color, sock);
1577 anim_move(
'z', 1, 2, mesh, color, sock);
1578 anim_move(
'x', 1, 1, mesh, color, sock);
1581 anim_move(
'y', 3, 3, mesh, color, sock);
1582 anim_move(
'z', 1, 3, mesh, color, sock);
1583 anim_move(
'y', 3, 1, mesh, color, sock);
1584 anim_move(
'y', 1, 1, mesh, color, sock);
1585 anim_move(
'z', 1, 2, mesh, color, sock);
1586 anim_move(
'y', 1, 3, mesh, color, sock);
1594 anim_move(
'x', 1, 1, mesh, color, sock);
1595 anim_move(
'z', 1, 1, mesh, color, sock);
1596 anim_move(
'x', 1, 2, mesh, color, sock);
1597 anim_move(
'z', 1, 2, mesh, color, sock);
1598 anim_move(
'x', 1, 1, mesh, color, sock);
1601 anim_move(
'y', 3, 1, mesh, color, sock);
1602 anim_move(
'z', 1, 3, mesh, color, sock);
1603 anim_move(
'y', 3, 3, mesh, color, sock);
1604 anim_move(
'y', 1, 1, mesh, color, sock);
1605 anim_move(
'z', 1, 1, mesh, color, sock);
1606 anim_move(
'y', 1, 3, mesh, color, sock);
1609 anim_move(
'y', 2, 3, mesh, color, sock);
1610 anim_move(
'x', 1, 3, mesh, color, sock);
1611 anim_move(
'y', 2, 1, mesh, color, sock);
1628 anim_move(
'z', 1, 2, mesh, color, sock);
1629 anim_move(
'y', 2, 1, mesh, color, sock);
1630 anim_move(
'x', 3, 2, mesh, color, sock);
1631 anim_move(
'y', 2, 3, mesh, color, sock);
1634 anim_move(
'z', 1, 3, mesh, color, sock);
1635 anim_move(
'x', 3, 3, mesh, color, sock);
1636 anim_move(
'z', 1, 1, mesh, color, sock);
1637 anim_move(
'x', 3, 1, mesh, color, sock);
1640 anim_move(
'x', 3, 3, mesh, color, sock);
1641 anim_move(
'z', 1, 3, mesh, color, sock);
1642 anim_move(
'x', 3, 1, mesh, color, sock);
1650 anim_move(
'x', 3, 3, mesh, color, sock);
1651 anim_move(
'z', 1, 1, mesh, color, sock);
1652 anim_move(
'x', 3, 1, mesh, color, sock);
1655 anim_move(
'y', 1, 3, mesh, color, sock);
1656 anim_move(
'z', 1, 1, mesh, color, sock);
1657 anim_move(
'y', 1, 1, mesh, color, sock);
1658 anim_move(
'x', 3, 3, mesh, color, sock);
1659 anim_move(
'z', 1, 2, mesh, color, sock);
1660 anim_move(
'x', 3, 1, mesh, color, sock);
1663 anim_move(
'y', 1, 3, mesh, color, sock);
1664 anim_move(
'z', 1, 3, mesh, color, sock);
1665 anim_move(
'y', 1, 1, mesh, color, sock);
1673 anim_move(
'y', 2, 1, mesh, color, sock);
1674 anim_move(
'x', 3, 2, mesh, color, sock);
1675 anim_move(
'y', 2, 3, mesh, color, sock);
1678 anim_move(
'y', 1, 3, mesh, color, sock);
1679 anim_move(
'z', 1, 1, mesh, color, sock);
1680 anim_move(
'y', 1, 1, mesh, color, sock);
1683 anim_move(
'z', 1, 1, mesh, color, sock);
1684 anim_move(
'y', 2, 1, mesh, color, sock);
1685 anim_move(
'x', 3, 1, mesh, color, sock);
1686 anim_move(
'y', 2, 3, mesh, color, sock);
1694 anim_move(
'y', 1, 3, mesh, color, sock);
1695 anim_move(
'z', 1, 2, mesh, color, sock);
1696 anim_move(
'y', 1, 1, mesh, color, sock);
1699 anim_move(
'z', 1, 1, mesh, color, sock);
1700 anim_move(
'y', 2, 1, mesh, color, sock);
1701 anim_move(
'x', 3, 2, mesh, color, sock);
1702 anim_move(
'y', 2, 3, mesh, color, sock);
1705 anim_move(
'x', 3, 3, mesh, color, sock);
1706 anim_move(
'z', 1, 2, mesh, color, sock);
1707 anim_move(
'x', 3, 1, mesh, color, sock);
1715 anim_move(
'y', 1, 3, mesh, color, sock);
1716 anim_move(
'z', 1, 3, mesh, color, sock);
1717 anim_move(
'y', 1, 1, mesh, color, sock);
1718 anim_move(
'z', 1, 1, mesh, color, sock);
1719 anim_move(
'y', 1, 3, mesh, color, sock);
1720 anim_move(
'z', 1, 3, mesh, color, sock);
1721 anim_move(
'y', 1, 1, mesh, color, sock);
1724 anim_move(
'x', 3, 3, mesh, color, sock);
1725 anim_move(
'z', 1, 1, mesh, color, sock);
1726 anim_move(
'x', 3, 1, mesh, color, sock);
1727 anim_move(
'z', 1, 3, mesh, color, sock);
1728 anim_move(
'x', 3, 3, mesh, color, sock);
1729 anim_move(
'z', 1, 1, mesh, color, sock);
1730 anim_move(
'x', 3, 1, mesh, color, sock);
1738 anim_move(
'x', 3, 1, mesh, color, sock);
1739 anim_move(
'z', 1, 3, mesh, color, sock);
1740 anim_move(
'x', 3, 2, mesh, color, sock);
1741 anim_move(
'z', 1, 2, mesh, color, sock);
1742 anim_move(
'x', 3, 1, mesh, color, sock);
1745 anim_move(
'y', 3, 3, mesh, color, sock);
1746 anim_move(
'z', 1, 1, mesh, color, sock);
1747 anim_move(
'y', 3, 1, mesh, color, sock);
1748 anim_move(
'y', 1, 3, mesh, color, sock);
1749 anim_move(
'z', 1, 3, mesh, color, sock);
1750 anim_move(
'y', 1, 1, mesh, color, sock);
1753 anim_move(
'y', 2, 1, mesh, color, sock);
1754 anim_move(
'x', 3, 3, mesh, color, sock);
1755 anim_move(
'y', 2, 3, mesh, color, sock);
1763 anim_move(
'y', 1, 3, mesh, color, sock);
1764 anim_move(
'y', 3, 1, mesh, color, sock);
1765 anim_move(
'z', 1, 2, mesh, color, sock);
1766 anim_move(
'y', 3, 3, mesh, color, sock);
1767 anim_move(
'y', 1, 1, mesh, color, sock);
1770 anim_move(
'x', 1, 1, mesh, color, sock);
1771 anim_move(
'z', 1, 3, mesh, color, sock);
1772 anim_move(
'x', 1, 3, mesh, color, sock);
1773 anim_move(
'x', 3, 3, mesh, color, sock);
1774 anim_move(
'z', 1, 2, mesh, color, sock);
1775 anim_move(
'x', 3, 1, mesh, color, sock);
1778 anim_move(
'y', 3, 1, mesh, color, sock);
1779 anim_move(
'z', 1, 1, mesh, color, sock);
1780 anim_move(
'y', 3, 3, mesh, color, sock);
1781 anim_move(
'y', 1, 3, mesh, color, sock);
1782 anim_move(
'z', 1, 2, mesh, color, sock);
1783 anim_move(
'y', 1, 1, mesh, color, sock);
1800 anim_move(
'y', 3, 3, mesh, color, sock);
1801 anim_move(
'z', 1, 2, mesh, color, sock);
1802 anim_move(
'y', 3, 1, mesh, color, sock);
1805 anim_move(
'z', 1, 1, mesh, color, sock);
1806 anim_move(
'x', 2, 3, mesh, color, sock);
1807 anim_move(
'y', 3, 2, mesh, color, sock);
1808 anim_move(
'x', 2, 1, mesh, color, sock);
1811 anim_move(
'x', 3, 1, mesh, color, sock);
1812 anim_move(
'z', 1, 2, mesh, color, sock);
1813 anim_move(
'x', 3, 3, mesh, color, sock);
1821 anim_move(
'z', 1, 2, mesh, color, sock);
1822 anim_move(
'x', 2, 3, mesh, color, sock);
1823 anim_move(
'y', 3, 2, mesh, color, sock);
1824 anim_move(
'x', 2, 1, mesh, color, sock);
1827 anim_move(
'y', 3, 3, mesh, color, sock);
1828 anim_move(
'z', 1, 3, mesh, color, sock);
1829 anim_move(
'y', 3, 1, mesh, color, sock);
1832 anim_move(
'z', 1, 1, mesh, color, sock);
1833 anim_move(
'x', 3, 1, mesh, color, sock);
1834 anim_move(
'z', 1, 2, mesh, color, sock);
1835 anim_move(
'x', 3, 3, mesh, color, sock);
1843 anim_move(
'x', 3, 1, mesh, color, sock);
1844 anim_move(
'z', 1, 3, mesh, color, sock);
1845 anim_move(
'x', 3, 3, mesh, color, sock);
1848 anim_move(
'x', 3, 1, mesh, color, sock);
1849 anim_move(
'z', 1, 1, mesh, color, sock);
1850 anim_move(
'x', 3, 3, mesh, color, sock);
1851 anim_move(
'y', 3, 3, mesh, color, sock);
1852 anim_move(
'z', 1, 2, mesh, color, sock);
1853 anim_move(
'y', 3, 1, mesh, color, sock);
1856 anim_move(
'y', 3, 3, mesh, color, sock);
1857 anim_move(
'z', 1, 1, mesh, color, sock);
1858 anim_move(
'y', 3, 1, mesh, color, sock);
1866 anim_move(
'x', 2, 3, mesh, color, sock);
1867 anim_move(
'y', 3, 2, mesh, color, sock);
1868 anim_move(
'x', 2, 1, mesh, color, sock);
1871 anim_move(
'z', 1, 1, mesh, color, sock);
1872 anim_move(
'x', 2, 3, mesh, color, sock);
1873 anim_move(
'y', 3, 1, mesh, color, sock);
1874 anim_move(
'x', 2, 1, mesh, color, sock);
1877 anim_move(
'x', 3, 1, mesh, color, sock);
1878 anim_move(
'z', 1, 1, mesh, color, sock);
1879 anim_move(
'x', 3, 3, mesh, color, sock);
1887 anim_move(
'y', 3, 3, mesh, color, sock);
1888 anim_move(
'z', 1, 1, mesh, color, sock);
1889 anim_move(
'y', 3, 1, mesh, color, sock);
1890 anim_move(
'z', 1, 3, mesh, color, sock);
1891 anim_move(
'y', 3, 3, mesh, color, sock);
1892 anim_move(
'z', 1, 1, mesh, color, sock);
1893 anim_move(
'y', 3, 1, mesh, color, sock);
1896 anim_move(
'x', 3, 1, mesh, color, sock);
1897 anim_move(
'z', 1, 3, mesh, color, sock);
1898 anim_move(
'x', 3, 3, mesh, color, sock);
1899 anim_move(
'z', 1, 1, mesh, color, sock);
1900 anim_move(
'x', 3, 1, mesh, color, sock);
1901 anim_move(
'z', 1, 3, mesh, color, sock);
1902 anim_move(
'x', 3, 3, mesh, color, sock);
1910 anim_move(
'x', 2, 3, mesh, color, sock);
1911 anim_move(
'y', 3, 3, mesh, color, sock);
1912 anim_move(
'x', 2, 1, mesh, color, sock);
1915 anim_move(
'x', 1, 1, mesh, color, sock);
1916 anim_move(
'z', 1, 1, mesh, color, sock);
1917 anim_move(
'x', 1, 3, mesh, color, sock);
1918 anim_move(
'x', 3, 1, mesh, color, sock);
1919 anim_move(
'z', 1, 3, mesh, color, sock);
1920 anim_move(
'x', 3, 3, mesh, color, sock);
1923 anim_move(
'y', 3, 1, mesh, color, sock);
1924 anim_move(
'z', 1, 3, mesh, color, sock);
1925 anim_move(
'y', 3, 2, mesh, color, sock);
1926 anim_move(
'z', 1, 2, mesh, color, sock);
1927 anim_move(
'y', 3, 1, mesh, color, sock);
1944 anim_move(
'z', 1, 1, mesh, color, sock);
1945 anim_move(
'y', 3, 1, mesh, color, sock);
1946 anim_move(
'z', 1, 1, mesh, color, sock);
1947 anim_move(
'y', 3, 3, mesh, color, sock);
1948 anim_move(
'x', 1, 1, mesh, color, sock);
1949 anim_move(
'z', 1, 2, mesh, color, sock);
1950 anim_move(
'x', 1, 3, mesh, color, sock);
1953 anim_move(
'y', 3, 1, mesh, color, sock);
1954 anim_move(
'z', 1, 1, mesh, color, sock);
1955 anim_move(
'y', 3, 3, mesh, color, sock);
1958 anim_move(
'z', 1, 3, mesh, color, sock);
1959 anim_move(
'x', 1, 1, mesh, color, sock);
1960 anim_move(
'z', 1, 2, mesh, color, sock);
1961 anim_move(
'x', 1, 3, mesh, color, sock);
1969 anim_move(
'y', 3, 1, mesh, color, sock);
1970 anim_move(
'z', 1, 2, mesh, color, sock);
1971 anim_move(
'y', 3, 3, mesh, color, sock);
1974 anim_move(
'z', 1, 2, mesh, color, sock);
1975 anim_move(
'x', 1, 1, mesh, color, sock);
1976 anim_move(
'z', 1, 3, mesh, color, sock);
1977 anim_move(
'x', 1, 3, mesh, color, sock);
1978 anim_move(
'y', 3, 1, mesh, color, sock);
1979 anim_move(
'z', 1, 2, mesh, color, sock);
1980 anim_move(
'y', 3, 3, mesh, color, sock);
1983 anim_move(
'x', 1, 1, mesh, color, sock);
1984 anim_move(
'z', 1, 2, mesh, color, sock);
1985 anim_move(
'x', 1, 3, mesh, color, sock);
1993 anim_move(
'z', 1, 3, mesh, color, sock);
1994 anim_move(
'x', 1, 1, mesh, color, sock);
1995 anim_move(
'z', 1, 3, mesh, color, sock);
1996 anim_move(
'x', 1, 3, mesh, color, sock);
1997 anim_move(
'y', 3, 1, mesh, color, sock);
1998 anim_move(
'z', 1, 2, mesh, color, sock);
1999 anim_move(
'y', 3, 3, mesh, color, sock);
2002 anim_move(
'z', 1, 1, mesh, color, sock);
2003 anim_move(
'y', 3, 1, mesh, color, sock);
2004 anim_move(
'z', 1, 2, mesh, color, sock);
2005 anim_move(
'y', 3, 3, mesh, color, sock);
2008 anim_move(
'x', 1, 1, mesh, color, sock);
2009 anim_move(
'z', 1, 3, mesh, color, sock);
2010 anim_move(
'x', 1, 3, mesh, color, sock);
2018 anim_move(
'x', 1, 1, mesh, color, sock);
2019 anim_move(
'z', 1, 1, mesh, color, sock);
2020 anim_move(
'x', 1, 3, mesh, color, sock);
2023 anim_move(
'y', 3, 1, mesh, color, sock);
2024 anim_move(
'z', 1, 1, mesh, color, sock);
2025 anim_move(
'y', 3, 3, mesh, color, sock);
2026 anim_move(
'x', 1, 1, mesh, color, sock);
2027 anim_move(
'z', 1, 2, mesh, color, sock);
2028 anim_move(
'x', 1, 3, mesh, color, sock);
2031 anim_move(
'y', 3, 1, mesh, color, sock);
2032 anim_move(
'z', 1, 3, mesh, color, sock);
2033 anim_move(
'y', 3, 3, mesh, color, sock);
2041 anim_move(
'y', 3, 1, mesh, color, sock);
2042 anim_move(
'z', 1, 3, mesh, color, sock);
2043 anim_move(
'y', 3, 3, mesh, color, sock);
2044 anim_move(
'z', 1, 1, mesh, color, sock);
2045 anim_move(
'y', 3, 1, mesh, color, sock);
2046 anim_move(
'z', 1, 3, mesh, color, sock);
2047 anim_move(
'y', 3, 3, mesh, color, sock);
2050 anim_move(
'x', 1, 1, mesh, color, sock);
2051 anim_move(
'z', 1, 1, mesh, color, sock);
2052 anim_move(
'x', 1, 3, mesh, color, sock);
2053 anim_move(
'z', 1, 3, mesh, color, sock);
2054 anim_move(
'x', 1, 1, mesh, color, sock);
2055 anim_move(
'z', 1, 1, mesh, color, sock);
2056 anim_move(
'x', 1, 3, mesh, color, sock);
2068 cout <<
"Entering solve_top_corners" << endl;
2081 cout <<
"Location of 4-th corner: " << i4
2082 <<
" with orientation " << o4 << endl;
2095 cout <<
"Location of 5-th corner: " << i5
2096 <<
" with orientation " << o5 << endl;
2109 cout <<
"Location of 6-th corner: " << i6
2110 <<
" with orientation " << o6 << endl;
2123 cout <<
"Location of 7-th corner: " << i7
2124 <<
" with orientation " << o7 << endl;
2135 for (
int i=0; i<12; i++)
2137 if ((rubik.edge_[2 * i + 0] == edge_colors_[2 * ind + 0] &&
2138 rubik.edge_[2 * i + 1] == edge_colors_[2 * ind + 1]))
2142 if ((rubik.edge_[2 * i + 0] == edge_colors_[2 * ind + 1] &&
2143 rubik.edge_[2 * i + 1] == edge_colors_[2 * ind + 0]))
2160 anim_move(
'y', 2, 1, mesh, color, sock);
2161 anim_move(
'x', 2, 1, mesh, color, sock);
2162 anim_move(
'y', 2, 3, mesh, color, sock);
2165 anim_move(
'x', 3, 1, mesh, color, sock);
2166 anim_move(
'y', 1, 1, mesh, color, sock);
2169 anim_move(
'y', 3, 2, mesh, color, sock);
2170 anim_move(
'z', 3, 2, mesh, color, sock);
2173 anim_move(
'x', 1, 2, mesh, color, sock);
2174 anim_move(
'z', 3, 3, mesh, color, sock);
2177 anim_move(
'z', 3, 1, mesh, color, sock);
2180 anim_move(
'y', 2, 1, mesh, color, sock);
2181 anim_move(
'x', 2, 3, mesh, color, sock);
2182 anim_move(
'y', 2, 3, mesh, color, sock);
2185 anim_move(
'y', 2, 3, mesh, color, sock);
2186 anim_move(
'z', 3, 1, mesh, color, sock);
2187 anim_move(
'y', 2, 1, mesh, color, sock);
2190 anim_move(
'y', 1, 3, mesh, color, sock);
2193 anim_move(
'z', 2, 1, mesh, color, sock);
2194 anim_move(
'y', 1, 3, mesh, color, sock);
2197 anim_move(
'y', 3, 1, mesh, color, sock);
2198 anim_move(
'z', 3, 2, mesh, color, sock);
2201 anim_move(
'x', 1, 3, mesh, color, sock);
2202 anim_move(
'z', 3, 3, mesh, color, sock);
2211 anim_move(
'y', 1, 2, mesh, color, sock);
2214 anim_move(
'z', 1, 3, mesh, color, sock);
2215 anim_move(
'y', 1, 2, mesh, color, sock);
2218 anim_move(
'x', 2, 3, mesh, color, sock);
2219 anim_move(
'z', 3, 1, mesh, color, sock);
2220 anim_move(
'x', 2, 1, mesh, color, sock);
2221 anim_move(
'z', 3, 1, mesh, color, sock);
2224 anim_move(
'y', 2, 3, mesh, color, sock);
2225 anim_move(
'z', 3, 3, mesh, color, sock);
2226 anim_move(
'y', 2, 1, mesh, color, sock);
2229 anim_move(
'y', 1, 3, mesh, color, sock);
2230 anim_move(
'z', 2, 1, mesh, color, sock);
2231 anim_move(
'y', 1, 3, mesh, color, sock);
2234 anim_move(
'y', 2, 1, mesh, color, sock);
2235 anim_move(
'z', 3, 3, mesh, color, sock);
2236 anim_move(
'y', 2, 3, mesh, color, sock);
2239 anim_move(
'z', 3, 2, mesh, color, sock);
2242 anim_move(
'z', 3, 3, mesh, color, sock);
2245 anim_move(
'z', 2, 3, mesh, color, sock);
2246 anim_move(
'y', 1, 1, mesh, color, sock);
2249 anim_move(
'y', 1, 1, mesh, color, sock);
2252 anim_move(
'x', 3, 3, mesh, color, sock);
2253 anim_move(
'z', 3, 1, mesh, color, sock);
2256 anim_move(
'y', 3, 3, mesh, color, sock);
2257 anim_move(
'z', 3, 2, mesh, color, sock);
2272 anim_move(
'y', 1, 3, mesh, color, sock);
2273 anim_move(
'x', 3, 1, mesh, color, sock);
2274 anim_move(
'y', 1, 1, mesh, color, sock);
2277 anim_move(
'x', 2, 3, mesh, color, sock);
2278 anim_move(
'y', 2, 1, mesh, color, sock);
2279 anim_move(
'x', 2, 1, mesh, color, sock);
2282 anim_move(
'z', 1, 1, mesh, color, sock);
2283 anim_move(
'x', 3, 2, mesh, color, sock);
2286 anim_move(
'z', 1, 2, mesh, color, sock);
2287 anim_move(
'x', 3, 2, mesh, color, sock);
2290 anim_move(
'y', 3, 3, mesh, color, sock);
2291 anim_move(
'x', 3, 3, mesh, color, sock);
2294 anim_move(
'x', 2, 1, mesh, color, sock);
2295 anim_move(
'y', 2, 3, mesh, color, sock);
2296 anim_move(
'x', 2, 3, mesh, color, sock);
2299 anim_move(
'z', 2, 3, mesh, color, sock);
2300 anim_move(
'x', 3, 1, mesh, color, sock);
2303 anim_move(
'x', 3, 1, mesh, color, sock);
2306 anim_move(
'z', 2, 1, mesh, color, sock);
2307 anim_move(
'x', 3, 1, mesh, color, sock);
2310 anim_move(
'y', 3, 2, mesh, color, sock);
2311 anim_move(
'x', 3, 3, mesh, color, sock);
2320 anim_move(
'z', 1, 3, mesh, color, sock);
2321 anim_move(
'x', 3, 2, mesh, color, sock);
2324 anim_move(
'x', 3, 2, mesh, color, sock);
2327 anim_move(
'y', 3, 1, mesh, color, sock);
2328 anim_move(
'x', 3, 3, mesh, color, sock);
2331 anim_move(
'z', 1, 2, mesh, color, sock);
2332 anim_move(
'x', 2, 3, mesh, color, sock);
2333 anim_move(
'y', 2, 1, mesh, color, sock);
2334 anim_move(
'x', 2, 1, mesh, color, sock);
2337 anim_move(
'x', 3, 1, mesh, color, sock);
2338 anim_move(
'z', 2, 1, mesh, color, sock);
2339 anim_move(
'x', 3, 1, mesh, color, sock);
2342 anim_move(
'y', 1, 1, mesh, color, sock);
2343 anim_move(
'z', 3, 1, mesh, color, sock);
2344 anim_move(
'y', 1, 3, mesh, color, sock);
2347 anim_move(
'y', 1, 1, mesh, color, sock);
2348 anim_move(
'z', 3, 2, mesh, color, sock);
2349 anim_move(
'y', 1, 3, mesh, color, sock);
2352 anim_move(
'z', 2, 2, mesh, color, sock);
2353 anim_move(
'x', 3, 3, mesh, color, sock);
2356 anim_move(
'z', 2, 3, mesh, color, sock);
2357 anim_move(
'x', 3, 3, mesh, color, sock);
2360 anim_move(
'x', 3, 3, mesh, color, sock);
2363 anim_move(
'z', 2, 1, mesh, color, sock);
2364 anim_move(
'x', 3, 3, mesh, color, sock);
2379 anim_move(
'z', 1, 2, mesh, color, sock);
2380 anim_move(
'y', 3, 2, mesh, color, sock);
2383 anim_move(
'z', 1, 3, mesh, color, sock);
2384 anim_move(
'y', 3, 2, mesh, color, sock);
2387 anim_move(
'y', 3, 1, mesh, color, sock);
2388 anim_move(
'z', 2, 3, mesh, color, sock);
2389 anim_move(
'y', 3, 3, mesh, color, sock);
2392 anim_move(
'x', 1, 3, mesh, color, sock);
2393 anim_move(
'y', 3, 3, mesh, color, sock);
2396 anim_move(
'z', 3, 1, mesh, color, sock);
2397 anim_move(
'y', 3, 1, mesh, color, sock);
2398 anim_move(
'z', 3, 3, mesh, color, sock);
2399 anim_move(
'y', 3, 3, mesh, color, sock);
2402 anim_move(
'z', 2, 1, mesh, color, sock);
2403 anim_move(
'y', 3, 3, mesh, color, sock);
2406 anim_move(
'z', 2, 2, mesh, color, sock);
2407 anim_move(
'y', 3, 3, mesh, color, sock);
2410 anim_move(
'z', 2, 3, mesh, color, sock);
2411 anim_move(
'y', 3, 3, mesh, color, sock);
2414 anim_move(
'y', 3, 3, mesh, color, sock);
2423 anim_move(
'z', 1, 1, mesh, color, sock);
2424 anim_move(
'x', 1, 3, mesh, color, sock);
2425 anim_move(
'y', 3, 3, mesh, color, sock);
2428 anim_move(
'x', 2, 1, mesh, color, sock);
2429 anim_move(
'z', 1, 3, mesh, color, sock);
2430 anim_move(
'x', 2, 3, mesh, color, sock);
2433 anim_move(
'y', 3, 2, mesh, color, sock);
2436 anim_move(
'z', 1, 1, mesh, color, sock);
2437 anim_move(
'y', 3, 2, mesh, color, sock);
2440 anim_move(
'y', 3, 1, mesh, color, sock);
2441 anim_move(
'z', 2, 1, mesh, color, sock);
2442 anim_move(
'y', 3, 1, mesh, color, sock);
2445 anim_move(
'x', 1, 1, mesh, color, sock);
2446 anim_move(
'y', 3, 3, mesh, color, sock);
2449 anim_move(
'z', 2, 2, mesh, color, sock);
2450 anim_move(
'y', 3, 1, mesh, color, sock);
2453 anim_move(
'z', 2, 3, mesh, color, sock);
2454 anim_move(
'y', 3, 1, mesh, color, sock);
2457 anim_move(
'y', 3, 1, mesh, color, sock);
2460 anim_move(
'z', 2, 1, mesh, color, sock);
2461 anim_move(
'y', 3, 1, mesh, color, sock);
2476 anim_move(
'z', 1, 1, mesh, color, sock);
2477 anim_move(
'x', 1, 2, mesh, color, sock);
2480 anim_move(
'z', 1, 2, mesh, color, sock);
2481 anim_move(
'x', 1, 2, mesh, color, sock);
2484 anim_move(
'y', 3, 3, mesh, color, sock);
2485 anim_move(
'x', 1, 3, mesh, color, sock);
2486 anim_move(
'y', 3, 1, mesh, color, sock);
2489 anim_move(
'x', 1, 1, mesh, color, sock);
2490 anim_move(
'z', 2, 1, mesh, color, sock);
2491 anim_move(
'x', 1, 3, mesh, color, sock);
2494 anim_move(
'x', 1, 1, mesh, color, sock);
2497 anim_move(
'z', 2, 1, mesh, color, sock);
2498 anim_move(
'x', 1, 1, mesh, color, sock);
2501 anim_move(
'z', 2, 2, mesh, color, sock);
2502 anim_move(
'x', 1, 1, mesh, color, sock);
2505 anim_move(
'z', 2, 3, mesh, color, sock);
2506 anim_move(
'x', 1, 1, mesh, color, sock);
2515 anim_move(
'y', 1, 3, mesh, color, sock);
2516 anim_move(
'x', 1, 1, mesh, color, sock);
2517 anim_move(
'y', 1, 1, mesh, color, sock);
2520 anim_move(
'z', 1, 3, mesh, color, sock);
2521 anim_move(
'y', 3, 3, mesh, color, sock);
2522 anim_move(
'x', 1, 3, mesh, color, sock);
2523 anim_move(
'y', 3, 1, mesh, color, sock);
2526 anim_move(
'z', 1, 3, mesh, color, sock);
2527 anim_move(
'x', 1, 2, mesh, color, sock);
2530 anim_move(
'x', 1, 2, mesh, color, sock);
2533 anim_move(
'x', 1, 1, mesh, color, sock);
2534 anim_move(
'z', 2, 3, mesh, color, sock);
2535 anim_move(
'x', 1, 1, mesh, color, sock);
2538 anim_move(
'z', 2, 1, mesh, color, sock);
2539 anim_move(
'x', 1, 3, mesh, color, sock);
2542 anim_move(
'z', 2, 2, mesh, color, sock);
2543 anim_move(
'x', 1, 3, mesh, color, sock);
2546 anim_move(
'z', 2, 3, mesh, color, sock);
2547 anim_move(
'x', 1, 3, mesh, color, sock);
2550 anim_move(
'x', 1, 3, mesh, color, sock);
2565 anim_move(
'z', 1, 2, mesh, color, sock);
2566 anim_move(
'y', 1, 1, mesh, color, sock);
2567 anim_move(
'z', 1, 3, mesh, color, sock);
2568 anim_move(
'y', 1, 3, mesh, color, sock);
2569 anim_move(
'x', 1, 1, mesh, color, sock);
2570 anim_move(
'y', 1, 3, mesh, color, sock);
2571 anim_move(
'x', 1, 3, mesh, color, sock);
2572 anim_move(
'y', 1, 1, mesh, color, sock);
2575 anim_move(
'z', 1, 3, mesh, color, sock);
2576 anim_move(
'y', 1, 1, mesh, color, sock);
2577 anim_move(
'z', 1, 3, mesh, color, sock);
2578 anim_move(
'y', 1, 3, mesh, color, sock);
2579 anim_move(
'x', 1, 1, mesh, color, sock);
2580 anim_move(
'y', 1, 3, mesh, color, sock);
2581 anim_move(
'x', 1, 3, mesh, color, sock);
2582 anim_move(
'y', 1, 1, mesh, color, sock);
2585 anim_move(
'z', 1, 1, mesh, color, sock);
2586 anim_move(
'x', 1, 3, mesh, color, sock);
2587 anim_move(
'z', 1, 1, mesh, color, sock);
2588 anim_move(
'x', 1, 1, mesh, color, sock);
2589 anim_move(
'y', 1, 3, mesh, color, sock);
2590 anim_move(
'x', 1, 1, mesh, color, sock);
2591 anim_move(
'y', 1, 1, mesh, color, sock);
2592 anim_move(
'x', 1, 3, mesh, color, sock);
2595 anim_move(
'z', 1, 2, mesh, color, sock);
2596 anim_move(
'x', 1, 3, mesh, color, sock);
2597 anim_move(
'z', 1, 1, mesh, color, sock);
2598 anim_move(
'x', 1, 1, mesh, color, sock);
2599 anim_move(
'y', 1, 3, mesh, color, sock);
2600 anim_move(
'x', 1, 1, mesh, color, sock);
2601 anim_move(
'y', 1, 1, mesh, color, sock);
2602 anim_move(
'x', 1, 3, mesh, color, sock);
2605 anim_move(
'x', 3, 3, mesh, color, sock);
2607 anim_move(
'x', 3, 1, mesh, color, sock);
2608 anim_move(
'z', 1, 1, mesh, color, sock);
2609 anim_move(
'y', 1, 1, mesh, color, sock);
2611 anim_move(
'y', 1, 3, mesh, color, sock);
2614 anim_move(
'z', 2, 1, mesh, color, sock);
2615 anim_move(
'y', 1, 2, mesh, color, sock);
2616 anim_move(
'z', 2, 3, mesh, color, sock);
2617 anim_move(
'y', 1, 2, mesh, color, sock);
2620 anim_move(
'y', 3, 1, mesh, color, sock);
2622 anim_move(
'y', 3, 3, mesh, color, sock);
2623 anim_move(
'z', 1, 3, mesh, color, sock);
2624 anim_move(
'y', 1, 1, mesh, color, sock);
2626 anim_move(
'y', 1, 3, mesh, color, sock);
2635 anim_move(
'z', 1, 3, mesh, color, sock);
2636 anim_move(
'x', 1, 3, mesh, color, sock);
2637 anim_move(
'z', 1, 1, mesh, color, sock);
2638 anim_move(
'x', 1, 1, mesh, color, sock);
2639 anim_move(
'y', 1, 3, mesh, color, sock);
2640 anim_move(
'x', 1, 1, mesh, color, sock);
2641 anim_move(
'y', 1, 1, mesh, color, sock);
2642 anim_move(
'x', 1, 3, mesh, color, sock);
2645 anim_move(
'x', 1, 3, mesh, color, sock);
2646 anim_move(
'z', 1, 1, mesh, color, sock);
2647 anim_move(
'x', 1, 1, mesh, color, sock);
2648 anim_move(
'y', 1, 3, mesh, color, sock);
2649 anim_move(
'x', 1, 1, mesh, color, sock);
2650 anim_move(
'y', 1, 1, mesh, color, sock);
2651 anim_move(
'x', 1, 3, mesh, color, sock);
2654 anim_move(
'y', 1, 1, mesh, color, sock);
2655 anim_move(
'z', 1, 3, mesh, color, sock);
2656 anim_move(
'y', 1, 3, mesh, color, sock);
2657 anim_move(
'x', 1, 1, mesh, color, sock);
2658 anim_move(
'y', 1, 3, mesh, color, sock);
2659 anim_move(
'x', 1, 3, mesh, color, sock);
2660 anim_move(
'y', 1, 1, mesh, color, sock);
2663 anim_move(
'z', 1, 1, mesh, color, sock);
2664 anim_move(
'y', 1, 1, mesh, color, sock);
2665 anim_move(
'z', 1, 3, mesh, color, sock);
2666 anim_move(
'y', 1, 3, mesh, color, sock);
2667 anim_move(
'x', 1, 1, mesh, color, sock);
2668 anim_move(
'y', 1, 3, mesh, color, sock);
2669 anim_move(
'x', 1, 3, mesh, color, sock);
2670 anim_move(
'y', 1, 1, mesh, color, sock);
2673 anim_move(
'y', 1, 1, mesh, color, sock);
2674 anim_move(
'z', 1, 3, mesh, color, sock);
2675 anim_move(
'y', 1, 3, mesh, color, sock);
2676 anim_move(
'x', 1, 1, mesh, color, sock);
2677 anim_move(
'y', 1, 3, mesh, color, sock);
2678 anim_move(
'x', 1, 3, mesh, color, sock);
2679 anim_move(
'y', 1, 1, mesh, color, sock);
2680 anim_move(
'z', 1, 3, mesh, color, sock);
2681 anim_move(
'y', 1, 1, mesh, color, sock);
2682 anim_move(
'z', 1, 3, mesh, color, sock);
2683 anim_move(
'y', 1, 3, mesh, color, sock);
2684 anim_move(
'x', 1, 1, mesh, color, sock);
2685 anim_move(
'y', 1, 3, mesh, color, sock);
2686 anim_move(
'x', 1, 3, mesh, color, sock);
2687 anim_move(
'y', 1, 1, mesh, color, sock);
2690 anim_move(
'y', 1, 2, mesh, color, sock);
2691 anim_move(
'z', 1, 2, mesh, color, sock);
2692 anim_move(
'y', 1, 2, mesh, color, sock);
2693 anim_move(
'z', 1, 2, mesh, color, sock);
2694 anim_move(
'y', 1, 2, mesh, color, sock);
2697 anim_move(
'y', 3, 3, mesh, color, sock);
2699 anim_move(
'y', 3, 1, mesh, color, sock);
2700 anim_move(
'z', 1, 3, mesh, color, sock);
2701 anim_move(
'y', 1, 1, mesh, color, sock);
2703 anim_move(
'y', 1, 3, mesh, color, sock);
2706 anim_move(
'z', 2, 1, mesh, color, sock);
2707 anim_move(
'x', 1, 2, mesh, color, sock);
2708 anim_move(
'z', 2, 3, mesh, color, sock);
2709 anim_move(
'x', 1, 2, mesh, color, sock);
2724 anim_move(
'z', 1, 1, mesh, color, sock);
2725 anim_move(
'x', 3, 3, mesh, color, sock);
2726 anim_move(
'z', 1, 3, mesh, color, sock);
2727 anim_move(
'x', 3, 1, mesh, color, sock);
2728 anim_move(
'y', 1, 1, mesh, color, sock);
2729 anim_move(
'x', 3, 1, mesh, color, sock);
2730 anim_move(
'y', 1, 3, mesh, color, sock);
2731 anim_move(
'x', 3, 3, mesh, color, sock);
2734 anim_move(
'z', 1, 2, mesh, color, sock);
2735 anim_move(
'x', 3, 3, mesh, color, sock);
2736 anim_move(
'z', 1, 3, mesh, color, sock);
2737 anim_move(
'x', 3, 1, mesh, color, sock);
2738 anim_move(
'y', 1, 1, mesh, color, sock);
2739 anim_move(
'x', 3, 1, mesh, color, sock);
2740 anim_move(
'y', 1, 3, mesh, color, sock);
2741 anim_move(
'x', 3, 3, mesh, color, sock);
2744 anim_move(
'y', 1, 3, mesh, color, sock);
2745 anim_move(
'z', 1, 1, mesh, color, sock);
2746 anim_move(
'y', 1, 1, mesh, color, sock);
2747 anim_move(
'x', 3, 1, mesh, color, sock);
2748 anim_move(
'y', 1, 1, mesh, color, sock);
2749 anim_move(
'x', 3, 3, mesh, color, sock);
2750 anim_move(
'y', 1, 3, mesh, color, sock);
2753 anim_move(
'z', 1, 1, mesh, color, sock);
2754 anim_move(
'y', 1, 3, mesh, color, sock);
2755 anim_move(
'z', 1, 1, mesh, color, sock);
2756 anim_move(
'y', 1, 1, mesh, color, sock);
2757 anim_move(
'x', 3, 1, mesh, color, sock);
2758 anim_move(
'y', 1, 1, mesh, color, sock);
2759 anim_move(
'x', 3, 3, mesh, color, sock);
2760 anim_move(
'y', 1, 3, mesh, color, sock);
2763 anim_move(
'y', 3, 3, mesh, color, sock);
2765 anim_move(
'y', 3, 1, mesh, color, sock);
2766 anim_move(
'z', 1, 3, mesh, color, sock);
2767 anim_move(
'y', 1, 3, mesh, color, sock);
2769 anim_move(
'y', 1, 1, mesh, color, sock);
2772 anim_move(
'z', 2, 1, mesh, color, sock);
2773 anim_move(
'x', 3, 2, mesh, color, sock);
2774 anim_move(
'z', 2, 3, mesh, color, sock);
2775 anim_move(
'x', 3, 2, mesh, color, sock);
2784 anim_move(
'z', 1, 2, mesh, color, sock);
2785 anim_move(
'y', 1, 3, mesh, color, sock);
2786 anim_move(
'z', 1, 1, mesh, color, sock);
2787 anim_move(
'y', 1, 1, mesh, color, sock);
2788 anim_move(
'x', 3, 1, mesh, color, sock);
2789 anim_move(
'y', 1, 1, mesh, color, sock);
2790 anim_move(
'x', 3, 3, mesh, color, sock);
2791 anim_move(
'y', 1, 3, mesh, color, sock);
2794 anim_move(
'z', 1, 3, mesh, color, sock);
2795 anim_move(
'y', 1, 3, mesh, color, sock);
2796 anim_move(
'z', 1, 1, mesh, color, sock);
2797 anim_move(
'y', 1, 1, mesh, color, sock);
2798 anim_move(
'x', 3, 1, mesh, color, sock);
2799 anim_move(
'y', 1, 1, mesh, color, sock);
2800 anim_move(
'x', 3, 3, mesh, color, sock);
2801 anim_move(
'y', 1, 3, mesh, color, sock);
2804 anim_move(
'z', 1, 3, mesh, color, sock);
2805 anim_move(
'x', 3, 3, mesh, color, sock);
2806 anim_move(
'z', 1, 3, mesh, color, sock);
2807 anim_move(
'x', 3, 1, mesh, color, sock);
2808 anim_move(
'y', 1, 1, mesh, color, sock);
2809 anim_move(
'x', 3, 1, mesh, color, sock);
2810 anim_move(
'y', 1, 3, mesh, color, sock);
2811 anim_move(
'x', 3, 3, mesh, color, sock);
2814 anim_move(
'x', 3, 3, mesh, color, sock);
2815 anim_move(
'z', 1, 3, mesh, color, sock);
2816 anim_move(
'x', 3, 1, mesh, color, sock);
2817 anim_move(
'y', 1, 1, mesh, color, sock);
2818 anim_move(
'x', 3, 1, mesh, color, sock);
2819 anim_move(
'y', 1, 3, mesh, color, sock);
2820 anim_move(
'x', 3, 3, mesh, color, sock);
2823 anim_move(
'x', 3, 3, mesh, color, sock);
2824 anim_move(
'z', 1, 3, mesh, color, sock);
2825 anim_move(
'x', 3, 1, mesh, color, sock);
2826 anim_move(
'y', 1, 1, mesh, color, sock);
2827 anim_move(
'x', 3, 1, mesh, color, sock);
2828 anim_move(
'y', 1, 3, mesh, color, sock);
2829 anim_move(
'x', 3, 3, mesh, color, sock);
2830 anim_move(
'z', 1, 3, mesh, color, sock);
2831 anim_move(
'x', 3, 3, mesh, color, sock);
2832 anim_move(
'z', 1, 3, mesh, color, sock);
2833 anim_move(
'x', 3, 1, mesh, color, sock);
2834 anim_move(
'y', 1, 1, mesh, color, sock);
2835 anim_move(
'x', 3, 1, mesh, color, sock);
2836 anim_move(
'y', 1, 3, mesh, color, sock);
2837 anim_move(
'x', 3, 3, mesh, color, sock);
2840 anim_move(
'x', 3, 2, mesh, color, sock);
2841 anim_move(
'z', 1, 2, mesh, color, sock);
2842 anim_move(
'x', 3, 2, mesh, color, sock);
2843 anim_move(
'z', 1, 2, mesh, color, sock);
2844 anim_move(
'x', 3, 2, mesh, color, sock);
2847 anim_move(
'y', 3, 1, mesh, color, sock);
2849 anim_move(
'y', 3, 3, mesh, color, sock);
2850 anim_move(
'z', 1, 3, mesh, color, sock);
2851 anim_move(
'y', 1, 3, mesh, color, sock);
2853 anim_move(
'y', 1, 1, mesh, color, sock);
2868 anim_move(
'y', 3, 3, mesh, color, sock);
2869 anim_move(
'z', 1, 3, mesh, color, sock);
2870 anim_move(
'y', 3, 1, mesh, color, sock);
2871 anim_move(
'x', 3, 3, mesh, color, sock);
2872 anim_move(
'y', 3, 1, mesh, color, sock);
2873 anim_move(
'x', 3, 1, mesh, color, sock);
2874 anim_move(
'y', 3, 3, mesh, color, sock);
2877 anim_move(
'z', 1, 1, mesh, color, sock);
2878 anim_move(
'y', 3, 3, mesh, color, sock);
2879 anim_move(
'z', 1, 3, mesh, color, sock);
2880 anim_move(
'y', 3, 1, mesh, color, sock);
2881 anim_move(
'x', 3, 3, mesh, color, sock);
2882 anim_move(
'y', 3, 1, mesh, color, sock);
2883 anim_move(
'x', 3, 1, mesh, color, sock);
2884 anim_move(
'y', 3, 3, mesh, color, sock);
2887 anim_move(
'z', 1, 3, mesh, color, sock);
2888 anim_move(
'x', 3, 1, mesh, color, sock);
2889 anim_move(
'z', 1, 1, mesh, color, sock);
2890 anim_move(
'x', 3, 3, mesh, color, sock);
2891 anim_move(
'y', 3, 1, mesh, color, sock);
2892 anim_move(
'x', 3, 3, mesh, color, sock);
2893 anim_move(
'y', 3, 3, mesh, color, sock);
2894 anim_move(
'x', 3, 1, mesh, color, sock);
2897 anim_move(
'x', 3, 1, mesh, color, sock);
2898 anim_move(
'z', 1, 1, mesh, color, sock);
2899 anim_move(
'x', 3, 3, mesh, color, sock);
2900 anim_move(
'y', 3, 1, mesh, color, sock);
2901 anim_move(
'x', 3, 3, mesh, color, sock);
2902 anim_move(
'y', 3, 3, mesh, color, sock);
2903 anim_move(
'x', 3, 1, mesh, color, sock);
2906 anim_move(
'y', 3, 1, mesh, color, sock);
2908 anim_move(
'y', 3, 3, mesh, color, sock);
2909 anim_move(
'z', 1, 1, mesh, color, sock);
2910 anim_move(
'y', 3, 3, mesh, color, sock);
2912 anim_move(
'y', 3, 1, mesh, color, sock);
2921 anim_move(
'z', 1, 1, mesh, color, sock);
2922 anim_move(
'x', 3, 1, mesh, color, sock);
2923 anim_move(
'z', 1, 1, mesh, color, sock);
2924 anim_move(
'x', 3, 3, mesh, color, sock);
2925 anim_move(
'y', 3, 1, mesh, color, sock);
2926 anim_move(
'x', 3, 3, mesh, color, sock);
2927 anim_move(
'y', 3, 3, mesh, color, sock);
2928 anim_move(
'x', 3, 1, mesh, color, sock);
2931 anim_move(
'z', 1, 2, mesh, color, sock);
2932 anim_move(
'x', 3, 1, mesh, color, sock);
2933 anim_move(
'z', 1, 1, mesh, color, sock);
2934 anim_move(
'x', 3, 3, mesh, color, sock);
2935 anim_move(
'y', 3, 1, mesh, color, sock);
2936 anim_move(
'x', 3, 3, mesh, color, sock);
2937 anim_move(
'y', 3, 3, mesh, color, sock);
2938 anim_move(
'x', 3, 1, mesh, color, sock);
2941 anim_move(
'z', 1, 2, mesh, color, sock);
2942 anim_move(
'y', 3, 3, mesh, color, sock);
2943 anim_move(
'z', 1, 3, mesh, color, sock);
2944 anim_move(
'y', 3, 1, mesh, color, sock);
2945 anim_move(
'x', 3, 3, mesh, color, sock);
2946 anim_move(
'y', 3, 1, mesh, color, sock);
2947 anim_move(
'x', 3, 1, mesh, color, sock);
2948 anim_move(
'y', 3, 3, mesh, color, sock);
2951 anim_move(
'z', 1, 3, mesh, color, sock);
2952 anim_move(
'y', 3, 3, mesh, color, sock);
2953 anim_move(
'z', 1, 3, mesh, color, sock);
2954 anim_move(
'y', 3, 1, mesh, color, sock);
2955 anim_move(
'x', 3, 3, mesh, color, sock);
2956 anim_move(
'y', 3, 1, mesh, color, sock);
2957 anim_move(
'x', 3, 1, mesh, color, sock);
2958 anim_move(
'y', 3, 3, mesh, color, sock);
2961 anim_move(
'x', 3, 1, mesh, color, sock);
2962 anim_move(
'z', 1, 1, mesh, color, sock);
2963 anim_move(
'x', 3, 3, mesh, color, sock);
2964 anim_move(
'y', 3, 1, mesh, color, sock);
2965 anim_move(
'x', 3, 3, mesh, color, sock);
2966 anim_move(
'y', 3, 3, mesh, color, sock);
2967 anim_move(
'x', 3, 1, mesh, color, sock);
2968 anim_move(
'z', 1, 1, mesh, color, sock);
2969 anim_move(
'x', 3, 1, mesh, color, sock);
2970 anim_move(
'z', 1, 1, mesh, color, sock);
2971 anim_move(
'x', 3, 3, mesh, color, sock);
2972 anim_move(
'y', 3, 1, mesh, color, sock);
2973 anim_move(
'x', 3, 3, mesh, color, sock);
2974 anim_move(
'y', 3, 3, mesh, color, sock);
2975 anim_move(
'x', 3, 1, mesh, color, sock);
2978 anim_move(
'y', 3, 2, mesh, color, sock);
2979 anim_move(
'z', 1, 2, mesh, color, sock);
2980 anim_move(
'y', 3, 2, mesh, color, sock);
2981 anim_move(
'z', 1, 2, mesh, color, sock);
2982 anim_move(
'y', 3, 2, mesh, color, sock);
2997 anim_move(
'z', 1, 3, mesh, color, sock);
2998 anim_move(
'x', 1, 1, mesh, color, sock);
2999 anim_move(
'z', 1, 3, mesh, color, sock);
3000 anim_move(
'x', 1, 3, mesh, color, sock);
3001 anim_move(
'y', 3, 3, mesh, color, sock);
3002 anim_move(
'x', 1, 3, mesh, color, sock);
3003 anim_move(
'y', 3, 1, mesh, color, sock);
3004 anim_move(
'x', 1, 1, mesh, color, sock);
3007 anim_move(
'x', 1, 1, mesh, color, sock);
3008 anim_move(
'z', 1, 3, mesh, color, sock);
3009 anim_move(
'x', 1, 3, mesh, color, sock);
3010 anim_move(
'y', 3, 3, mesh, color, sock);
3011 anim_move(
'x', 1, 3, mesh, color, sock);
3012 anim_move(
'y', 3, 1, mesh, color, sock);
3013 anim_move(
'x', 1, 1, mesh, color, sock);
3016 anim_move(
'z', 1, 2, mesh, color, sock);
3017 anim_move(
'y', 3, 1, mesh, color, sock);
3018 anim_move(
'z', 1, 1, mesh, color, sock);
3019 anim_move(
'y', 3, 3, mesh, color, sock);
3020 anim_move(
'x', 1, 3, mesh, color, sock);
3021 anim_move(
'y', 3, 3, mesh, color, sock);
3022 anim_move(
'x', 1, 1, mesh, color, sock);
3023 anim_move(
'y', 3, 1, mesh, color, sock);
3026 anim_move(
'z', 1, 3, mesh, color, sock);
3027 anim_move(
'y', 3, 1, mesh, color, sock);
3028 anim_move(
'z', 1, 1, mesh, color, sock);
3029 anim_move(
'y', 3, 3, mesh, color, sock);
3030 anim_move(
'x', 1, 3, mesh, color, sock);
3031 anim_move(
'y', 3, 3, mesh, color, sock);
3032 anim_move(
'x', 1, 1, mesh, color, sock);
3033 anim_move(
'y', 3, 1, mesh, color, sock);
3042 anim_move(
'y', 3, 1, mesh, color, sock);
3043 anim_move(
'z', 1, 1, mesh, color, sock);
3044 anim_move(
'y', 3, 3, mesh, color, sock);
3045 anim_move(
'x', 1, 3, mesh, color, sock);
3046 anim_move(
'y', 3, 3, mesh, color, sock);
3047 anim_move(
'x', 1, 1, mesh, color, sock);
3048 anim_move(
'y', 3, 1, mesh, color, sock);
3051 anim_move(
'z', 1, 1, mesh, color, sock);
3052 anim_move(
'y', 3, 1, mesh, color, sock);
3053 anim_move(
'z', 1, 1, mesh, color, sock);
3054 anim_move(
'y', 3, 3, mesh, color, sock);
3055 anim_move(
'x', 1, 3, mesh, color, sock);
3056 anim_move(
'y', 3, 3, mesh, color, sock);
3057 anim_move(
'x', 1, 1, mesh, color, sock);
3058 anim_move(
'y', 3, 1, mesh, color, sock);
3061 anim_move(
'z', 1, 1, mesh, color, sock);
3062 anim_move(
'x', 1, 1, mesh, color, sock);
3063 anim_move(
'z', 1, 3, mesh, color, sock);
3064 anim_move(
'x', 1, 3, mesh, color, sock);
3065 anim_move(
'y', 3, 3, mesh, color, sock);
3066 anim_move(
'x', 1, 3, mesh, color, sock);
3067 anim_move(
'y', 3, 1, mesh, color, sock);
3068 anim_move(
'x', 1, 1, mesh, color, sock);
3071 anim_move(
'z', 1, 2, mesh, color, sock);
3072 anim_move(
'x', 1, 1, mesh, color, sock);
3073 anim_move(
'z', 1, 3, mesh, color, sock);
3074 anim_move(
'x', 1, 3, mesh, color, sock);
3075 anim_move(
'y', 3, 3, mesh, color, sock);
3076 anim_move(
'x', 1, 3, mesh, color, sock);
3077 anim_move(
'y', 3, 1, mesh, color, sock);
3078 anim_move(
'x', 1, 1, mesh, color, sock);
3081 anim_move(
'x', 1, 1, mesh, color, sock);
3082 anim_move(
'z', 1, 3, mesh, color, sock);
3083 anim_move(
'x', 1, 3, mesh, color, sock);
3084 anim_move(
'y', 3, 3, mesh, color, sock);
3085 anim_move(
'x', 1, 3, mesh, color, sock);
3086 anim_move(
'y', 3, 1, mesh, color, sock);
3087 anim_move(
'x', 1, 1, mesh, color, sock);
3088 anim_move(
'z', 1, 3, mesh, color, sock);
3089 anim_move(
'x', 1, 1, mesh, color, sock);
3090 anim_move(
'z', 1, 3, mesh, color, sock);
3091 anim_move(
'x', 1, 3, mesh, color, sock);
3092 anim_move(
'y', 3, 3, mesh, color, sock);
3093 anim_move(
'x', 1, 3, mesh, color, sock);
3094 anim_move(
'y', 3, 1, mesh, color, sock);
3095 anim_move(
'x', 1, 1, mesh, color, sock);
3106 cout <<
"Entering solve_top_edges" << endl;
3116 int i4 = max(l4,-1-l4);
3117 int o4 = (l4 >= 0) ? 0 : 1;
3120 cout <<
"Location of 4-th edge: " << i4
3121 <<
" with orientation " << o4 << endl;
3123 if (i4 < 12 && ((i4 < 4) ||
3124 (i4 > 4 && o4 == 0) ||
3134 int i5 = max(l5,-1-l5);
3135 int o5 = (l5 >= 0) ? 0 : 1;
3138 cout <<
"Location of 5-th edge: " << i5
3139 <<
" with orientation " << o5 << endl;
3141 if (i5 < 12 && ((i5 < 4) ||
3142 (i5 > 5 && o5 == 0) ||
3143 (i5 > 4 && o5 == 1) ))
3152 int i6 = max(l6,-1-l6);
3153 int o6 = (l6 >= 0) ? 0 : 1;
3156 cout <<
"Location of 6-th edge: " << i6
3157 <<
" with orientation " << o6 << endl;
3159 if (i6 < 12 && ((i6 < 4) ||
3160 (i6 > 6 && o6 == 0) ||
3161 (i6 > 5 && o6 == 1) ))
3170 int i7 = max(l7,-1-l7);
3171 int o7 = (l7 >= 0) ? 0 : 1;
3174 cout <<
"Location of 7-th edge: " << i7
3175 <<
" with orientation " << o7 << endl;
3177 if (i7 < 12 && ((i7 < 4) ||
3178 (i7 > 7 && o7 == 0) ||
3179 (i7 > 6 && o7 == 1) ))
3191 cout <<
"Entering solve_mid_edges" << endl;
3201 int i8 = max(l8,-1-l8);
3202 int o8 = (l8 >= 0) ? 0 : 1;
3205 cout <<
"Location of 8-th edge: " << i8
3206 <<
" with orientation " << o8 << endl;
3208 if (i8 >= 4 && i8 < 8)
3210 cout <<
"Moving edges from top tier to middle tier is not supported." 3213 else if (i8 < 12 && ((i8 < 4) ||
3214 (i8 > 8 && o8 == 0) ||
3215 (i8 > 7 && o8 == 1) ))
3224 int i9 = max(l9,-1-l9);
3225 int o9 = (l9 >= 0) ? 0 : 1;
3228 cout <<
"Location of 9-th edge: " << i9
3229 <<
" with orientation " << o9 << endl;
3231 if (i9 >= 4 && i9 < 8)
3233 cout <<
"Moving edges from top tier to middle tier is not supported." 3236 else if (i9 < 12 && ((i9 < 4) ||
3237 (i9 > 9 && o9 == 0) ||
3238 (i9 > 8 && o9 == 1) ))
3247 int i10 = max(l10,-1-l10);
3248 int o10 = (l10 >= 0) ? 0 : 1;
3251 cout <<
"Location of 10-th edge: " << i10
3252 <<
" with orientation " << o10 << endl;
3254 if (i10 >= 4 && i10 < 8)
3256 cout <<
"Moving edges from top tier to middle tier is not supported." 3259 else if (i10 < 12 && ((i10 < 4) ||
3260 (i10 > 10 && o10 == 0) ||
3261 (i10 > 9 && o10 == 1) ))
3270 int i11 = max(l11,-1-l11);
3271 int o11 = (l11 >= 0) ? 0 : 1;
3274 cout <<
"Location of 11-th edge: " << i11
3275 <<
" with orientation " << o11 << endl;
3277 if (i11 >= 4 && i11 < 8)
3279 cout <<
"Moving edges from top tier to middle tier is not supported." 3282 else if (i11 < 12 && ((i11 < 4) ||
3283 (i11 > 11 && o11 == 0) ||
3284 (i11 > 10 && o11 == 1) ))
3297 cout <<
"Entering swap_corners" << endl;
3304 for (
int i=0; i<8; i++)
3306 if ((rubik.corn_[3 * i] == c0[0] &&
3307 rubik.corn_[3 * i + 1] == c0[1] &&
3308 rubik.corn_[3 * i + 2] == c0[2]) ||
3309 (rubik.corn_[3 * i] == c0[1] &&
3310 rubik.corn_[3 * i + 1] == c0[2] &&
3311 rubik.corn_[3 * i + 2] == c0[0]) ||
3312 (rubik.corn_[3 * i] == c0[2] &&
3313 rubik.corn_[3 * i + 1] == c0[0] &&
3314 rubik.corn_[3 * i + 2] == c0[1]) ||
3315 (rubik.corn_[3 * i] == c0[2] &&
3316 rubik.corn_[3 * i + 1] == c0[1] &&
3317 rubik.corn_[3 * i + 2] == c0[0]) ||
3318 (rubik.corn_[3 * i] == c0[1] &&
3319 rubik.corn_[3 * i + 1] == c0[0] &&
3320 rubik.corn_[3 * i + 2] == c0[2]) ||
3321 (rubik.corn_[3 * i] == c0[0] &&
3322 rubik.corn_[3 * i + 1] == c0[2] &&
3323 rubik.corn_[3 * i + 2] == c0[1]))
3331 cout <<
"Location of c0 = {"<<c0[0]<<
","<<c0[1]<<
","<<c0[2]<<
"}: " 3343 anim_move(
'z', 1, i0, mesh, color, sock);
3345 anim_move(
'z', 1, 4-i0, mesh, color, sock);
3348 anim_move(
'x', 1, 3, mesh, color, sock);
3350 anim_move(
'x', 1, 1, mesh, color, sock);
3353 anim_move(
'y', 1, 2, mesh, color, sock);
3355 anim_move(
'y', 1, 2, mesh, color, sock);
3358 anim_move(
'z', 3, 2, mesh, color, sock);
3359 anim_move(
'x', 1, 3, mesh, color, sock);
3361 anim_move(
'x', 1, 1, mesh, color, sock);
3362 anim_move(
'z', 3, 2, mesh, color, sock);
3365 anim_move(
'x', 1, 2, mesh, color, sock);
3367 anim_move(
'x', 1, 2, mesh, color, sock);
3371 else if (c1 != NULL)
3375 for (
int i=1; i<8; i++)
3377 if ((rubik.corn_[3 * i] == c1[0] &&
3378 rubik.corn_[3 * i + 1] == c1[1] &&
3379 rubik.corn_[3 * i + 2] == c1[2]) ||
3380 (rubik.corn_[3 * i] == c1[1] &&
3381 rubik.corn_[3 * i + 1] == c1[2] &&
3382 rubik.corn_[3 * i + 2] == c1[0]) ||
3383 (rubik.corn_[3 * i] == c1[2] &&
3384 rubik.corn_[3 * i + 1] == c1[0] &&
3385 rubik.corn_[3 * i + 2] == c1[1]) ||
3386 (rubik.corn_[3 * i] == c1[2] &&
3387 rubik.corn_[3 * i + 1] == c1[1] &&
3388 rubik.corn_[3 * i + 2] == c1[0]) ||
3389 (rubik.corn_[3 * i] == c1[1] &&
3390 rubik.corn_[3 * i + 1] == c1[0] &&
3391 rubik.corn_[3 * i + 2] == c1[2]) ||
3392 (rubik.corn_[3 * i] == c1[0] &&
3393 rubik.corn_[3 * i + 1] == c1[2] &&
3394 rubik.corn_[3 * i + 2] == c1[1]))
3402 cout <<
"Location of piece belonging at " << 0 <<
" (c1) is " 3412 anim_move(
'x', 3, 1, mesh, color, sock);
3414 anim_move(
'x', 3, 3, mesh, color, sock);
3417 anim_move(
'y', 3, 1, mesh, color, sock);
3418 anim_move(
'x', 3, 1, mesh, color, sock);
3420 anim_move(
'x', 3, 3, mesh, color, sock);
3421 anim_move(
'y', 3, 3, mesh, color, sock);
3424 anim_move(
'z', 3, 3, mesh, color, sock);
3425 anim_move(
'x', 3, 3, mesh, color, sock);
3427 anim_move(
'x', 3, 1, mesh, color, sock);
3428 anim_move(
'z', 3, 1, mesh, color, sock);
3431 anim_move(
'x', 3, 3, mesh, color, sock);
3433 anim_move(
'x', 3, 1, mesh, color, sock);
3436 anim_move(
'x', 3, 2, mesh, color, sock);
3438 anim_move(
'x', 3, 2, mesh, color, sock);
3441 anim_move(
'z', 3, 2, mesh, color, sock);
3442 anim_move(
'x', 3, 3, mesh, color, sock);
3444 anim_move(
'x', 3, 1, mesh, color, sock);
3445 anim_move(
'z', 3, 2, mesh, color, sock);
3451 anim_move(
'x', 3, 3, mesh, color, sock);
3452 anim_move(
'z', 1, 1, mesh, color, sock);
3453 anim_move(
'x', 3, 1, mesh, color, sock);
3454 anim_move(
'y', 1, 3, mesh, color, sock);
3455 anim_move(
'z', 1, 3, mesh, color, sock);
3456 anim_move(
'y', 1, 1, mesh, color, sock);
3457 anim_move(
'x', 3, 3, mesh, color, sock);
3458 anim_move(
'z', 1, 3, mesh, color, sock);
3459 anim_move(
'x', 3, 1, mesh, color, sock);
3460 anim_move(
'z', 1, 2, mesh, color, sock);
3469 cout <<
"Entering solve_corner_locations" << endl;
3478 for (
int i=0; i<8; i++)
3480 if (!((rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 0] &&
3481 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 1] &&
3482 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 2]) ||
3483 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 1] &&
3484 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 2] &&
3485 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 0]) ||
3486 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 2] &&
3487 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 0] &&
3488 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 1]) ||
3489 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 2] &&
3490 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 1] &&
3491 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 0]) ||
3492 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 1] &&
3493 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 0] &&
3494 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 2]) ||
3495 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 0] &&
3496 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 2] &&
3497 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 1])))
3505 cout <<
"First incorrectly filled corner location: " << i0 << endl;
3508 if (i0 < 0) {
return; }
3515 cout <<
"Location of piece belonging at " << i0 <<
" is " << i1 << endl;
3520 cout <<
"Invalid configuration of corners" << endl;
3524 int c0[3] = {rubik.corn_[3 * i0],
3525 rubik.corn_[3 * i0 + 1],
3526 rubik.corn_[3 * i0 + 2]
3528 int c1[3] = {rubik.corn_[3 * i1],
3529 rubik.corn_[3 * i1 + 1],
3530 rubik.corn_[3 * i1 + 2]
3544 cout <<
"Entering solve_bot_corner_locations" << endl;
3557 cout <<
"Location of piece belonging at 0 is " << i0 << endl;
3561 anim_move(
'z', 1, i0, mesh, color, sock);
3571 cout <<
"Location of piece belonging at 1 is " << i1 << endl;
3576 cout <<
"Invalid configuration of corners" << endl;
3582 anim_move(
'y', 3, 3, mesh, color, sock);
3583 anim_move(
'z', 1, 1, mesh, color, sock);
3584 anim_move(
'y', 3, 1, mesh, color, sock);
3585 anim_move(
'x', 3, 1, mesh, color, sock);
3586 anim_move(
'z', 1, 3, mesh, color, sock);
3587 anim_move(
'x', 3, 3, mesh, color, sock);
3588 anim_move(
'y', 3, 3, mesh, color, sock);
3589 anim_move(
'z', 1, 3, mesh, color, sock);
3590 anim_move(
'y', 3, 1, mesh, color, sock);
3591 anim_move(
'z', 1, 2, mesh, color, sock);
3594 anim_move(
'y', 3, 3, mesh, color, sock);
3595 anim_move(
'z', 1, 1, mesh, color, sock);
3596 anim_move(
'y', 3, 1, mesh, color, sock);
3597 anim_move(
'x', 3, 1, mesh, color, sock);
3598 anim_move(
'z', 1, 2, mesh, color, sock);
3599 anim_move(
'x', 3, 3, mesh, color, sock);
3600 anim_move(
'y', 3, 3, mesh, color, sock);
3601 anim_move(
'z', 1, 3, mesh, color, sock);
3602 anim_move(
'y', 3, 1, mesh, color, sock);
3603 anim_move(
'z', 1, 3, mesh, color, sock);
3614 cout <<
"Location of piece belonging at 2 is " << i2 << endl;
3619 cout <<
"Invalid configuration of corners" << endl;
3624 anim_move(
'x', 1, 1, mesh, color, sock);
3625 anim_move(
'z', 1, 1, mesh, color, sock);
3626 anim_move(
'x', 1, 3, mesh, color, sock);
3627 anim_move(
'y', 3, 1, mesh, color, sock);
3628 anim_move(
'z', 1, 3, mesh, color, sock);
3629 anim_move(
'y', 3, 3, mesh, color, sock);
3630 anim_move(
'x', 1, 1, mesh, color, sock);
3631 anim_move(
'z', 1, 3, mesh, color, sock);
3632 anim_move(
'x', 1, 3, mesh, color, sock);
3633 anim_move(
'z', 1, 2, mesh, color, sock);
3640 bool cw,
int * c0,
int * c1,
int * c2)
3646 for (
int i=0; i<8; i++)
3648 if ((rubik.corn_[3 * i] == c0[0] &&
3649 rubik.corn_[3 * i + 1] == c0[1] &&
3650 rubik.corn_[3 * i + 2] == c0[2]) ||
3651 (rubik.corn_[3 * i] == c0[1] &&
3652 rubik.corn_[3 * i + 1] == c0[2] &&
3653 rubik.corn_[3 * i + 2] == c0[0]) ||
3654 (rubik.corn_[3 * i] == c0[2] &&
3655 rubik.corn_[3 * i + 1] == c0[0] &&
3656 rubik.corn_[3 * i + 2] == c0[1]) ||
3657 (rubik.corn_[3 * i] == c0[2] &&
3658 rubik.corn_[3 * i + 1] == c0[1] &&
3659 rubik.corn_[3 * i + 2] == c0[0]) ||
3660 (rubik.corn_[3 * i] == c0[1] &&
3661 rubik.corn_[3 * i + 1] == c0[0] &&
3662 rubik.corn_[3 * i + 2] == c0[2]) ||
3663 (rubik.corn_[3 * i] == c0[0] &&
3664 rubik.corn_[3 * i + 1] == c0[2] &&
3665 rubik.corn_[3 * i + 2] == c0[1]))
3673 cout <<
"Location of c0 = {"<<c0[0]<<
","<<c0[1]<<
","<<c0[2]<<
"}: " 3685 anim_move(
'z', 1, i0, mesh, color, sock);
3687 anim_move(
'z', 1, 4-i0, mesh, color, sock);
3690 anim_move(
'x', 1, 3, mesh, color, sock);
3692 anim_move(
'x', 1, 1, mesh, color, sock);
3695 anim_move(
'y', 1, 2, mesh, color, sock);
3697 anim_move(
'y', 1, 2, mesh, color, sock);
3700 anim_move(
'z', 3, 2, mesh, color, sock);
3701 anim_move(
'x', 1, 3, mesh, color, sock);
3703 anim_move(
'x', 1, 1, mesh, color, sock);
3704 anim_move(
'z', 3, 2, mesh, color, sock);
3707 anim_move(
'x', 1, 2, mesh, color, sock);
3709 anim_move(
'x', 1, 2, mesh, color, sock);
3714 else if (c1 != NULL)
3718 for (
int i=1; i<8; i++)
3720 if ((rubik.corn_[3 * i] == c1[0] &&
3721 rubik.corn_[3 * i + 1] == c1[1] &&
3722 rubik.corn_[3 * i + 2] == c1[2]) ||
3723 (rubik.corn_[3 * i] == c1[1] &&
3724 rubik.corn_[3 * i + 1] == c1[2] &&
3725 rubik.corn_[3 * i + 2] == c1[0]) ||
3726 (rubik.corn_[3 * i] == c1[2] &&
3727 rubik.corn_[3 * i + 1] == c1[0] &&
3728 rubik.corn_[3 * i + 2] == c1[1]) ||
3729 (rubik.corn_[3 * i] == c1[2] &&
3730 rubik.corn_[3 * i + 1] == c1[1] &&
3731 rubik.corn_[3 * i + 2] == c1[0]) ||
3732 (rubik.corn_[3 * i] == c1[1] &&
3733 rubik.corn_[3 * i + 1] == c1[0] &&
3734 rubik.corn_[3 * i + 2] == c1[2]) ||
3735 (rubik.corn_[3 * i] == c1[0] &&
3736 rubik.corn_[3 * i + 1] == c1[2] &&
3737 rubik.corn_[3 * i + 2] == c1[1]))
3745 cout <<
"Location of c1 = {"<<c1[0]<<
","<<c1[1]<<
","<<c1[2]<<
"}: " 3757 anim_move(
'x', 3, 1, mesh, color, sock);
3759 anim_move(
'x', 3, 3, mesh, color, sock);
3762 anim_move(
'y', 3, 1, mesh, color, sock);
3763 anim_move(
'x', 3, 1, mesh, color, sock);
3765 anim_move(
'x', 3, 3, mesh, color, sock);
3766 anim_move(
'y', 3, 3, mesh, color, sock);
3769 anim_move(
'z', 3, 3, mesh, color, sock);
3770 anim_move(
'x', 3, 3, mesh, color, sock);
3772 anim_move(
'x', 3, 1, mesh, color, sock);
3773 anim_move(
'z', 3, 1, mesh, color, sock);
3776 anim_move(
'x', 3, 3, mesh, color, sock);
3778 anim_move(
'x', 3, 1, mesh, color, sock);
3781 anim_move(
'x', 3, 2, mesh, color, sock);
3783 anim_move(
'x', 3, 2, mesh, color, sock);
3786 anim_move(
'z', 3, 2, mesh, color, sock);
3787 anim_move(
'x', 3, 3, mesh, color, sock);
3789 anim_move(
'x', 3, 1, mesh, color, sock);
3790 anim_move(
'z', 3, 2, mesh, color, sock);
3802 anim_move(
'y', 3, 3, mesh, color, sock);
3804 anim_move(
'y', 3, 1, mesh, color, sock);
3807 anim_move(
'x', 3, 3, mesh, color, sock);
3808 anim_move(
'y', 3, 3, mesh, color, sock);
3810 anim_move(
'y', 3, 1, mesh, color, sock);
3811 anim_move(
'x', 3, 1, mesh, color, sock);
3814 anim_move(
'z', 3, 1, mesh, color, sock);
3815 anim_move(
'y', 3, 1, mesh, color, sock);
3817 anim_move(
'y', 3, 3, mesh, color, sock);
3818 anim_move(
'z', 3, 3, mesh, color, sock);
3821 anim_move(
'z', 3, 2, mesh, color, sock);
3822 anim_move(
'y', 3, 1, mesh, color, sock);
3824 anim_move(
'y', 3, 3, mesh, color, sock);
3825 anim_move(
'z', 3, 2, mesh, color, sock);
3828 anim_move(
'y', 3, 2, mesh, color, sock);
3830 anim_move(
'y', 3, 2, mesh, color, sock);
3833 anim_move(
'y', 3, 1, mesh, color, sock);
3835 anim_move(
'y', 3, 3, mesh, color, sock);
3840 else if (c2 != NULL)
3844 for (
int i=2; i<8; i++)
3846 if ((rubik.corn_[3 * i] == c2[0] &&
3847 rubik.corn_[3 * i + 1] == c2[1] &&
3848 rubik.corn_[3 * i + 2] == c2[2]) ||
3849 (rubik.corn_[3 * i] == c2[1] &&
3850 rubik.corn_[3 * i + 1] == c2[2] &&
3851 rubik.corn_[3 * i + 2] == c2[0]) ||
3852 (rubik.corn_[3 * i] == c2[2] &&
3853 rubik.corn_[3 * i + 1] == c2[0] &&
3854 rubik.corn_[3 * i + 2] == c2[1]) ||
3855 (rubik.corn_[3 * i] == c2[2] &&
3856 rubik.corn_[3 * i + 1] == c2[1] &&
3857 rubik.corn_[3 * i + 2] == c2[0]) ||
3858 (rubik.corn_[3 * i] == c2[1] &&
3859 rubik.corn_[3 * i + 1] == c2[0] &&
3860 rubik.corn_[3 * i + 2] == c2[2]) ||
3861 (rubik.corn_[3 * i] == c2[0] &&
3862 rubik.corn_[3 * i + 1] == c2[2] &&
3863 rubik.corn_[3 * i + 2] == c2[1]))
3871 cout <<
"Location of c2 = {"<<c2[0]<<
","<<c2[1]<<
","<<c2[2]<<
"}: " 3881 anim_move(
'y', 3, 1, mesh, color, sock);
3883 anim_move(
'y', 3, 3, mesh, color, sock);
3886 anim_move(
'z', 3, 2, mesh, color, sock);
3887 anim_move(
'y', 3, 3, mesh, color, sock);
3889 anim_move(
'y', 3, 1, mesh, color, sock);
3890 anim_move(
'z', 3, 2, mesh, color, sock);
3893 anim_move(
'z', 3, 3, mesh, color, sock);
3894 anim_move(
'y', 3, 3, mesh, color, sock);
3896 anim_move(
'y', 3, 1, mesh, color, sock);
3897 anim_move(
'z', 3, 1, mesh, color, sock);
3900 anim_move(
'y', 3, 3, mesh, color, sock);
3902 anim_move(
'y', 3, 1, mesh, color, sock);
3905 anim_move(
'y', 3, 2, mesh, color, sock);
3907 anim_move(
'y', 3, 2, mesh, color, sock);
3917 cout <<
"twist_corners performing clockwise twist" << endl;
3919 anim_move(
'x', 3, 1, mesh, color, sock);
3920 anim_move(
'z', 1, 3, mesh, color, sock);
3921 anim_move(
'x', 3, 3, mesh, color, sock);
3922 anim_move(
'z', 1, 3, mesh, color, sock);
3923 anim_move(
'x', 3, 1, mesh, color, sock);
3924 anim_move(
'z', 1, 2, mesh, color, sock);
3925 anim_move(
'x', 3, 3, mesh, color, sock);
3926 anim_move(
'z', 1, 2, mesh, color, sock);
3932 cout <<
"twist_corners performing counter-clockwise twist" << endl;
3934 anim_move(
'y', 1, 1, mesh, color, sock);
3935 anim_move(
'z', 1, 1, mesh, color, sock);
3936 anim_move(
'y', 1, 3, mesh, color, sock);
3937 anim_move(
'z', 1, 1, mesh, color, sock);
3938 anim_move(
'y', 1, 1, mesh, color, sock);
3939 anim_move(
'z', 1, 2, mesh, color, sock);
3940 anim_move(
'y', 1, 3, mesh, color, sock);
3941 anim_move(
'z', 1, 2, mesh, color, sock);
3952 cout <<
"Entering solve_corner_orientations" << endl;
3962 for (
int i=0; i<8; i++)
3964 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
3973 cw = rubik.corn_[3 * i0 + 0] == corn_colors_[3 * i0 + 1];
3979 cw = rubik.corn_[3 * i0 + 0] == corn_colors_[3 * i0 + 2];
3986 if (i0 < 0) {
return; }
3990 cout <<
"First incorrectly oriented corner: " << i0 << endl;
3995 for (
int i=i0+1; i<8; i++)
3997 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
4005 cout <<
"Second incorrectly oriented corner: " << i1 << endl;
4011 for (
int i=i1+1; i<8; i++)
4013 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
4023 cout <<
"Third incorrectly oriented corner: " << i2 << endl;
4027 int c0[3] = {rubik.corn_[3 * i0],
4028 rubik.corn_[3 * i0 + 1],
4029 rubik.corn_[3 * i0 + 2]
4031 int c1[3] = {rubik.corn_[3 * i1],
4032 rubik.corn_[3 * i1 + 1],
4033 rubik.corn_[3 * i1 + 2]
4035 int c2[3] = {rubik.corn_[3 * i2],
4036 rubik.corn_[3 * i2 + 1],
4037 rubik.corn_[3 * i2 + 2]
4045 int c0[3] = {rubik.corn_[3 * i0],
4046 rubik.corn_[3 * i0 + 1],
4047 rubik.corn_[3 * i0 + 2]
4049 int c1[3] = {rubik.corn_[3 * i1],
4050 rubik.corn_[3 * i1 + 1],
4051 rubik.corn_[3 * i1 + 2]
4061 int * e0,
int * e1,
int * e2)
4065 cout <<
"Entering permute_edges" << endl;
4072 for (
int i=0; i<12; i++)
4074 if ((rubik.edge_[2 * i] == e0[0] &&
4075 rubik.edge_[2 * i + 1] == e0[1]) ||
4076 (rubik.edge_[2 * i] == e0[1] &&
4077 rubik.edge_[2 * i + 1] == e0[0]))
4085 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4096 anim_move(
'z', 1, i0, mesh, color, sock);
4098 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4101 anim_move(
'x', 2, 3, mesh, color, sock);
4103 anim_move(
'x', 2, 1, mesh, color, sock);
4106 anim_move(
'y', 2, 3, mesh, color, sock);
4108 anim_move(
'y', 2, 1, mesh, color, sock);
4111 anim_move(
'x', 2, 2, mesh, color, sock);
4113 anim_move(
'x', 2, 2, mesh, color, sock);
4116 anim_move(
'y', 2, 1, mesh, color, sock);
4118 anim_move(
'y', 2, 3, mesh, color, sock);
4121 anim_move(
'y', 1, 1, mesh, color, sock);
4123 anim_move(
'y', 1, 3, mesh, color, sock);
4126 anim_move(
'y', 1, 3, mesh, color, sock);
4128 anim_move(
'y', 1, 1, mesh, color, sock);
4131 anim_move(
'x', 3, 1, mesh, color, sock);
4133 anim_move(
'x', 3, 3, mesh, color, sock);
4136 anim_move(
'x', 1, 1, mesh, color, sock);
4138 anim_move(
'x', 1, 3, mesh, color, sock);
4142 else if (e1 != NULL)
4146 for (
int i=1; i<12; i++)
4148 if ((rubik.edge_[2 * i] == e1[0] &&
4149 rubik.edge_[2 * i + 1] == e1[1]) ||
4150 (rubik.edge_[2 * i] == e1[1] &&
4151 rubik.edge_[2 * i + 1] == e1[0]))
4159 cout <<
"Location of piece belonging at " << 0 <<
" (e1) is " 4170 anim_move(
'y', 1, 1, mesh, color, sock);
4171 anim_move(
'z', 1, i1-1, mesh, color, sock);
4172 anim_move(
'y', 1, 3, mesh, color, sock);
4174 anim_move(
'y', 1, 1, mesh, color, sock);
4175 anim_move(
'z', 1, 5-i1, mesh, color, sock);
4176 anim_move(
'y', 1, 3, mesh, color, sock);
4182 anim_move(
'z', 3, (i1-1)%4, mesh, color, sock);
4183 anim_move(
'x', 3, 2, mesh, color, sock);
4185 anim_move(
'x', 3, 2, mesh, color, sock);
4186 anim_move(
'z', 3, (9-i1)%4, mesh, color, sock);
4192 anim_move(
'z', 2, (i1-5)%4, mesh, color, sock);
4193 anim_move(
'x', 3, 3, mesh, color, sock);
4195 anim_move(
'x', 3, 1, mesh, color, sock);
4196 anim_move(
'z', 2, (13-i1)%4, mesh, color, sock);
4200 else if (e2 != NULL)
4204 for (
int i=2; i<12; i++)
4206 if ((rubik.edge_[2 * i] == e2[0] &&
4207 rubik.edge_[2 * i + 1] == e2[1]) ||
4208 (rubik.edge_[2 * i] == e2[1] &&
4209 rubik.edge_[2 * i + 1] == e2[0]))
4217 cout <<
"Location of e2: " << i2 << endl;
4226 anim_move(
'x', 1, 3, mesh, color, sock);
4227 anim_move(
'y', 3, 1, mesh, color, sock);
4229 anim_move(
'y', 3, 3, mesh, color, sock);
4230 anim_move(
'x', 1, 1, mesh, color, sock);
4236 anim_move(
'z', 3, (i2-2)%4, mesh, color, sock);
4237 anim_move(
'y', 3, 2, mesh, color, sock);
4239 anim_move(
'y', 3, 2, mesh, color, sock);
4240 anim_move(
'z', 3, (10-i2)%4, mesh, color, sock);
4246 anim_move(
'z', 2, (i2-6)%4, mesh, color, sock);
4247 anim_move(
'y', 3, 3, mesh, color, sock);
4249 anim_move(
'y', 3, 1, mesh, color, sock);
4250 anim_move(
'z', 2, (14-i2)%4, mesh, color, sock);
4265 anim_move(
'y', 2, 1, mesh, color, sock);
4266 anim_move(
'z', 1, 1, mesh, color, sock);
4267 anim_move(
'y', 2, 3, mesh, color, sock);
4268 anim_move(
'z', 1, 2, mesh, color, sock);
4269 anim_move(
'y', 2, 1, mesh, color, sock);
4270 anim_move(
'z', 1, 1, mesh, color, sock);
4271 anim_move(
'y', 2, 3, mesh, color, sock);
4275 anim_move(
'y', 2, 1, mesh, color, sock);
4276 anim_move(
'z', 1, 3, mesh, color, sock);
4277 anim_move(
'y', 2, 3, mesh, color, sock);
4278 anim_move(
'z', 1, 2, mesh, color, sock);
4279 anim_move(
'y', 2, 1, mesh, color, sock);
4280 anim_move(
'z', 1, 3, mesh, color, sock);
4281 anim_move(
'y', 2, 3, mesh, color, sock);
4290 cout <<
"Entering solve_edge_locations" << endl;
4299 for (
int i=0; i<12; i++)
4301 if (!((rubik.edge_[2 * i] == edge_colors_[2 * i] &&
4302 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 1]) ||
4303 (rubik.edge_[2 * i] == edge_colors_[2 * i + 1] &&
4304 rubik.edge_[2 * i + 1] == edge_colors_[2 * i])))
4312 cout <<
"First incorrectly filled edge location: " << i0 << endl;
4315 if (i0 < 0) {
return; }
4319 if (i1 < 0 ) { i1 = -1 - i1; }
4322 cout <<
"Location of piece belonging at " << i0 <<
" is " << i1 << endl;
4327 for (
int i=i0+1; i<12; i++)
4329 if (i == i1) {
continue; }
4330 if (!((rubik.edge_[2 * i + 0] == edge_colors_[2 * i + 0] &&
4331 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 1]) ||
4332 (rubik.edge_[2 * i + 0] == edge_colors_[2 * i + 1] &&
4333 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 0])))
4341 cout <<
"Another incorrectly filled edge location: " << i2 << endl;
4344 if (i1 < 0 || i2 <0)
4346 cout <<
"Invalid configuration of edges" << endl;
4350 int e0[2] = {rubik.edge_[2 * i0], rubik.edge_[2 * i0 + 1]};
4351 int e1[2] = {rubik.edge_[2 * i1], rubik.edge_[2 * i1 + 1]};
4352 int e2[2] = {rubik.edge_[2 * i2], rubik.edge_[2 * i2 + 1]};
4361 int n,
int * e0,
int * e1,
int * e2,
int * e3)
4369 for (
int i=0; i<12; i++)
4371 if ((rubik.edge_[2 * i] == e0[0] &&
4372 rubik.edge_[2 * i + 1] == e0[1]) ||
4373 (rubik.edge_[2 * i] == e0[1] &&
4374 rubik.edge_[2 * i + 1] == e0[0]))
4382 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4393 anim_move(
'z', 1, i0, mesh, color, sock);
4395 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4398 anim_move(
'x', 2, 3, mesh, color, sock);
4400 anim_move(
'x', 2, 1, mesh, color, sock);
4403 anim_move(
'y', 2, 3, mesh, color, sock);
4405 anim_move(
'y', 2, 1, mesh, color, sock);
4408 anim_move(
'x', 2, 2, mesh, color, sock);
4410 anim_move(
'x', 2, 2, mesh, color, sock);
4413 anim_move(
'y', 2, 1, mesh, color, sock);
4415 anim_move(
'y', 2, 3, mesh, color, sock);
4418 anim_move(
'y', 1, 1, mesh, color, sock);
4420 anim_move(
'y', 1, 3, mesh, color, sock);
4423 anim_move(
'y', 1, 3, mesh, color, sock);
4425 anim_move(
'y', 1, 1, mesh, color, sock);
4428 anim_move(
'x', 3, 1, mesh, color, sock);
4430 anim_move(
'x', 3, 3, mesh, color, sock);
4433 anim_move(
'x', 1, 1, mesh, color, sock);
4435 anim_move(
'x', 1, 3, mesh, color, sock);
4439 else if (e1 != NULL)
4443 for (
int i=1; i<12; i++)
4445 if ((rubik.edge_[2 * i] == e1[0] &&
4446 rubik.edge_[2 * i + 1] == e1[1]) ||
4447 (rubik.edge_[2 * i] == e1[1] &&
4448 rubik.edge_[2 * i + 1] == e1[0]))
4456 cout <<
"Location of e1: " << i1 << endl;
4462 anim_move(
'x', 3, 3, mesh, color, sock);
4463 anim_move(
'y', 3, 3, mesh, color, sock);
4464 flip_edges(mesh, color, sock, 2, NULL, NULL);
4465 anim_move(
'y', 3, 1, mesh, color, sock);
4466 anim_move(
'x', 3, 1, mesh, color, sock);
4469 flip_edges(mesh, color, sock, 2, NULL, NULL);
4472 anim_move(
'x', 1, 3, mesh, color, sock);
4473 anim_move(
'y', 3, 1, mesh, color, sock);
4474 flip_edges(mesh, color, sock, 2, NULL, NULL);
4475 anim_move(
'y', 3, 3, mesh, color, sock);
4476 anim_move(
'x', 1, 1, mesh, color, sock);
4482 anim_move(
'z', 3, (i1-2)%4, mesh, color, sock);
4483 anim_move(
'y', 3, 2, mesh, color, sock);
4484 flip_edges(mesh, color, sock, 2, NULL, NULL);
4485 anim_move(
'y', 3, 2, mesh, color, sock);
4486 anim_move(
'z', 3, (10-i1)%4, mesh, color, sock);
4492 anim_move(
'z', 2, (i1-6)%4, mesh, color, sock);
4493 anim_move(
'y', 3, 3, mesh, color, sock);
4494 flip_edges(mesh, color, sock, 2, NULL, NULL);
4495 anim_move(
'y', 3, 1, mesh, color, sock);
4496 anim_move(
'z', 2, (14-i1)%4, mesh, color, sock);
4502 anim_move(
'x', 2, 3, mesh, color, sock);
4503 anim_move(
'z', 1, 3, mesh, color, sock);
4504 anim_move(
'x', 2, 1, mesh, color, sock);
4505 anim_move(
'z', 1, 3, mesh, color, sock);
4506 anim_move(
'x', 2, 3, mesh, color, sock);
4507 anim_move(
'z', 1, 3, mesh, color, sock);
4508 anim_move(
'x', 2, 1, mesh, color, sock);
4509 anim_move(
'z', 1, 3, mesh, color, sock);
4510 anim_move(
'x', 2, 3, mesh, color, sock);
4511 anim_move(
'z', 1, 2, mesh, color, sock);
4512 anim_move(
'x', 2, 1, mesh, color, sock);
4513 anim_move(
'z', 1, 3, mesh, color, sock);
4514 anim_move(
'x', 2, 3, mesh, color, sock);
4515 anim_move(
'z', 1, 3, mesh, color, sock);
4516 anim_move(
'x', 2, 1, mesh, color, sock);
4517 anim_move(
'z', 1, 3, mesh, color, sock);
4518 anim_move(
'x', 2, 3, mesh, color, sock);
4519 anim_move(
'z', 1, 3, mesh, color, sock);
4520 anim_move(
'x', 2, 1, mesh, color, sock);
4521 anim_move(
'z', 1, 2, mesh, color, sock);
4530 for (
int i=0; i<12; i++)
4532 if ((rubik.edge_[2 * i] == e0[0] &&
4533 rubik.edge_[2 * i + 1] == e0[1]) ||
4534 (rubik.edge_[2 * i] == e0[1] &&
4535 rubik.edge_[2 * i + 1] == e0[0]))
4543 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4549 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4554 anim_move(
'z', 1, i0, mesh, color, sock);
4555 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4556 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4559 anim_move(
'x', 2, 3, mesh, color, sock);
4560 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4561 anim_move(
'x', 2, 1, mesh, color, sock);
4564 anim_move(
'y', 2, 3, mesh, color, sock);
4565 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4566 anim_move(
'y', 2, 1, mesh, color, sock);
4569 anim_move(
'x', 2, 2, mesh, color, sock);
4570 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4571 anim_move(
'x', 2, 2, mesh, color, sock);
4574 anim_move(
'y', 2, 1, mesh, color, sock);
4575 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4576 anim_move(
'y', 2, 3, mesh, color, sock);
4579 anim_move(
'y', 1, 1, mesh, color, sock);
4580 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4581 anim_move(
'y', 1, 3, mesh, color, sock);
4584 anim_move(
'y', 1, 3, mesh, color, sock);
4585 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4586 anim_move(
'y', 1, 1, mesh, color, sock);
4589 anim_move(
'x', 3, 1, mesh, color, sock);
4590 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4591 anim_move(
'x', 3, 3, mesh, color, sock);
4594 anim_move(
'x', 1, 1, mesh, color, sock);
4595 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4596 anim_move(
'x', 1, 3, mesh, color, sock);
4600 else if (e1 != NULL)
4604 for (
int i=1; i<12; i++)
4606 if ((rubik.edge_[2 * i] == e1[0] &&
4607 rubik.edge_[2 * i + 1] == e1[1]) ||
4608 (rubik.edge_[2 * i] == e1[1] &&
4609 rubik.edge_[2 * i + 1] == e1[0]))
4617 cout <<
"Location of e1: " << i1 << endl;
4623 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4626 anim_move(
'y', 3, 1, mesh, color, sock);
4627 anim_move(
'x', 3, 1, mesh, color, sock);
4628 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4629 anim_move(
'x', 3, 3, mesh, color, sock);
4630 anim_move(
'y', 3, 3, mesh, color, sock);
4633 anim_move(
'y', 2, 1, mesh, color, sock);
4634 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4635 anim_move(
'y', 2, 3, mesh, color, sock);
4641 anim_move(
'z', 3, (i1-1)%4, mesh, color, sock);
4642 anim_move(
'x', 3, 2, mesh, color, sock);
4643 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4644 anim_move(
'x', 3, 2, mesh, color, sock);
4645 anim_move(
'z', 3, (9-i1)%4, mesh, color, sock);
4651 anim_move(
'z', 2, (i1-5)%4, mesh, color, sock);
4652 anim_move(
'x', 3, 3, mesh, color, sock);
4653 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4654 anim_move(
'x', 3, 1, mesh, color, sock);
4655 anim_move(
'z', 2, (13-i1)%4, mesh, color, sock);
4659 else if (e2 != NULL)
4663 for (
int i=2; i<12; i++)
4665 if ((rubik.edge_[2 * i] == e2[0] &&
4666 rubik.edge_[2 * i + 1] == e2[1]) ||
4667 (rubik.edge_[2 * i] == e2[1] &&
4668 rubik.edge_[2 * i + 1] == e2[0]))
4676 cout <<
"Location of e2: " << i2 << endl;
4682 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4685 anim_move(
'x', 1, 3, mesh, color, sock);
4686 anim_move(
'y', 3, 1, mesh, color, sock);
4687 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4688 anim_move(
'y', 3, 3, mesh, color, sock);
4689 anim_move(
'x', 1, 1, mesh, color, sock);
4695 anim_move(
'z', 3, (i2-2)%4, mesh, color, sock);
4696 anim_move(
'y', 3, 2, mesh, color, sock);
4697 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4698 anim_move(
'y', 3, 2, mesh, color, sock);
4699 anim_move(
'z', 3, (10-i2)%4, mesh, color, sock);
4705 anim_move(
'z', 2, (i2-6)%4, mesh, color, sock);
4706 anim_move(
'y', 3, 3, mesh, color, sock);
4707 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4708 anim_move(
'y', 3, 1, mesh, color, sock);
4709 anim_move(
'z', 2, (14-i2)%4, mesh, color, sock);
4713 else if (e3 != NULL)
4717 for (
int i=3; i<12; i++)
4719 if ((rubik.edge_[2 * i] == e3[0] &&
4720 rubik.edge_[2 * i + 1] == e3[1]) ||
4721 (rubik.edge_[2 * i] == e3[1] &&
4722 rubik.edge_[2 * i + 1] == e3[0]))
4730 cout <<
"Location of e3: " << i3 << endl;
4736 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4742 anim_move(
'z', 3, (i3-3)%4, mesh, color, sock);
4743 anim_move(
'x', 1, 2, mesh, color, sock);
4744 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4745 anim_move(
'x', 1, 2, mesh, color, sock);
4746 anim_move(
'z', 3, (7-i3)%4, mesh, color, sock);
4752 anim_move(
'z', 2, (i3-4)%4, mesh, color, sock);
4753 anim_move(
'x', 1, 3, mesh, color, sock);
4754 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4755 anim_move(
'x', 1, 1, mesh, color, sock);
4756 anim_move(
'z', 2, (12-i3)%4, mesh, color, sock);
4762 anim_move(
'x', 2, 3, mesh, color, sock);
4763 anim_move(
'z', 1, 2, mesh, color, sock);
4764 anim_move(
'x', 2, 1, mesh, color, sock);
4765 anim_move(
'z', 1, 2, mesh, color, sock);
4766 anim_move(
'x', 2, 3, mesh, color, sock);
4767 anim_move(
'z', 1, 3, mesh, color, sock);
4768 anim_move(
'x', 2, 1, mesh, color, sock);
4769 anim_move(
'z', 1, 2, mesh, color, sock);
4770 anim_move(
'x', 2, 3, mesh, color, sock);
4771 anim_move(
'z', 1, 2, mesh, color, sock);
4772 anim_move(
'x', 2, 1, mesh, color, sock);
4773 anim_move(
'z', 1, 1, mesh, color, sock);
4783 cout <<
"Entering solve_edge_orientations" << endl;
4792 for (
int i=0; i<12; i++)
4794 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4802 cout <<
"First incorrectly oriented edge location: " << i0 << endl;
4805 if (i0 < 0) {
return; }
4809 for (
int i=i0+1; i<12; i++)
4811 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4819 cout <<
"Second incorrectly oriented edge location: " << i1 << endl;
4825 for (
int i=i1+1; i<12; i++)
4827 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4837 cout <<
"Third incorrectly oriented edge location: " << i2 << endl;
4841 for (
int i=i2+1; i<12; i++)
4843 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4851 cout <<
"Fourth incorrectly oriented edge location: " << i3 << endl;
4855 int e0[2] = {rubik.edge_[2 * i0], rubik.edge_[2 * i0 + 1]};
4856 int e1[2] = {rubik.edge_[2 * i1], rubik.edge_[2 * i1 + 1]};
4857 int e2[2] = {rubik.edge_[2 * max(i2,0)], rubik.edge_[2 * max(i2,0) + 1]};
4858 int e3[2] = {rubik.edge_[2 * max(i3,0)], rubik.edge_[2 * max(i3,0) + 1]};
4866 flip_edges(mesh, color, sock, 4, e0, e1, e2, e3);
4878 cout <<
"Solving top center block..." << endl;
4883 cout <<
"Solving top tier edges..." << endl;
4888 cout <<
"Solving center blocks..." << endl;
4892 cout <<
"Solving top tier corners..." << endl;
4896 cout <<
"Move count: " << count_ << endl;
4905 cout <<
"Solving center blocks in the middle tier..." << endl;
4910 cout <<
"Solving edge blocks in the middle tier..." << endl;
4914 cout <<
"Move count: " << count_ << endl;
4922 cout <<
"Solving corner block locations in the bottom tier..." << endl;
4927 cout <<
"Solving corner block orientations..." << endl;
4932 cout <<
"Solving edge block locations..." << endl;
4937 cout <<
"Solving edge block orientations..." << endl;
4948 cout <<
"Solving top center block..." << endl;
4953 cout <<
"Solving top tier edges..." << endl;
4958 cout <<
"Solving top tier corners..." << endl;
4963 cout <<
"Solving center blocks in the middle tier..." << endl;
4968 cout <<
"Solving edge blocks in the middle tier..." << endl;
4973 cout <<
"Solving corner block locations in the bottom tier..." << endl;
4978 cout <<
"Solving corner block orientations..." << endl;
4983 cout <<
"Solving edge block locations..." << endl;
4988 cout <<
"Solving edge block orientations..." << endl;
4992 cout <<
"Move count: " << count_ << endl;
void move_to_e7(int i7, int o7, Mesh &mesh, GridFunction &color, socketstream &sock)
void solve(Mesh &mesh, GridFunction &color, socketstream &sock)
int locate_corner(int ind)
bool validate_centers(const int max_ind=6)
void move_to_e8(int i8, int o8, Mesh &mesh, GridFunction &color, socketstream &sock)
void print_state(ostream &out)
Class for grid function - Vector with associated FE space.
void move_to_e10(int i10, int o10, Mesh &mesh, GridFunction &color, socketstream &sock)
void PrintOptions(std::ostream &out) const
Print the options.
void update_centers(char axis, int incr)
int main(int argc, char *argv[])
void solve_edge_orientations(Mesh &mesh, GridFunction &color, socketstream &sock)
void PrintUsage(std::ostream &out) const
Print the usage message.
bool validate_edges(const int max_ind=12)
void move_to_c7(int i7, int o7, Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_mid(Mesh &mesh, GridFunction &color, socketstream &sock)
void move_to_c4(int i4, int o4, Mesh &mesh, GridFunction &color, socketstream &sock)
void GetBdrElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of boundary element i.
bool Good() const
Return true if the command line options were parsed successfully.
void move_to_e5(int i5, int o5, Mesh &mesh, GridFunction &color, socketstream &sock)
int GetNBE() const
Returns number of boundary elements.
void permute_edges(Mesh &mesh, GridFunction &color, socketstream &sock, int *e0, int *e1, int *e2)
int GetAttribute(int i) const
Return the attribute of element i.
void solve_edge_locations(Mesh &mesh, GridFunction &color, socketstream &sock)
int AddVertex(double x, double y=0.0, double z=0.0)
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void update_edges(char axis, int tier, int incr)
void move_to_e4(int i4, int o4, Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_centers(Mesh &mesh, GridFunction &color, socketstream &sock)
const double * GetVertex(int i) const
Return pointer to vertex i's coordinates.
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
void anim_move(char axis, int tier, int increment, Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_top(Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_corner_orientations(Mesh &mesh, GridFunction &color, socketstream &sock)
void init_hex_mesh(Mesh &mesh)
void solve_bot_corner_locations(Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_corner_locations(Mesh &mesh, GridFunction &color, socketstream &sock)
void update_corners(char axis, int tier, int incr)
void move_to_c6(int i6, int o6, Mesh &mesh, GridFunction &color, socketstream &sock)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
int AddHex(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int attr=1)
void flip_edges(Mesh &mesh, GridFunction &color, socketstream &sock, int n, int *e0=NULL, int *e1=NULL, int *e2=NULL, int *e3=NULL)
void FinalizeTopology(bool generate_bdr=true)
Finalize the construction of the secondary topology (connectivity) data of a Mesh.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
void move_to_e6(int i6, int o6, Mesh &mesh, GridFunction &color, socketstream &sock)
void swap_corners(Mesh &mesh, GridFunction &color, socketstream &sock, int *c0=NULL, int *c1=NULL)
void rotate_step(char axis, int incr, double *x)
int GetNE() const
Returns number of elements.
void solve_top_edges(Mesh &mesh, GridFunction &color, socketstream &sock)
A piecewise constant coefficient with the constants keyed off the element attribute numbers...
void mark_elements(Mesh &mesh, char axis, int tier)
void solve_bot(Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_top_corners(Mesh &mesh, GridFunction &color, socketstream &sock)
void determine_random_moves(Array< Move > &moves)
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void twist_corners(Mesh &mesh, GridFunction &color, socketstream &sock, bool cw, int *c0=NULL, int *c1=NULL, int *c2=NULL)
int Size() const
Return the logical size of the array.
void SetAttribute(int i, int attr)
Set the attribute of element i.
void move_to_c5(int i5, int o5, Mesh &mesh, GridFunction &color, socketstream &sock)
virtual void Print(std::ostream &os=mfem::out) const
bool anim_step(char axis, int incr, Mesh &mesh)
void repaint_cube(Mesh &mesh, GridFunction &color, socketstream &sock)
bool validate_corners(const int max_ind=8)
void move_to_e9(int i9, int o9, Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_top_center(Mesh &mesh, GridFunction &color, socketstream &sock)
void solve_mid_edges(Mesh &mesh, GridFunction &color, socketstream &sock)
void move_to_e11(int i11, int o11, Mesh &mesh, GridFunction &color, socketstream &sock)
void GetBdrElementAdjacentElement(int bdr_el, int &el, int &info) const
For the given boundary element, bdr_el, return its adjacent element and its info, i...
void update_state(char axis, int tier, int incr)
Arbitrary order "L2-conforming" discontinuous finite elements.