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++)
1110 for (
int i=0; i<mesh.
GetNE(); i++)
1115 for (
int j=0; j<v.
Size(); j++)
1125 if ( x[0] > -2.5 + tier && x[0] < -1.5 + tier )
1135 if ( x[1] > -2.5 + tier && x[1] < -1.5 + tier )
1145 if ( x[2] > -2.5 + tier && x[2] < -1.5 + tier )
1166 sock <<
"solution\n" << mesh << color << flush;
1173 for (
int i=0; i<moves.
Size(); i++)
1175 double ran = double(rand()) / RAND_MAX;
1176 int ir = (int)(26 * ran);
1177 int incr = (ir % 3) + 1; ir /= 3;
1178 int tier = (ir % 3) + 1; ir /= 3;
1179 char axis = (ir == 0)?
'x' : ((ir == 1) ?
'y' :
'z');
1183 moves[i].axis = axis;
1184 moves[i].tier = tier;
1185 moves[i].incr = incr;
1187 else if (axis == moves[i-1].axis)
1189 if (tier == moves[i-1].tier)
1191 int new_incr = (moves[i-1].incr + incr) % 4;
1194 moves[i-1].incr = new_incr;
1198 else if (incr == moves[i-1].incr)
1200 moves[i-1].tier = 6 - moves[i-1].tier - tier;
1201 moves[i-1].incr = 4 - incr;
1207 moves[i].axis = axis;
1208 moves[i].tier = tier;
1209 moves[i].incr = incr;
1218 for (
int i=0; i<6; i++)
1220 if (rubik.cent_[i] == 5)
1229 anim_move(
'x', 2, 2, mesh, color, sock);
1232 anim_move(
'x', 2, 1, mesh, color, sock);
1235 anim_move(
'y', 2, 1, mesh, color, sock);
1238 anim_move(
'x', 2, 3, mesh, color, sock);
1241 anim_move(
'y', 2, 3, mesh, color, sock);
1254 bool allWrong =
true;
1255 bool allRight =
true;
1256 for (
int i=0; i<6; i++)
1258 if (rubik.cent_[i] == i)
1269 if (allRight) {
return; }
1277 if (rubik.cent_[2] == 2)
1281 switch (rubik.cent_[0])
1294 else if (rubik.cent_[1] == 1)
1298 switch (rubik.cent_[0])
1315 switch (rubik.cent_[1])
1328 anim_move(axis, 2, incr, mesh, color, sock);
1334 for (
int i=1; i<6; i++)
1336 if (rubik.cent_[i] == 0)
1348 axis =
'x'; incr = 3;
1351 axis =
'y'; incr = 3;
1354 axis =
'x'; incr = 1;
1357 axis =
'y'; incr = 1;
1360 axis =
'x'; incr = 2;
1363 anim_move(axis, 2, incr, mesh, color, sock);
1373 for (
int i=0; i<8; i++)
1375 if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 0] &&
1376 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 1] &&
1377 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 2])
1381 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 1] &&
1382 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 2] &&
1383 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 0])
1387 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 2] &&
1388 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 0] &&
1389 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 1])
1393 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 2] &&
1394 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 1] &&
1395 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 0])
1399 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 1] &&
1400 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 0] &&
1401 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 2])
1405 else if (rubik.corn_[3 * i + 0] == corn_colors_[3 * ind + 0] &&
1406 rubik.corn_[3 * i + 1] == corn_colors_[3 * ind + 2] &&
1407 rubik.corn_[3 * i + 2] == corn_colors_[3 * ind + 1])
1425 anim_move(
'x', 1, 3, mesh, color, sock);
1426 anim_move(
'z', 1, 3, mesh, color, sock);
1427 anim_move(
'x', 1, 1, mesh, color, sock);
1430 anim_move(
'y', 1, 1, mesh, color, sock);
1431 anim_move(
'z', 1, 3, mesh, color, sock);
1432 anim_move(
'y', 1, 3, mesh, color, sock);
1433 anim_move(
'x', 1, 3, mesh, color, sock);
1434 anim_move(
'z', 1, 2, mesh, color, sock);
1435 anim_move(
'x', 1, 1, mesh, color, sock);
1438 anim_move(
'y', 1, 1, mesh, color, sock);
1439 anim_move(
'z', 1, 1, mesh, color, sock);
1440 anim_move(
'y', 1, 3, mesh, color, sock);
1448 anim_move(
'x', 2, 1, mesh, color, sock);
1449 anim_move(
'y', 1, 2, mesh, color, sock);
1450 anim_move(
'x', 2, 3, mesh, color, sock);
1453 anim_move(
'z', 1, 1, mesh, color, sock);
1454 anim_move(
'x', 2, 1, mesh, color, sock);
1455 anim_move(
'y', 1, 3, mesh, color, sock);
1456 anim_move(
'x', 2, 3, mesh, color, sock);
1459 anim_move(
'x', 1, 3, mesh, color, sock);
1460 anim_move(
'z', 1, 1, mesh, color, sock);
1461 anim_move(
'x', 1, 1, mesh, color, sock);
1469 anim_move(
'y', 1, 1, mesh, color, sock);
1470 anim_move(
'z', 1, 2, mesh, color, sock);
1471 anim_move(
'y', 1, 3, mesh, color, sock);
1474 anim_move(
'x', 3, 1, mesh, color, sock);
1475 anim_move(
'z', 1, 1, mesh, color, sock);
1476 anim_move(
'x', 3, 3, mesh, color, sock);
1477 anim_move(
'x', 2, 1, mesh, color, sock);
1478 anim_move(
'y', 1, 3, mesh, color, sock);
1479 anim_move(
'x', 2, 3, mesh, color, sock);
1482 anim_move(
'x', 1, 3, mesh, color, sock);
1483 anim_move(
'z', 1, 2, mesh, color, sock);
1484 anim_move(
'x', 1, 1, mesh, color, sock);
1492 anim_move(
'y', 2, 3, mesh, color, sock);
1493 anim_move(
'x', 1, 2, mesh, color, sock);
1494 anim_move(
'y', 2, 1, mesh, color, sock);
1497 anim_move(
'y', 1, 1, mesh, color, sock);
1498 anim_move(
'z', 1, 3, mesh, color, sock);
1499 anim_move(
'y', 1, 3, mesh, color, sock);
1502 anim_move(
'z', 1, 3, mesh, color, sock);
1503 anim_move(
'y', 1, 1, mesh, color, sock);
1504 anim_move(
'z', 1, 1, mesh, color, sock);
1505 anim_move(
'y', 1, 3, mesh, color, sock);
1513 anim_move(
'y', 1, 1, mesh, color, sock);
1514 anim_move(
'z', 1, 1, mesh, color, sock);
1515 anim_move(
'y', 1, 3, mesh, color, sock);
1516 anim_move(
'z', 1, 3, mesh, color, sock);
1517 anim_move(
'y', 1, 1, mesh, color, sock);
1518 anim_move(
'z', 1, 1, mesh, color, sock);
1519 anim_move(
'y', 1, 3, mesh, color, sock);
1522 anim_move(
'x', 1, 3, mesh, color, sock);
1523 anim_move(
'z', 1, 3, mesh, color, sock);
1524 anim_move(
'x', 1, 1, mesh, color, sock);
1525 anim_move(
'z', 1, 1, mesh, color, sock);
1526 anim_move(
'x', 1, 3, mesh, color, sock);
1527 anim_move(
'z', 1, 3, mesh, color, sock);
1528 anim_move(
'x', 1, 1, mesh, color, sock);
1536 anim_move(
'x', 2, 1, mesh, color, sock);
1537 anim_move(
'y', 1, 1, mesh, color, sock);
1538 anim_move(
'x', 2, 3, mesh, color, sock);
1541 anim_move(
'x', 3, 3, mesh, color, sock);
1542 anim_move(
'z', 1, 1, mesh, color, sock);
1543 anim_move(
'x', 3, 1, mesh, color, sock);
1544 anim_move(
'x', 1, 3, mesh, color, sock);
1545 anim_move(
'z', 1, 3, mesh, color, sock);
1546 anim_move(
'x', 1, 1, mesh, color, sock);
1549 anim_move(
'y', 1, 3, mesh, color, sock);
1550 anim_move(
'z', 1, 3, mesh, color, sock);
1551 anim_move(
'y', 1, 2, mesh, color, sock);
1552 anim_move(
'z', 1, 2, mesh, color, sock);
1553 anim_move(
'y', 1, 3, mesh, color, sock);
1561 anim_move(
'y', 1, 1, mesh, color, sock);
1562 anim_move(
'y', 3, 3, mesh, color, sock);
1563 anim_move(
'z', 1, 2, mesh, color, sock);
1564 anim_move(
'y', 3, 1, mesh, color, sock);
1565 anim_move(
'y', 1, 3, mesh, color, sock);
1568 anim_move(
'x', 3, 1, mesh, color, sock);
1569 anim_move(
'z', 1, 1, mesh, color, sock);
1570 anim_move(
'x', 3, 3, mesh, color, sock);
1571 anim_move(
'x', 1, 3, mesh, color, sock);
1572 anim_move(
'z', 1, 2, mesh, color, sock);
1573 anim_move(
'x', 1, 1, mesh, color, sock);
1576 anim_move(
'y', 3, 3, mesh, color, sock);
1577 anim_move(
'z', 1, 3, mesh, color, sock);
1578 anim_move(
'y', 3, 1, mesh, color, sock);
1579 anim_move(
'y', 1, 1, mesh, color, sock);
1580 anim_move(
'z', 1, 2, mesh, color, sock);
1581 anim_move(
'y', 1, 3, mesh, color, sock);
1589 anim_move(
'x', 1, 1, mesh, color, sock);
1590 anim_move(
'z', 1, 1, mesh, color, sock);
1591 anim_move(
'x', 1, 2, mesh, color, sock);
1592 anim_move(
'z', 1, 2, mesh, color, sock);
1593 anim_move(
'x', 1, 1, mesh, color, sock);
1596 anim_move(
'y', 3, 1, mesh, color, sock);
1597 anim_move(
'z', 1, 3, mesh, color, sock);
1598 anim_move(
'y', 3, 3, mesh, color, sock);
1599 anim_move(
'y', 1, 1, mesh, color, sock);
1600 anim_move(
'z', 1, 1, mesh, color, sock);
1601 anim_move(
'y', 1, 3, mesh, color, sock);
1604 anim_move(
'y', 2, 3, mesh, color, sock);
1605 anim_move(
'x', 1, 3, mesh, color, sock);
1606 anim_move(
'y', 2, 1, mesh, color, sock);
1623 anim_move(
'z', 1, 2, mesh, color, sock);
1624 anim_move(
'y', 2, 1, mesh, color, sock);
1625 anim_move(
'x', 3, 2, mesh, color, sock);
1626 anim_move(
'y', 2, 3, mesh, color, sock);
1629 anim_move(
'z', 1, 3, mesh, color, sock);
1630 anim_move(
'x', 3, 3, mesh, color, sock);
1631 anim_move(
'z', 1, 1, mesh, color, sock);
1632 anim_move(
'x', 3, 1, mesh, color, sock);
1635 anim_move(
'x', 3, 3, mesh, color, sock);
1636 anim_move(
'z', 1, 3, mesh, color, sock);
1637 anim_move(
'x', 3, 1, mesh, color, sock);
1645 anim_move(
'x', 3, 3, mesh, color, sock);
1646 anim_move(
'z', 1, 1, mesh, color, sock);
1647 anim_move(
'x', 3, 1, mesh, color, sock);
1650 anim_move(
'y', 1, 3, mesh, color, sock);
1651 anim_move(
'z', 1, 1, mesh, color, sock);
1652 anim_move(
'y', 1, 1, mesh, color, sock);
1653 anim_move(
'x', 3, 3, mesh, color, sock);
1654 anim_move(
'z', 1, 2, mesh, color, sock);
1655 anim_move(
'x', 3, 1, mesh, color, sock);
1658 anim_move(
'y', 1, 3, mesh, color, sock);
1659 anim_move(
'z', 1, 3, mesh, color, sock);
1660 anim_move(
'y', 1, 1, mesh, color, sock);
1668 anim_move(
'y', 2, 1, mesh, color, sock);
1669 anim_move(
'x', 3, 2, mesh, color, sock);
1670 anim_move(
'y', 2, 3, mesh, color, sock);
1673 anim_move(
'y', 1, 3, mesh, color, sock);
1674 anim_move(
'z', 1, 1, mesh, color, sock);
1675 anim_move(
'y', 1, 1, mesh, color, sock);
1678 anim_move(
'z', 1, 1, mesh, color, sock);
1679 anim_move(
'y', 2, 1, mesh, color, sock);
1680 anim_move(
'x', 3, 1, mesh, color, sock);
1681 anim_move(
'y', 2, 3, mesh, color, sock);
1689 anim_move(
'y', 1, 3, mesh, color, sock);
1690 anim_move(
'z', 1, 2, mesh, color, sock);
1691 anim_move(
'y', 1, 1, mesh, color, sock);
1694 anim_move(
'z', 1, 1, mesh, color, sock);
1695 anim_move(
'y', 2, 1, mesh, color, sock);
1696 anim_move(
'x', 3, 2, mesh, color, sock);
1697 anim_move(
'y', 2, 3, mesh, color, sock);
1700 anim_move(
'x', 3, 3, mesh, color, sock);
1701 anim_move(
'z', 1, 2, mesh, color, sock);
1702 anim_move(
'x', 3, 1, mesh, color, sock);
1710 anim_move(
'y', 1, 3, mesh, color, sock);
1711 anim_move(
'z', 1, 3, mesh, color, sock);
1712 anim_move(
'y', 1, 1, mesh, color, sock);
1713 anim_move(
'z', 1, 1, mesh, color, sock);
1714 anim_move(
'y', 1, 3, mesh, color, sock);
1715 anim_move(
'z', 1, 3, mesh, color, sock);
1716 anim_move(
'y', 1, 1, mesh, color, sock);
1719 anim_move(
'x', 3, 3, mesh, color, sock);
1720 anim_move(
'z', 1, 1, mesh, color, sock);
1721 anim_move(
'x', 3, 1, mesh, color, sock);
1722 anim_move(
'z', 1, 3, mesh, color, sock);
1723 anim_move(
'x', 3, 3, mesh, color, sock);
1724 anim_move(
'z', 1, 1, mesh, color, sock);
1725 anim_move(
'x', 3, 1, mesh, color, sock);
1733 anim_move(
'x', 3, 1, mesh, color, sock);
1734 anim_move(
'z', 1, 3, mesh, color, sock);
1735 anim_move(
'x', 3, 2, mesh, color, sock);
1736 anim_move(
'z', 1, 2, mesh, color, sock);
1737 anim_move(
'x', 3, 1, mesh, color, sock);
1740 anim_move(
'y', 3, 3, mesh, color, sock);
1741 anim_move(
'z', 1, 1, mesh, color, sock);
1742 anim_move(
'y', 3, 1, mesh, color, sock);
1743 anim_move(
'y', 1, 3, mesh, color, sock);
1744 anim_move(
'z', 1, 3, mesh, color, sock);
1745 anim_move(
'y', 1, 1, mesh, color, sock);
1748 anim_move(
'y', 2, 1, mesh, color, sock);
1749 anim_move(
'x', 3, 3, mesh, color, sock);
1750 anim_move(
'y', 2, 3, mesh, color, sock);
1758 anim_move(
'y', 1, 3, mesh, color, sock);
1759 anim_move(
'y', 3, 1, mesh, color, sock);
1760 anim_move(
'z', 1, 2, mesh, color, sock);
1761 anim_move(
'y', 3, 3, mesh, color, sock);
1762 anim_move(
'y', 1, 1, mesh, color, sock);
1765 anim_move(
'x', 1, 1, mesh, color, sock);
1766 anim_move(
'z', 1, 3, mesh, color, sock);
1767 anim_move(
'x', 1, 3, mesh, color, sock);
1768 anim_move(
'x', 3, 3, mesh, color, sock);
1769 anim_move(
'z', 1, 2, mesh, color, sock);
1770 anim_move(
'x', 3, 1, mesh, color, sock);
1773 anim_move(
'y', 3, 1, mesh, color, sock);
1774 anim_move(
'z', 1, 1, mesh, color, sock);
1775 anim_move(
'y', 3, 3, mesh, color, sock);
1776 anim_move(
'y', 1, 3, mesh, color, sock);
1777 anim_move(
'z', 1, 2, mesh, color, sock);
1778 anim_move(
'y', 1, 1, mesh, color, sock);
1795 anim_move(
'y', 3, 3, mesh, color, sock);
1796 anim_move(
'z', 1, 2, mesh, color, sock);
1797 anim_move(
'y', 3, 1, mesh, color, sock);
1800 anim_move(
'z', 1, 1, mesh, color, sock);
1801 anim_move(
'x', 2, 3, mesh, color, sock);
1802 anim_move(
'y', 3, 2, mesh, color, sock);
1803 anim_move(
'x', 2, 1, mesh, color, sock);
1806 anim_move(
'x', 3, 1, mesh, color, sock);
1807 anim_move(
'z', 1, 2, mesh, color, sock);
1808 anim_move(
'x', 3, 3, mesh, color, sock);
1816 anim_move(
'z', 1, 2, mesh, color, sock);
1817 anim_move(
'x', 2, 3, mesh, color, sock);
1818 anim_move(
'y', 3, 2, mesh, color, sock);
1819 anim_move(
'x', 2, 1, mesh, color, sock);
1822 anim_move(
'y', 3, 3, mesh, color, sock);
1823 anim_move(
'z', 1, 3, mesh, color, sock);
1824 anim_move(
'y', 3, 1, mesh, color, sock);
1827 anim_move(
'z', 1, 1, mesh, color, sock);
1828 anim_move(
'x', 3, 1, mesh, color, sock);
1829 anim_move(
'z', 1, 2, mesh, color, sock);
1830 anim_move(
'x', 3, 3, mesh, color, sock);
1838 anim_move(
'x', 3, 1, mesh, color, sock);
1839 anim_move(
'z', 1, 3, mesh, color, sock);
1840 anim_move(
'x', 3, 3, mesh, color, sock);
1843 anim_move(
'x', 3, 1, mesh, color, sock);
1844 anim_move(
'z', 1, 1, mesh, color, sock);
1845 anim_move(
'x', 3, 3, mesh, color, sock);
1846 anim_move(
'y', 3, 3, mesh, color, sock);
1847 anim_move(
'z', 1, 2, mesh, color, sock);
1848 anim_move(
'y', 3, 1, mesh, color, sock);
1851 anim_move(
'y', 3, 3, mesh, color, sock);
1852 anim_move(
'z', 1, 1, mesh, color, sock);
1853 anim_move(
'y', 3, 1, mesh, color, sock);
1861 anim_move(
'x', 2, 3, mesh, color, sock);
1862 anim_move(
'y', 3, 2, mesh, color, sock);
1863 anim_move(
'x', 2, 1, mesh, color, sock);
1866 anim_move(
'z', 1, 1, mesh, color, sock);
1867 anim_move(
'x', 2, 3, mesh, color, sock);
1868 anim_move(
'y', 3, 1, mesh, color, sock);
1869 anim_move(
'x', 2, 1, mesh, color, sock);
1872 anim_move(
'x', 3, 1, mesh, color, sock);
1873 anim_move(
'z', 1, 1, mesh, color, sock);
1874 anim_move(
'x', 3, 3, mesh, color, sock);
1882 anim_move(
'y', 3, 3, mesh, color, sock);
1883 anim_move(
'z', 1, 1, mesh, color, sock);
1884 anim_move(
'y', 3, 1, mesh, color, sock);
1885 anim_move(
'z', 1, 3, mesh, color, sock);
1886 anim_move(
'y', 3, 3, mesh, color, sock);
1887 anim_move(
'z', 1, 1, mesh, color, sock);
1888 anim_move(
'y', 3, 1, mesh, color, sock);
1891 anim_move(
'x', 3, 1, mesh, color, sock);
1892 anim_move(
'z', 1, 3, mesh, color, sock);
1893 anim_move(
'x', 3, 3, mesh, color, sock);
1894 anim_move(
'z', 1, 1, mesh, color, sock);
1895 anim_move(
'x', 3, 1, mesh, color, sock);
1896 anim_move(
'z', 1, 3, mesh, color, sock);
1897 anim_move(
'x', 3, 3, mesh, color, sock);
1905 anim_move(
'x', 2, 3, mesh, color, sock);
1906 anim_move(
'y', 3, 3, mesh, color, sock);
1907 anim_move(
'x', 2, 1, mesh, color, sock);
1910 anim_move(
'x', 1, 1, mesh, color, sock);
1911 anim_move(
'z', 1, 1, mesh, color, sock);
1912 anim_move(
'x', 1, 3, mesh, color, sock);
1913 anim_move(
'x', 3, 1, mesh, color, sock);
1914 anim_move(
'z', 1, 3, mesh, color, sock);
1915 anim_move(
'x', 3, 3, mesh, color, sock);
1918 anim_move(
'y', 3, 1, mesh, color, sock);
1919 anim_move(
'z', 1, 3, mesh, color, sock);
1920 anim_move(
'y', 3, 2, mesh, color, sock);
1921 anim_move(
'z', 1, 2, mesh, color, sock);
1922 anim_move(
'y', 3, 1, mesh, color, sock);
1939 anim_move(
'z', 1, 1, mesh, color, sock);
1940 anim_move(
'y', 3, 1, mesh, color, sock);
1941 anim_move(
'z', 1, 1, mesh, color, sock);
1942 anim_move(
'y', 3, 3, mesh, color, sock);
1943 anim_move(
'x', 1, 1, mesh, color, sock);
1944 anim_move(
'z', 1, 2, mesh, color, sock);
1945 anim_move(
'x', 1, 3, mesh, color, sock);
1948 anim_move(
'y', 3, 1, mesh, color, sock);
1949 anim_move(
'z', 1, 1, mesh, color, sock);
1950 anim_move(
'y', 3, 3, mesh, color, sock);
1953 anim_move(
'z', 1, 3, mesh, color, sock);
1954 anim_move(
'x', 1, 1, mesh, color, sock);
1955 anim_move(
'z', 1, 2, mesh, color, sock);
1956 anim_move(
'x', 1, 3, mesh, color, sock);
1964 anim_move(
'y', 3, 1, mesh, color, sock);
1965 anim_move(
'z', 1, 2, mesh, color, sock);
1966 anim_move(
'y', 3, 3, mesh, color, sock);
1969 anim_move(
'z', 1, 2, mesh, color, sock);
1970 anim_move(
'x', 1, 1, mesh, color, sock);
1971 anim_move(
'z', 1, 3, mesh, color, sock);
1972 anim_move(
'x', 1, 3, mesh, color, sock);
1973 anim_move(
'y', 3, 1, mesh, color, sock);
1974 anim_move(
'z', 1, 2, mesh, color, sock);
1975 anim_move(
'y', 3, 3, mesh, color, sock);
1978 anim_move(
'x', 1, 1, mesh, color, sock);
1979 anim_move(
'z', 1, 2, mesh, color, sock);
1980 anim_move(
'x', 1, 3, mesh, color, sock);
1988 anim_move(
'z', 1, 3, mesh, color, sock);
1989 anim_move(
'x', 1, 1, mesh, color, sock);
1990 anim_move(
'z', 1, 3, mesh, color, sock);
1991 anim_move(
'x', 1, 3, mesh, color, sock);
1992 anim_move(
'y', 3, 1, mesh, color, sock);
1993 anim_move(
'z', 1, 2, mesh, color, sock);
1994 anim_move(
'y', 3, 3, mesh, color, sock);
1997 anim_move(
'z', 1, 1, mesh, color, sock);
1998 anim_move(
'y', 3, 1, mesh, color, sock);
1999 anim_move(
'z', 1, 2, mesh, color, sock);
2000 anim_move(
'y', 3, 3, mesh, color, sock);
2003 anim_move(
'x', 1, 1, mesh, color, sock);
2004 anim_move(
'z', 1, 3, mesh, color, sock);
2005 anim_move(
'x', 1, 3, mesh, color, sock);
2013 anim_move(
'x', 1, 1, mesh, color, sock);
2014 anim_move(
'z', 1, 1, mesh, color, sock);
2015 anim_move(
'x', 1, 3, mesh, color, sock);
2018 anim_move(
'y', 3, 1, mesh, color, sock);
2019 anim_move(
'z', 1, 1, mesh, color, sock);
2020 anim_move(
'y', 3, 3, mesh, color, sock);
2021 anim_move(
'x', 1, 1, mesh, color, sock);
2022 anim_move(
'z', 1, 2, mesh, color, sock);
2023 anim_move(
'x', 1, 3, mesh, color, sock);
2026 anim_move(
'y', 3, 1, mesh, color, sock);
2027 anim_move(
'z', 1, 3, mesh, color, sock);
2028 anim_move(
'y', 3, 3, mesh, color, sock);
2036 anim_move(
'y', 3, 1, mesh, color, sock);
2037 anim_move(
'z', 1, 3, mesh, color, sock);
2038 anim_move(
'y', 3, 3, mesh, color, sock);
2039 anim_move(
'z', 1, 1, mesh, color, sock);
2040 anim_move(
'y', 3, 1, mesh, color, sock);
2041 anim_move(
'z', 1, 3, mesh, color, sock);
2042 anim_move(
'y', 3, 3, mesh, color, sock);
2045 anim_move(
'x', 1, 1, mesh, color, sock);
2046 anim_move(
'z', 1, 1, mesh, color, sock);
2047 anim_move(
'x', 1, 3, mesh, color, sock);
2048 anim_move(
'z', 1, 3, mesh, color, sock);
2049 anim_move(
'x', 1, 1, mesh, color, sock);
2050 anim_move(
'z', 1, 1, mesh, color, sock);
2051 anim_move(
'x', 1, 3, mesh, color, sock);
2063 cout <<
"Entering solve_top_corners" << endl;
2076 cout <<
"Location of 4-th corner: " << i4
2077 <<
" with orientation " << o4 << endl;
2090 cout <<
"Location of 5-th corner: " << i5
2091 <<
" with orientation " << o5 << endl;
2104 cout <<
"Location of 6-th corner: " << i6
2105 <<
" with orientation " << o6 << endl;
2118 cout <<
"Location of 7-th corner: " << i7
2119 <<
" with orientation " << o7 << endl;
2130 for (
int i=0; i<12; i++)
2132 if ((rubik.edge_[2 * i + 0] == edge_colors_[2 * ind + 0] &&
2133 rubik.edge_[2 * i + 1] == edge_colors_[2 * ind + 1]))
2137 if ((rubik.edge_[2 * i + 0] == edge_colors_[2 * ind + 1] &&
2138 rubik.edge_[2 * i + 1] == edge_colors_[2 * ind + 0]))
2155 anim_move(
'y', 2, 1, mesh, color, sock);
2156 anim_move(
'x', 2, 1, mesh, color, sock);
2157 anim_move(
'y', 2, 3, mesh, color, sock);
2160 anim_move(
'x', 3, 1, mesh, color, sock);
2161 anim_move(
'y', 1, 1, mesh, color, sock);
2164 anim_move(
'y', 3, 2, mesh, color, sock);
2165 anim_move(
'z', 3, 2, mesh, color, sock);
2168 anim_move(
'x', 1, 2, mesh, color, sock);
2169 anim_move(
'z', 3, 3, mesh, color, sock);
2172 anim_move(
'z', 3, 1, mesh, color, sock);
2175 anim_move(
'y', 2, 1, mesh, color, sock);
2176 anim_move(
'x', 2, 3, mesh, color, sock);
2177 anim_move(
'y', 2, 3, mesh, color, sock);
2180 anim_move(
'y', 2, 3, mesh, color, sock);
2181 anim_move(
'z', 3, 1, mesh, color, sock);
2182 anim_move(
'y', 2, 1, mesh, color, sock);
2185 anim_move(
'y', 1, 3, mesh, color, sock);
2188 anim_move(
'z', 2, 1, mesh, color, sock);
2189 anim_move(
'y', 1, 3, mesh, color, sock);
2192 anim_move(
'y', 3, 1, mesh, color, sock);
2193 anim_move(
'z', 3, 2, mesh, color, sock);
2196 anim_move(
'x', 1, 3, mesh, color, sock);
2197 anim_move(
'z', 3, 3, mesh, color, sock);
2206 anim_move(
'y', 1, 2, mesh, color, sock);
2209 anim_move(
'z', 1, 3, mesh, color, sock);
2210 anim_move(
'y', 1, 2, mesh, color, sock);
2213 anim_move(
'x', 2, 3, mesh, color, sock);
2214 anim_move(
'z', 3, 1, mesh, color, sock);
2215 anim_move(
'x', 2, 1, mesh, color, sock);
2216 anim_move(
'z', 3, 1, mesh, color, sock);
2219 anim_move(
'y', 2, 3, mesh, color, sock);
2220 anim_move(
'z', 3, 3, mesh, color, sock);
2221 anim_move(
'y', 2, 1, mesh, color, sock);
2224 anim_move(
'y', 1, 3, mesh, color, sock);
2225 anim_move(
'z', 2, 1, mesh, color, sock);
2226 anim_move(
'y', 1, 3, mesh, color, sock);
2229 anim_move(
'y', 2, 1, mesh, color, sock);
2230 anim_move(
'z', 3, 3, mesh, color, sock);
2231 anim_move(
'y', 2, 3, mesh, color, sock);
2234 anim_move(
'z', 3, 2, mesh, color, sock);
2237 anim_move(
'z', 3, 3, mesh, color, sock);
2240 anim_move(
'z', 2, 3, mesh, color, sock);
2241 anim_move(
'y', 1, 1, mesh, color, sock);
2244 anim_move(
'y', 1, 1, mesh, color, sock);
2247 anim_move(
'x', 3, 3, mesh, color, sock);
2248 anim_move(
'z', 3, 1, mesh, color, sock);
2251 anim_move(
'y', 3, 3, mesh, color, sock);
2252 anim_move(
'z', 3, 2, mesh, color, sock);
2267 anim_move(
'y', 1, 3, mesh, color, sock);
2268 anim_move(
'x', 3, 1, mesh, color, sock);
2269 anim_move(
'y', 1, 1, mesh, color, sock);
2272 anim_move(
'x', 2, 3, mesh, color, sock);
2273 anim_move(
'y', 2, 1, mesh, color, sock);
2274 anim_move(
'x', 2, 1, mesh, color, sock);
2277 anim_move(
'z', 1, 1, mesh, color, sock);
2278 anim_move(
'x', 3, 2, mesh, color, sock);
2281 anim_move(
'z', 1, 2, mesh, color, sock);
2282 anim_move(
'x', 3, 2, mesh, color, sock);
2285 anim_move(
'y', 3, 3, mesh, color, sock);
2286 anim_move(
'x', 3, 3, mesh, color, sock);
2289 anim_move(
'x', 2, 1, mesh, color, sock);
2290 anim_move(
'y', 2, 3, mesh, color, sock);
2291 anim_move(
'x', 2, 3, mesh, color, sock);
2294 anim_move(
'z', 2, 3, mesh, color, sock);
2295 anim_move(
'x', 3, 1, mesh, color, sock);
2298 anim_move(
'x', 3, 1, mesh, color, sock);
2301 anim_move(
'z', 2, 1, mesh, color, sock);
2302 anim_move(
'x', 3, 1, mesh, color, sock);
2305 anim_move(
'y', 3, 2, mesh, color, sock);
2306 anim_move(
'x', 3, 3, mesh, color, sock);
2315 anim_move(
'z', 1, 3, mesh, color, sock);
2316 anim_move(
'x', 3, 2, mesh, color, sock);
2319 anim_move(
'x', 3, 2, mesh, color, sock);
2322 anim_move(
'y', 3, 1, mesh, color, sock);
2323 anim_move(
'x', 3, 3, mesh, color, sock);
2326 anim_move(
'z', 1, 2, mesh, color, sock);
2327 anim_move(
'x', 2, 3, mesh, color, sock);
2328 anim_move(
'y', 2, 1, mesh, color, sock);
2329 anim_move(
'x', 2, 1, mesh, color, sock);
2332 anim_move(
'x', 3, 1, mesh, color, sock);
2333 anim_move(
'z', 2, 1, mesh, color, sock);
2334 anim_move(
'x', 3, 1, mesh, color, sock);
2337 anim_move(
'y', 1, 1, mesh, color, sock);
2338 anim_move(
'z', 3, 1, mesh, color, sock);
2339 anim_move(
'y', 1, 3, mesh, color, sock);
2342 anim_move(
'y', 1, 1, mesh, color, sock);
2343 anim_move(
'z', 3, 2, mesh, color, sock);
2344 anim_move(
'y', 1, 3, mesh, color, sock);
2347 anim_move(
'z', 2, 2, mesh, color, sock);
2348 anim_move(
'x', 3, 3, mesh, color, sock);
2351 anim_move(
'z', 2, 3, mesh, color, sock);
2352 anim_move(
'x', 3, 3, mesh, color, sock);
2355 anim_move(
'x', 3, 3, mesh, color, sock);
2358 anim_move(
'z', 2, 1, mesh, color, sock);
2359 anim_move(
'x', 3, 3, mesh, color, sock);
2374 anim_move(
'z', 1, 2, mesh, color, sock);
2375 anim_move(
'y', 3, 2, mesh, color, sock);
2378 anim_move(
'z', 1, 3, mesh, color, sock);
2379 anim_move(
'y', 3, 2, mesh, color, sock);
2382 anim_move(
'y', 3, 1, mesh, color, sock);
2383 anim_move(
'z', 2, 3, mesh, color, sock);
2384 anim_move(
'y', 3, 3, mesh, color, sock);
2387 anim_move(
'x', 1, 3, mesh, color, sock);
2388 anim_move(
'y', 3, 3, mesh, color, sock);
2391 anim_move(
'z', 3, 1, mesh, color, sock);
2392 anim_move(
'y', 3, 1, mesh, color, sock);
2393 anim_move(
'z', 3, 3, mesh, color, sock);
2394 anim_move(
'y', 3, 3, mesh, color, sock);
2397 anim_move(
'z', 2, 1, mesh, color, sock);
2398 anim_move(
'y', 3, 3, mesh, color, sock);
2401 anim_move(
'z', 2, 2, mesh, color, sock);
2402 anim_move(
'y', 3, 3, mesh, color, sock);
2405 anim_move(
'z', 2, 3, mesh, color, sock);
2406 anim_move(
'y', 3, 3, mesh, color, sock);
2409 anim_move(
'y', 3, 3, mesh, color, sock);
2418 anim_move(
'z', 1, 1, mesh, color, sock);
2419 anim_move(
'x', 1, 3, mesh, color, sock);
2420 anim_move(
'y', 3, 3, mesh, color, sock);
2423 anim_move(
'x', 2, 1, mesh, color, sock);
2424 anim_move(
'z', 1, 3, mesh, color, sock);
2425 anim_move(
'x', 2, 3, mesh, color, sock);
2428 anim_move(
'y', 3, 2, mesh, color, sock);
2431 anim_move(
'z', 1, 1, mesh, color, sock);
2432 anim_move(
'y', 3, 2, mesh, color, sock);
2435 anim_move(
'y', 3, 1, mesh, color, sock);
2436 anim_move(
'z', 2, 1, mesh, color, sock);
2437 anim_move(
'y', 3, 1, mesh, color, sock);
2440 anim_move(
'x', 1, 1, mesh, color, sock);
2441 anim_move(
'y', 3, 3, mesh, color, sock);
2444 anim_move(
'z', 2, 2, mesh, color, sock);
2445 anim_move(
'y', 3, 1, mesh, color, sock);
2448 anim_move(
'z', 2, 3, mesh, color, sock);
2449 anim_move(
'y', 3, 1, mesh, color, sock);
2452 anim_move(
'y', 3, 1, mesh, color, sock);
2455 anim_move(
'z', 2, 1, mesh, color, sock);
2456 anim_move(
'y', 3, 1, mesh, color, sock);
2471 anim_move(
'z', 1, 1, mesh, color, sock);
2472 anim_move(
'x', 1, 2, mesh, color, sock);
2475 anim_move(
'z', 1, 2, mesh, color, sock);
2476 anim_move(
'x', 1, 2, mesh, color, sock);
2479 anim_move(
'y', 3, 3, mesh, color, sock);
2480 anim_move(
'x', 1, 3, mesh, color, sock);
2481 anim_move(
'y', 3, 1, mesh, color, sock);
2484 anim_move(
'x', 1, 1, mesh, color, sock);
2485 anim_move(
'z', 2, 1, mesh, color, sock);
2486 anim_move(
'x', 1, 3, mesh, color, sock);
2489 anim_move(
'x', 1, 1, mesh, color, sock);
2492 anim_move(
'z', 2, 1, mesh, color, sock);
2493 anim_move(
'x', 1, 1, mesh, color, sock);
2496 anim_move(
'z', 2, 2, mesh, color, sock);
2497 anim_move(
'x', 1, 1, mesh, color, sock);
2500 anim_move(
'z', 2, 3, mesh, color, sock);
2501 anim_move(
'x', 1, 1, mesh, color, sock);
2510 anim_move(
'y', 1, 3, mesh, color, sock);
2511 anim_move(
'x', 1, 1, mesh, color, sock);
2512 anim_move(
'y', 1, 1, mesh, color, sock);
2515 anim_move(
'z', 1, 3, mesh, color, sock);
2516 anim_move(
'y', 3, 3, mesh, color, sock);
2517 anim_move(
'x', 1, 3, mesh, color, sock);
2518 anim_move(
'y', 3, 1, mesh, color, sock);
2521 anim_move(
'z', 1, 3, mesh, color, sock);
2522 anim_move(
'x', 1, 2, mesh, color, sock);
2525 anim_move(
'x', 1, 2, mesh, color, sock);
2528 anim_move(
'x', 1, 1, mesh, color, sock);
2529 anim_move(
'z', 2, 3, mesh, color, sock);
2530 anim_move(
'x', 1, 1, mesh, color, sock);
2533 anim_move(
'z', 2, 1, mesh, color, sock);
2534 anim_move(
'x', 1, 3, mesh, color, sock);
2537 anim_move(
'z', 2, 2, mesh, color, sock);
2538 anim_move(
'x', 1, 3, mesh, color, sock);
2541 anim_move(
'z', 2, 3, mesh, color, sock);
2542 anim_move(
'x', 1, 3, mesh, color, sock);
2545 anim_move(
'x', 1, 3, mesh, color, sock);
2560 anim_move(
'z', 1, 2, mesh, color, sock);
2561 anim_move(
'y', 1, 1, mesh, color, sock);
2562 anim_move(
'z', 1, 3, mesh, color, sock);
2563 anim_move(
'y', 1, 3, mesh, color, sock);
2564 anim_move(
'x', 1, 1, mesh, color, sock);
2565 anim_move(
'y', 1, 3, mesh, color, sock);
2566 anim_move(
'x', 1, 3, mesh, color, sock);
2567 anim_move(
'y', 1, 1, mesh, color, sock);
2570 anim_move(
'z', 1, 3, mesh, color, sock);
2571 anim_move(
'y', 1, 1, mesh, color, sock);
2572 anim_move(
'z', 1, 3, mesh, color, sock);
2573 anim_move(
'y', 1, 3, mesh, color, sock);
2574 anim_move(
'x', 1, 1, mesh, color, sock);
2575 anim_move(
'y', 1, 3, mesh, color, sock);
2576 anim_move(
'x', 1, 3, mesh, color, sock);
2577 anim_move(
'y', 1, 1, mesh, color, sock);
2580 anim_move(
'z', 1, 1, mesh, color, sock);
2581 anim_move(
'x', 1, 3, mesh, color, sock);
2582 anim_move(
'z', 1, 1, mesh, color, sock);
2583 anim_move(
'x', 1, 1, mesh, color, sock);
2584 anim_move(
'y', 1, 3, mesh, color, sock);
2585 anim_move(
'x', 1, 1, mesh, color, sock);
2586 anim_move(
'y', 1, 1, mesh, color, sock);
2587 anim_move(
'x', 1, 3, mesh, color, sock);
2590 anim_move(
'z', 1, 2, mesh, color, sock);
2591 anim_move(
'x', 1, 3, mesh, color, sock);
2592 anim_move(
'z', 1, 1, mesh, color, sock);
2593 anim_move(
'x', 1, 1, mesh, color, sock);
2594 anim_move(
'y', 1, 3, mesh, color, sock);
2595 anim_move(
'x', 1, 1, mesh, color, sock);
2596 anim_move(
'y', 1, 1, mesh, color, sock);
2597 anim_move(
'x', 1, 3, mesh, color, sock);
2600 anim_move(
'x', 3, 3, mesh, color, sock);
2602 anim_move(
'x', 3, 1, mesh, color, sock);
2603 anim_move(
'z', 1, 1, mesh, color, sock);
2604 anim_move(
'y', 1, 1, mesh, color, sock);
2606 anim_move(
'y', 1, 3, mesh, color, sock);
2609 anim_move(
'z', 2, 1, mesh, color, sock);
2610 anim_move(
'y', 1, 2, mesh, color, sock);
2611 anim_move(
'z', 2, 3, mesh, color, sock);
2612 anim_move(
'y', 1, 2, mesh, color, sock);
2615 anim_move(
'y', 3, 1, mesh, color, sock);
2617 anim_move(
'y', 3, 3, mesh, color, sock);
2618 anim_move(
'z', 1, 3, mesh, color, sock);
2619 anim_move(
'y', 1, 1, mesh, color, sock);
2621 anim_move(
'y', 1, 3, mesh, color, sock);
2630 anim_move(
'z', 1, 3, mesh, color, sock);
2631 anim_move(
'x', 1, 3, mesh, color, sock);
2632 anim_move(
'z', 1, 1, mesh, color, sock);
2633 anim_move(
'x', 1, 1, mesh, color, sock);
2634 anim_move(
'y', 1, 3, mesh, color, sock);
2635 anim_move(
'x', 1, 1, mesh, color, sock);
2636 anim_move(
'y', 1, 1, mesh, color, sock);
2637 anim_move(
'x', 1, 3, mesh, color, sock);
2640 anim_move(
'x', 1, 3, mesh, color, sock);
2641 anim_move(
'z', 1, 1, mesh, color, sock);
2642 anim_move(
'x', 1, 1, mesh, color, sock);
2643 anim_move(
'y', 1, 3, mesh, color, sock);
2644 anim_move(
'x', 1, 1, mesh, color, sock);
2645 anim_move(
'y', 1, 1, mesh, color, sock);
2646 anim_move(
'x', 1, 3, mesh, color, sock);
2649 anim_move(
'y', 1, 1, mesh, color, sock);
2650 anim_move(
'z', 1, 3, mesh, color, sock);
2651 anim_move(
'y', 1, 3, mesh, color, sock);
2652 anim_move(
'x', 1, 1, mesh, color, sock);
2653 anim_move(
'y', 1, 3, mesh, color, sock);
2654 anim_move(
'x', 1, 3, mesh, color, sock);
2655 anim_move(
'y', 1, 1, mesh, color, sock);
2658 anim_move(
'z', 1, 1, mesh, color, sock);
2659 anim_move(
'y', 1, 1, mesh, color, sock);
2660 anim_move(
'z', 1, 3, mesh, color, sock);
2661 anim_move(
'y', 1, 3, mesh, color, sock);
2662 anim_move(
'x', 1, 1, mesh, color, sock);
2663 anim_move(
'y', 1, 3, mesh, color, sock);
2664 anim_move(
'x', 1, 3, mesh, color, sock);
2665 anim_move(
'y', 1, 1, mesh, color, sock);
2668 anim_move(
'y', 1, 1, mesh, color, sock);
2669 anim_move(
'z', 1, 3, mesh, color, sock);
2670 anim_move(
'y', 1, 3, mesh, color, sock);
2671 anim_move(
'x', 1, 1, mesh, color, sock);
2672 anim_move(
'y', 1, 3, mesh, color, sock);
2673 anim_move(
'x', 1, 3, mesh, color, sock);
2674 anim_move(
'y', 1, 1, mesh, color, sock);
2675 anim_move(
'z', 1, 3, mesh, color, sock);
2676 anim_move(
'y', 1, 1, mesh, color, sock);
2677 anim_move(
'z', 1, 3, mesh, color, sock);
2678 anim_move(
'y', 1, 3, mesh, color, sock);
2679 anim_move(
'x', 1, 1, mesh, color, sock);
2680 anim_move(
'y', 1, 3, mesh, color, sock);
2681 anim_move(
'x', 1, 3, mesh, color, sock);
2682 anim_move(
'y', 1, 1, mesh, color, sock);
2685 anim_move(
'y', 1, 2, mesh, color, sock);
2686 anim_move(
'z', 1, 2, mesh, color, sock);
2687 anim_move(
'y', 1, 2, mesh, color, sock);
2688 anim_move(
'z', 1, 2, mesh, color, sock);
2689 anim_move(
'y', 1, 2, mesh, color, sock);
2692 anim_move(
'y', 3, 3, mesh, color, sock);
2694 anim_move(
'y', 3, 1, mesh, color, sock);
2695 anim_move(
'z', 1, 3, mesh, color, sock);
2696 anim_move(
'y', 1, 1, mesh, color, sock);
2698 anim_move(
'y', 1, 3, mesh, color, sock);
2701 anim_move(
'z', 2, 1, mesh, color, sock);
2702 anim_move(
'x', 1, 2, mesh, color, sock);
2703 anim_move(
'z', 2, 3, mesh, color, sock);
2704 anim_move(
'x', 1, 2, mesh, color, sock);
2719 anim_move(
'z', 1, 1, mesh, color, sock);
2720 anim_move(
'x', 3, 3, mesh, color, sock);
2721 anim_move(
'z', 1, 3, mesh, color, sock);
2722 anim_move(
'x', 3, 1, mesh, color, sock);
2723 anim_move(
'y', 1, 1, mesh, color, sock);
2724 anim_move(
'x', 3, 1, mesh, color, sock);
2725 anim_move(
'y', 1, 3, mesh, color, sock);
2726 anim_move(
'x', 3, 3, mesh, color, sock);
2729 anim_move(
'z', 1, 2, mesh, color, sock);
2730 anim_move(
'x', 3, 3, mesh, color, sock);
2731 anim_move(
'z', 1, 3, mesh, color, sock);
2732 anim_move(
'x', 3, 1, mesh, color, sock);
2733 anim_move(
'y', 1, 1, mesh, color, sock);
2734 anim_move(
'x', 3, 1, mesh, color, sock);
2735 anim_move(
'y', 1, 3, mesh, color, sock);
2736 anim_move(
'x', 3, 3, mesh, color, sock);
2739 anim_move(
'y', 1, 3, mesh, color, sock);
2740 anim_move(
'z', 1, 1, mesh, color, sock);
2741 anim_move(
'y', 1, 1, mesh, color, sock);
2742 anim_move(
'x', 3, 1, mesh, color, sock);
2743 anim_move(
'y', 1, 1, mesh, color, sock);
2744 anim_move(
'x', 3, 3, mesh, color, sock);
2745 anim_move(
'y', 1, 3, mesh, color, sock);
2748 anim_move(
'z', 1, 1, mesh, color, sock);
2749 anim_move(
'y', 1, 3, mesh, color, sock);
2750 anim_move(
'z', 1, 1, mesh, color, sock);
2751 anim_move(
'y', 1, 1, mesh, color, sock);
2752 anim_move(
'x', 3, 1, mesh, color, sock);
2753 anim_move(
'y', 1, 1, mesh, color, sock);
2754 anim_move(
'x', 3, 3, mesh, color, sock);
2755 anim_move(
'y', 1, 3, mesh, color, sock);
2758 anim_move(
'y', 3, 3, mesh, color, sock);
2760 anim_move(
'y', 3, 1, mesh, color, sock);
2761 anim_move(
'z', 1, 3, mesh, color, sock);
2762 anim_move(
'y', 1, 3, mesh, color, sock);
2764 anim_move(
'y', 1, 1, mesh, color, sock);
2767 anim_move(
'z', 2, 1, mesh, color, sock);
2768 anim_move(
'x', 3, 2, mesh, color, sock);
2769 anim_move(
'z', 2, 3, mesh, color, sock);
2770 anim_move(
'x', 3, 2, mesh, color, sock);
2779 anim_move(
'z', 1, 2, mesh, color, sock);
2780 anim_move(
'y', 1, 3, mesh, color, sock);
2781 anim_move(
'z', 1, 1, mesh, color, sock);
2782 anim_move(
'y', 1, 1, mesh, color, sock);
2783 anim_move(
'x', 3, 1, mesh, color, sock);
2784 anim_move(
'y', 1, 1, mesh, color, sock);
2785 anim_move(
'x', 3, 3, mesh, color, sock);
2786 anim_move(
'y', 1, 3, mesh, color, sock);
2789 anim_move(
'z', 1, 3, mesh, color, sock);
2790 anim_move(
'y', 1, 3, mesh, color, sock);
2791 anim_move(
'z', 1, 1, mesh, color, sock);
2792 anim_move(
'y', 1, 1, mesh, color, sock);
2793 anim_move(
'x', 3, 1, mesh, color, sock);
2794 anim_move(
'y', 1, 1, mesh, color, sock);
2795 anim_move(
'x', 3, 3, mesh, color, sock);
2796 anim_move(
'y', 1, 3, mesh, color, sock);
2799 anim_move(
'z', 1, 3, mesh, color, sock);
2800 anim_move(
'x', 3, 3, mesh, color, sock);
2801 anim_move(
'z', 1, 3, mesh, color, sock);
2802 anim_move(
'x', 3, 1, mesh, color, sock);
2803 anim_move(
'y', 1, 1, mesh, color, sock);
2804 anim_move(
'x', 3, 1, mesh, color, sock);
2805 anim_move(
'y', 1, 3, mesh, color, sock);
2806 anim_move(
'x', 3, 3, mesh, color, sock);
2809 anim_move(
'x', 3, 3, mesh, color, sock);
2810 anim_move(
'z', 1, 3, mesh, color, sock);
2811 anim_move(
'x', 3, 1, mesh, color, sock);
2812 anim_move(
'y', 1, 1, mesh, color, sock);
2813 anim_move(
'x', 3, 1, mesh, color, sock);
2814 anim_move(
'y', 1, 3, mesh, color, sock);
2815 anim_move(
'x', 3, 3, mesh, color, sock);
2818 anim_move(
'x', 3, 3, mesh, color, sock);
2819 anim_move(
'z', 1, 3, mesh, color, sock);
2820 anim_move(
'x', 3, 1, mesh, color, sock);
2821 anim_move(
'y', 1, 1, mesh, color, sock);
2822 anim_move(
'x', 3, 1, mesh, color, sock);
2823 anim_move(
'y', 1, 3, mesh, color, sock);
2824 anim_move(
'x', 3, 3, mesh, color, sock);
2825 anim_move(
'z', 1, 3, mesh, color, sock);
2826 anim_move(
'x', 3, 3, mesh, color, sock);
2827 anim_move(
'z', 1, 3, mesh, color, sock);
2828 anim_move(
'x', 3, 1, mesh, color, sock);
2829 anim_move(
'y', 1, 1, mesh, color, sock);
2830 anim_move(
'x', 3, 1, mesh, color, sock);
2831 anim_move(
'y', 1, 3, mesh, color, sock);
2832 anim_move(
'x', 3, 3, mesh, color, sock);
2835 anim_move(
'x', 3, 2, mesh, color, sock);
2836 anim_move(
'z', 1, 2, mesh, color, sock);
2837 anim_move(
'x', 3, 2, mesh, color, sock);
2838 anim_move(
'z', 1, 2, mesh, color, sock);
2839 anim_move(
'x', 3, 2, mesh, color, sock);
2842 anim_move(
'y', 3, 1, mesh, color, sock);
2844 anim_move(
'y', 3, 3, mesh, color, sock);
2845 anim_move(
'z', 1, 3, mesh, color, sock);
2846 anim_move(
'y', 1, 3, mesh, color, sock);
2848 anim_move(
'y', 1, 1, mesh, color, sock);
2863 anim_move(
'y', 3, 3, mesh, color, sock);
2864 anim_move(
'z', 1, 3, mesh, color, sock);
2865 anim_move(
'y', 3, 1, mesh, color, sock);
2866 anim_move(
'x', 3, 3, mesh, color, sock);
2867 anim_move(
'y', 3, 1, mesh, color, sock);
2868 anim_move(
'x', 3, 1, mesh, color, sock);
2869 anim_move(
'y', 3, 3, mesh, color, sock);
2872 anim_move(
'z', 1, 1, mesh, color, sock);
2873 anim_move(
'y', 3, 3, mesh, color, sock);
2874 anim_move(
'z', 1, 3, mesh, color, sock);
2875 anim_move(
'y', 3, 1, mesh, color, sock);
2876 anim_move(
'x', 3, 3, mesh, color, sock);
2877 anim_move(
'y', 3, 1, mesh, color, sock);
2878 anim_move(
'x', 3, 1, mesh, color, sock);
2879 anim_move(
'y', 3, 3, mesh, color, sock);
2882 anim_move(
'z', 1, 3, mesh, color, sock);
2883 anim_move(
'x', 3, 1, mesh, color, sock);
2884 anim_move(
'z', 1, 1, mesh, color, sock);
2885 anim_move(
'x', 3, 3, mesh, color, sock);
2886 anim_move(
'y', 3, 1, mesh, color, sock);
2887 anim_move(
'x', 3, 3, mesh, color, sock);
2888 anim_move(
'y', 3, 3, mesh, color, sock);
2889 anim_move(
'x', 3, 1, mesh, color, sock);
2892 anim_move(
'x', 3, 1, mesh, color, sock);
2893 anim_move(
'z', 1, 1, mesh, color, sock);
2894 anim_move(
'x', 3, 3, mesh, color, sock);
2895 anim_move(
'y', 3, 1, mesh, color, sock);
2896 anim_move(
'x', 3, 3, mesh, color, sock);
2897 anim_move(
'y', 3, 3, mesh, color, sock);
2898 anim_move(
'x', 3, 1, mesh, color, sock);
2901 anim_move(
'y', 3, 1, mesh, color, sock);
2903 anim_move(
'y', 3, 3, mesh, color, sock);
2904 anim_move(
'z', 1, 1, mesh, color, sock);
2905 anim_move(
'y', 3, 3, mesh, color, sock);
2907 anim_move(
'y', 3, 1, mesh, color, sock);
2916 anim_move(
'z', 1, 1, mesh, color, sock);
2917 anim_move(
'x', 3, 1, mesh, color, sock);
2918 anim_move(
'z', 1, 1, mesh, color, sock);
2919 anim_move(
'x', 3, 3, mesh, color, sock);
2920 anim_move(
'y', 3, 1, mesh, color, sock);
2921 anim_move(
'x', 3, 3, mesh, color, sock);
2922 anim_move(
'y', 3, 3, mesh, color, sock);
2923 anim_move(
'x', 3, 1, mesh, color, sock);
2926 anim_move(
'z', 1, 2, mesh, color, sock);
2927 anim_move(
'x', 3, 1, mesh, color, sock);
2928 anim_move(
'z', 1, 1, mesh, color, sock);
2929 anim_move(
'x', 3, 3, mesh, color, sock);
2930 anim_move(
'y', 3, 1, mesh, color, sock);
2931 anim_move(
'x', 3, 3, mesh, color, sock);
2932 anim_move(
'y', 3, 3, mesh, color, sock);
2933 anim_move(
'x', 3, 1, mesh, color, sock);
2936 anim_move(
'z', 1, 2, mesh, color, sock);
2937 anim_move(
'y', 3, 3, mesh, color, sock);
2938 anim_move(
'z', 1, 3, mesh, color, sock);
2939 anim_move(
'y', 3, 1, mesh, color, sock);
2940 anim_move(
'x', 3, 3, mesh, color, sock);
2941 anim_move(
'y', 3, 1, mesh, color, sock);
2942 anim_move(
'x', 3, 1, mesh, color, sock);
2943 anim_move(
'y', 3, 3, mesh, color, sock);
2946 anim_move(
'z', 1, 3, mesh, color, sock);
2947 anim_move(
'y', 3, 3, mesh, color, sock);
2948 anim_move(
'z', 1, 3, mesh, color, sock);
2949 anim_move(
'y', 3, 1, mesh, color, sock);
2950 anim_move(
'x', 3, 3, mesh, color, sock);
2951 anim_move(
'y', 3, 1, mesh, color, sock);
2952 anim_move(
'x', 3, 1, mesh, color, sock);
2953 anim_move(
'y', 3, 3, mesh, color, sock);
2956 anim_move(
'x', 3, 1, mesh, color, sock);
2957 anim_move(
'z', 1, 1, mesh, color, sock);
2958 anim_move(
'x', 3, 3, mesh, color, sock);
2959 anim_move(
'y', 3, 1, mesh, color, sock);
2960 anim_move(
'x', 3, 3, mesh, color, sock);
2961 anim_move(
'y', 3, 3, mesh, color, sock);
2962 anim_move(
'x', 3, 1, mesh, color, sock);
2963 anim_move(
'z', 1, 1, mesh, color, sock);
2964 anim_move(
'x', 3, 1, mesh, color, sock);
2965 anim_move(
'z', 1, 1, mesh, color, sock);
2966 anim_move(
'x', 3, 3, mesh, color, sock);
2967 anim_move(
'y', 3, 1, mesh, color, sock);
2968 anim_move(
'x', 3, 3, mesh, color, sock);
2969 anim_move(
'y', 3, 3, mesh, color, sock);
2970 anim_move(
'x', 3, 1, mesh, color, sock);
2973 anim_move(
'y', 3, 2, mesh, color, sock);
2974 anim_move(
'z', 1, 2, mesh, color, sock);
2975 anim_move(
'y', 3, 2, mesh, color, sock);
2976 anim_move(
'z', 1, 2, mesh, color, sock);
2977 anim_move(
'y', 3, 2, mesh, color, sock);
2992 anim_move(
'z', 1, 3, mesh, color, sock);
2993 anim_move(
'x', 1, 1, mesh, color, sock);
2994 anim_move(
'z', 1, 3, mesh, color, sock);
2995 anim_move(
'x', 1, 3, mesh, color, sock);
2996 anim_move(
'y', 3, 3, mesh, color, sock);
2997 anim_move(
'x', 1, 3, mesh, color, sock);
2998 anim_move(
'y', 3, 1, mesh, color, sock);
2999 anim_move(
'x', 1, 1, mesh, color, sock);
3002 anim_move(
'x', 1, 1, mesh, color, sock);
3003 anim_move(
'z', 1, 3, mesh, color, sock);
3004 anim_move(
'x', 1, 3, mesh, color, sock);
3005 anim_move(
'y', 3, 3, mesh, color, sock);
3006 anim_move(
'x', 1, 3, mesh, color, sock);
3007 anim_move(
'y', 3, 1, mesh, color, sock);
3008 anim_move(
'x', 1, 1, mesh, color, sock);
3011 anim_move(
'z', 1, 2, mesh, color, sock);
3012 anim_move(
'y', 3, 1, mesh, color, sock);
3013 anim_move(
'z', 1, 1, mesh, color, sock);
3014 anim_move(
'y', 3, 3, mesh, color, sock);
3015 anim_move(
'x', 1, 3, mesh, color, sock);
3016 anim_move(
'y', 3, 3, mesh, color, sock);
3017 anim_move(
'x', 1, 1, mesh, color, sock);
3018 anim_move(
'y', 3, 1, mesh, color, sock);
3021 anim_move(
'z', 1, 3, mesh, color, sock);
3022 anim_move(
'y', 3, 1, mesh, color, sock);
3023 anim_move(
'z', 1, 1, mesh, color, sock);
3024 anim_move(
'y', 3, 3, mesh, color, sock);
3025 anim_move(
'x', 1, 3, mesh, color, sock);
3026 anim_move(
'y', 3, 3, mesh, color, sock);
3027 anim_move(
'x', 1, 1, mesh, color, sock);
3028 anim_move(
'y', 3, 1, mesh, color, sock);
3037 anim_move(
'y', 3, 1, mesh, color, sock);
3038 anim_move(
'z', 1, 1, mesh, color, sock);
3039 anim_move(
'y', 3, 3, mesh, color, sock);
3040 anim_move(
'x', 1, 3, mesh, color, sock);
3041 anim_move(
'y', 3, 3, mesh, color, sock);
3042 anim_move(
'x', 1, 1, mesh, color, sock);
3043 anim_move(
'y', 3, 1, mesh, color, sock);
3046 anim_move(
'z', 1, 1, mesh, color, sock);
3047 anim_move(
'y', 3, 1, mesh, color, sock);
3048 anim_move(
'z', 1, 1, mesh, color, sock);
3049 anim_move(
'y', 3, 3, mesh, color, sock);
3050 anim_move(
'x', 1, 3, mesh, color, sock);
3051 anim_move(
'y', 3, 3, mesh, color, sock);
3052 anim_move(
'x', 1, 1, mesh, color, sock);
3053 anim_move(
'y', 3, 1, mesh, color, sock);
3056 anim_move(
'z', 1, 1, mesh, color, sock);
3057 anim_move(
'x', 1, 1, mesh, color, sock);
3058 anim_move(
'z', 1, 3, mesh, color, sock);
3059 anim_move(
'x', 1, 3, mesh, color, sock);
3060 anim_move(
'y', 3, 3, mesh, color, sock);
3061 anim_move(
'x', 1, 3, mesh, color, sock);
3062 anim_move(
'y', 3, 1, mesh, color, sock);
3063 anim_move(
'x', 1, 1, mesh, color, sock);
3066 anim_move(
'z', 1, 2, mesh, color, sock);
3067 anim_move(
'x', 1, 1, mesh, color, sock);
3068 anim_move(
'z', 1, 3, mesh, color, sock);
3069 anim_move(
'x', 1, 3, mesh, color, sock);
3070 anim_move(
'y', 3, 3, mesh, color, sock);
3071 anim_move(
'x', 1, 3, mesh, color, sock);
3072 anim_move(
'y', 3, 1, mesh, color, sock);
3073 anim_move(
'x', 1, 1, mesh, color, sock);
3076 anim_move(
'x', 1, 1, mesh, color, sock);
3077 anim_move(
'z', 1, 3, mesh, color, sock);
3078 anim_move(
'x', 1, 3, mesh, color, sock);
3079 anim_move(
'y', 3, 3, mesh, color, sock);
3080 anim_move(
'x', 1, 3, mesh, color, sock);
3081 anim_move(
'y', 3, 1, mesh, color, sock);
3082 anim_move(
'x', 1, 1, mesh, color, sock);
3083 anim_move(
'z', 1, 3, mesh, color, sock);
3084 anim_move(
'x', 1, 1, mesh, color, sock);
3085 anim_move(
'z', 1, 3, mesh, color, sock);
3086 anim_move(
'x', 1, 3, mesh, color, sock);
3087 anim_move(
'y', 3, 3, mesh, color, sock);
3088 anim_move(
'x', 1, 3, mesh, color, sock);
3089 anim_move(
'y', 3, 1, mesh, color, sock);
3090 anim_move(
'x', 1, 1, mesh, color, sock);
3101 cout <<
"Entering solve_top_edges" << endl;
3111 int i4 = max(l4,-1-l4);
3112 int o4 = (l4 >= 0) ? 0 : 1;
3115 cout <<
"Location of 4-th edge: " << i4
3116 <<
" with orientation " << o4 << endl;
3118 if (i4 < 12 && ((i4 < 4) ||
3119 (i4 > 4 && o4 == 0) ||
3129 int i5 = max(l5,-1-l5);
3130 int o5 = (l5 >= 0) ? 0 : 1;
3133 cout <<
"Location of 5-th edge: " << i5
3134 <<
" with orientation " << o5 << endl;
3136 if (i5 < 12 && ((i5 < 4) ||
3137 (i5 > 5 && o5 == 0) ||
3138 (i5 > 4 && o5 == 1) ))
3147 int i6 = max(l6,-1-l6);
3148 int o6 = (l6 >= 0) ? 0 : 1;
3151 cout <<
"Location of 6-th edge: " << i6
3152 <<
" with orientation " << o6 << endl;
3154 if (i6 < 12 && ((i6 < 4) ||
3155 (i6 > 6 && o6 == 0) ||
3156 (i6 > 5 && o6 == 1) ))
3165 int i7 = max(l7,-1-l7);
3166 int o7 = (l7 >= 0) ? 0 : 1;
3169 cout <<
"Location of 7-th edge: " << i7
3170 <<
" with orientation " << o7 << endl;
3172 if (i7 < 12 && ((i7 < 4) ||
3173 (i7 > 7 && o7 == 0) ||
3174 (i7 > 6 && o7 == 1) ))
3186 cout <<
"Entering solve_mid_edges" << endl;
3196 int i8 = max(l8,-1-l8);
3197 int o8 = (l8 >= 0) ? 0 : 1;
3200 cout <<
"Location of 8-th edge: " << i8
3201 <<
" with orientation " << o8 << endl;
3203 if (i8 >= 4 && i8 < 8)
3205 cout <<
"Moving edges from top tier to middle tier is not supported." 3208 else if (i8 < 12 && ((i8 < 4) ||
3209 (i8 > 8 && o8 == 0) ||
3210 (i8 > 7 && o8 == 1) ))
3219 int i9 = max(l9,-1-l9);
3220 int o9 = (l9 >= 0) ? 0 : 1;
3223 cout <<
"Location of 9-th edge: " << i9
3224 <<
" with orientation " << o9 << endl;
3226 if (i9 >= 4 && i9 < 8)
3228 cout <<
"Moving edges from top tier to middle tier is not supported." 3231 else if (i9 < 12 && ((i9 < 4) ||
3232 (i9 > 9 && o9 == 0) ||
3233 (i9 > 8 && o9 == 1) ))
3242 int i10 = max(l10,-1-l10);
3243 int o10 = (l10 >= 0) ? 0 : 1;
3246 cout <<
"Location of 10-th edge: " << i10
3247 <<
" with orientation " << o10 << endl;
3249 if (i10 >= 4 && i10 < 8)
3251 cout <<
"Moving edges from top tier to middle tier is not supported." 3254 else if (i10 < 12 && ((i10 < 4) ||
3255 (i10 > 10 && o10 == 0) ||
3256 (i10 > 9 && o10 == 1) ))
3265 int i11 = max(l11,-1-l11);
3266 int o11 = (l11 >= 0) ? 0 : 1;
3269 cout <<
"Location of 11-th edge: " << i11
3270 <<
" with orientation " << o11 << endl;
3272 if (i11 >= 4 && i11 < 8)
3274 cout <<
"Moving edges from top tier to middle tier is not supported." 3277 else if (i11 < 12 && ((i11 < 4) ||
3278 (i11 > 11 && o11 == 0) ||
3279 (i11 > 10 && o11 == 1) ))
3292 cout <<
"Entering swap_corners" << endl;
3299 for (
int i=0; i<8; i++)
3301 if ((rubik.corn_[3 * i] == c0[0] &&
3302 rubik.corn_[3 * i + 1] == c0[1] &&
3303 rubik.corn_[3 * i + 2] == c0[2]) ||
3304 (rubik.corn_[3 * i] == c0[1] &&
3305 rubik.corn_[3 * i + 1] == c0[2] &&
3306 rubik.corn_[3 * i + 2] == c0[0]) ||
3307 (rubik.corn_[3 * i] == c0[2] &&
3308 rubik.corn_[3 * i + 1] == c0[0] &&
3309 rubik.corn_[3 * i + 2] == c0[1]) ||
3310 (rubik.corn_[3 * i] == c0[2] &&
3311 rubik.corn_[3 * i + 1] == c0[1] &&
3312 rubik.corn_[3 * i + 2] == c0[0]) ||
3313 (rubik.corn_[3 * i] == c0[1] &&
3314 rubik.corn_[3 * i + 1] == c0[0] &&
3315 rubik.corn_[3 * i + 2] == c0[2]) ||
3316 (rubik.corn_[3 * i] == c0[0] &&
3317 rubik.corn_[3 * i + 1] == c0[2] &&
3318 rubik.corn_[3 * i + 2] == c0[1]))
3326 cout <<
"Location of c0 = {"<<c0[0]<<
","<<c0[1]<<
","<<c0[2]<<
"}: " 3338 anim_move(
'z', 1, i0, mesh, color, sock);
3340 anim_move(
'z', 1, 4-i0, mesh, color, sock);
3343 anim_move(
'x', 1, 3, mesh, color, sock);
3345 anim_move(
'x', 1, 1, mesh, color, sock);
3348 anim_move(
'y', 1, 2, mesh, color, sock);
3350 anim_move(
'y', 1, 2, mesh, color, sock);
3353 anim_move(
'z', 3, 2, mesh, color, sock);
3354 anim_move(
'x', 1, 3, mesh, color, sock);
3356 anim_move(
'x', 1, 1, mesh, color, sock);
3357 anim_move(
'z', 3, 2, mesh, color, sock);
3360 anim_move(
'x', 1, 2, mesh, color, sock);
3362 anim_move(
'x', 1, 2, mesh, color, sock);
3366 else if (c1 != NULL)
3370 for (
int i=1; i<8; i++)
3372 if ((rubik.corn_[3 * i] == c1[0] &&
3373 rubik.corn_[3 * i + 1] == c1[1] &&
3374 rubik.corn_[3 * i + 2] == c1[2]) ||
3375 (rubik.corn_[3 * i] == c1[1] &&
3376 rubik.corn_[3 * i + 1] == c1[2] &&
3377 rubik.corn_[3 * i + 2] == c1[0]) ||
3378 (rubik.corn_[3 * i] == c1[2] &&
3379 rubik.corn_[3 * i + 1] == c1[0] &&
3380 rubik.corn_[3 * i + 2] == c1[1]) ||
3381 (rubik.corn_[3 * i] == c1[2] &&
3382 rubik.corn_[3 * i + 1] == c1[1] &&
3383 rubik.corn_[3 * i + 2] == c1[0]) ||
3384 (rubik.corn_[3 * i] == c1[1] &&
3385 rubik.corn_[3 * i + 1] == c1[0] &&
3386 rubik.corn_[3 * i + 2] == c1[2]) ||
3387 (rubik.corn_[3 * i] == c1[0] &&
3388 rubik.corn_[3 * i + 1] == c1[2] &&
3389 rubik.corn_[3 * i + 2] == c1[1]))
3397 cout <<
"Location of piece belonging at " << 0 <<
" (c1) is " 3407 anim_move(
'x', 3, 1, mesh, color, sock);
3409 anim_move(
'x', 3, 3, mesh, color, sock);
3412 anim_move(
'y', 3, 1, mesh, color, sock);
3413 anim_move(
'x', 3, 1, mesh, color, sock);
3415 anim_move(
'x', 3, 3, mesh, color, sock);
3416 anim_move(
'y', 3, 3, mesh, color, sock);
3419 anim_move(
'z', 3, 3, mesh, color, sock);
3420 anim_move(
'x', 3, 3, mesh, color, sock);
3422 anim_move(
'x', 3, 1, mesh, color, sock);
3423 anim_move(
'z', 3, 1, mesh, color, sock);
3426 anim_move(
'x', 3, 3, mesh, color, sock);
3428 anim_move(
'x', 3, 1, mesh, color, sock);
3431 anim_move(
'x', 3, 2, mesh, color, sock);
3433 anim_move(
'x', 3, 2, mesh, color, sock);
3436 anim_move(
'z', 3, 2, mesh, color, sock);
3437 anim_move(
'x', 3, 3, mesh, color, sock);
3439 anim_move(
'x', 3, 1, mesh, color, sock);
3440 anim_move(
'z', 3, 2, mesh, color, sock);
3446 anim_move(
'x', 3, 3, mesh, color, sock);
3447 anim_move(
'z', 1, 1, mesh, color, sock);
3448 anim_move(
'x', 3, 1, mesh, color, sock);
3449 anim_move(
'y', 1, 3, mesh, color, sock);
3450 anim_move(
'z', 1, 3, mesh, color, sock);
3451 anim_move(
'y', 1, 1, mesh, color, sock);
3452 anim_move(
'x', 3, 3, mesh, color, sock);
3453 anim_move(
'z', 1, 3, mesh, color, sock);
3454 anim_move(
'x', 3, 1, mesh, color, sock);
3455 anim_move(
'z', 1, 2, mesh, color, sock);
3464 cout <<
"Entering solve_corner_locations" << endl;
3473 for (
int i=0; i<8; i++)
3475 if (!((rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 0] &&
3476 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 1] &&
3477 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 2]) ||
3478 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 1] &&
3479 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 2] &&
3480 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 0]) ||
3481 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 2] &&
3482 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 0] &&
3483 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 1]) ||
3484 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 2] &&
3485 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 1] &&
3486 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 0]) ||
3487 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 1] &&
3488 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 0] &&
3489 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 2]) ||
3490 (rubik.corn_[3 * i + 0] == corn_colors_[3 * i + 0] &&
3491 rubik.corn_[3 * i + 1] == corn_colors_[3 * i + 2] &&
3492 rubik.corn_[3 * i + 2] == corn_colors_[3 * i + 1])))
3500 cout <<
"First incorrectly filled corner location: " << i0 << endl;
3503 if (i0 < 0) {
return; }
3510 cout <<
"Location of piece belonging at " << i0 <<
" is " << i1 << endl;
3515 cout <<
"Invalid configuration of corners" << endl;
3519 int c0[3] = {rubik.corn_[3 * i0],
3520 rubik.corn_[3 * i0 + 1],
3521 rubik.corn_[3 * i0 + 2]
3523 int c1[3] = {rubik.corn_[3 * i1],
3524 rubik.corn_[3 * i1 + 1],
3525 rubik.corn_[3 * i1 + 2]
3539 cout <<
"Entering solve_bot_corner_locations" << endl;
3552 cout <<
"Location of piece belonging at 0 is " << i0 << endl;
3556 anim_move(
'z', 1, i0, mesh, color, sock);
3566 cout <<
"Location of piece belonging at 1 is " << i1 << endl;
3571 cout <<
"Invalid configuration of corners" << endl;
3577 anim_move(
'y', 3, 3, mesh, color, sock);
3578 anim_move(
'z', 1, 1, mesh, color, sock);
3579 anim_move(
'y', 3, 1, mesh, color, sock);
3580 anim_move(
'x', 3, 1, mesh, color, sock);
3581 anim_move(
'z', 1, 3, mesh, color, sock);
3582 anim_move(
'x', 3, 3, mesh, color, sock);
3583 anim_move(
'y', 3, 3, mesh, color, sock);
3584 anim_move(
'z', 1, 3, mesh, color, sock);
3585 anim_move(
'y', 3, 1, mesh, color, sock);
3586 anim_move(
'z', 1, 2, mesh, color, sock);
3589 anim_move(
'y', 3, 3, mesh, color, sock);
3590 anim_move(
'z', 1, 1, mesh, color, sock);
3591 anim_move(
'y', 3, 1, mesh, color, sock);
3592 anim_move(
'x', 3, 1, mesh, color, sock);
3593 anim_move(
'z', 1, 2, mesh, color, sock);
3594 anim_move(
'x', 3, 3, mesh, color, sock);
3595 anim_move(
'y', 3, 3, mesh, color, sock);
3596 anim_move(
'z', 1, 3, mesh, color, sock);
3597 anim_move(
'y', 3, 1, mesh, color, sock);
3598 anim_move(
'z', 1, 3, mesh, color, sock);
3609 cout <<
"Location of piece belonging at 2 is " << i2 << endl;
3614 cout <<
"Invalid configuration of corners" << endl;
3619 anim_move(
'x', 1, 1, mesh, color, sock);
3620 anim_move(
'z', 1, 1, mesh, color, sock);
3621 anim_move(
'x', 1, 3, mesh, color, sock);
3622 anim_move(
'y', 3, 1, mesh, color, sock);
3623 anim_move(
'z', 1, 3, mesh, color, sock);
3624 anim_move(
'y', 3, 3, mesh, color, sock);
3625 anim_move(
'x', 1, 1, mesh, color, sock);
3626 anim_move(
'z', 1, 3, mesh, color, sock);
3627 anim_move(
'x', 1, 3, mesh, color, sock);
3628 anim_move(
'z', 1, 2, mesh, color, sock);
3635 bool cw,
int * c0,
int * c1,
int * c2)
3641 for (
int i=0; i<8; i++)
3643 if ((rubik.corn_[3 * i] == c0[0] &&
3644 rubik.corn_[3 * i + 1] == c0[1] &&
3645 rubik.corn_[3 * i + 2] == c0[2]) ||
3646 (rubik.corn_[3 * i] == c0[1] &&
3647 rubik.corn_[3 * i + 1] == c0[2] &&
3648 rubik.corn_[3 * i + 2] == c0[0]) ||
3649 (rubik.corn_[3 * i] == c0[2] &&
3650 rubik.corn_[3 * i + 1] == c0[0] &&
3651 rubik.corn_[3 * i + 2] == c0[1]) ||
3652 (rubik.corn_[3 * i] == c0[2] &&
3653 rubik.corn_[3 * i + 1] == c0[1] &&
3654 rubik.corn_[3 * i + 2] == c0[0]) ||
3655 (rubik.corn_[3 * i] == c0[1] &&
3656 rubik.corn_[3 * i + 1] == c0[0] &&
3657 rubik.corn_[3 * i + 2] == c0[2]) ||
3658 (rubik.corn_[3 * i] == c0[0] &&
3659 rubik.corn_[3 * i + 1] == c0[2] &&
3660 rubik.corn_[3 * i + 2] == c0[1]))
3668 cout <<
"Location of c0 = {"<<c0[0]<<
","<<c0[1]<<
","<<c0[2]<<
"}: " 3680 anim_move(
'z', 1, i0, mesh, color, sock);
3682 anim_move(
'z', 1, 4-i0, mesh, color, sock);
3685 anim_move(
'x', 1, 3, mesh, color, sock);
3687 anim_move(
'x', 1, 1, mesh, color, sock);
3690 anim_move(
'y', 1, 2, mesh, color, sock);
3692 anim_move(
'y', 1, 2, mesh, color, sock);
3695 anim_move(
'z', 3, 2, mesh, color, sock);
3696 anim_move(
'x', 1, 3, mesh, color, sock);
3698 anim_move(
'x', 1, 1, mesh, color, sock);
3699 anim_move(
'z', 3, 2, mesh, color, sock);
3702 anim_move(
'x', 1, 2, mesh, color, sock);
3704 anim_move(
'x', 1, 2, mesh, color, sock);
3709 else if (c1 != NULL)
3713 for (
int i=1; i<8; i++)
3715 if ((rubik.corn_[3 * i] == c1[0] &&
3716 rubik.corn_[3 * i + 1] == c1[1] &&
3717 rubik.corn_[3 * i + 2] == c1[2]) ||
3718 (rubik.corn_[3 * i] == c1[1] &&
3719 rubik.corn_[3 * i + 1] == c1[2] &&
3720 rubik.corn_[3 * i + 2] == c1[0]) ||
3721 (rubik.corn_[3 * i] == c1[2] &&
3722 rubik.corn_[3 * i + 1] == c1[0] &&
3723 rubik.corn_[3 * i + 2] == c1[1]) ||
3724 (rubik.corn_[3 * i] == c1[2] &&
3725 rubik.corn_[3 * i + 1] == c1[1] &&
3726 rubik.corn_[3 * i + 2] == c1[0]) ||
3727 (rubik.corn_[3 * i] == c1[1] &&
3728 rubik.corn_[3 * i + 1] == c1[0] &&
3729 rubik.corn_[3 * i + 2] == c1[2]) ||
3730 (rubik.corn_[3 * i] == c1[0] &&
3731 rubik.corn_[3 * i + 1] == c1[2] &&
3732 rubik.corn_[3 * i + 2] == c1[1]))
3740 cout <<
"Location of c1 = {"<<c1[0]<<
","<<c1[1]<<
","<<c1[2]<<
"}: " 3752 anim_move(
'x', 3, 1, mesh, color, sock);
3754 anim_move(
'x', 3, 3, mesh, color, sock);
3757 anim_move(
'y', 3, 1, mesh, color, sock);
3758 anim_move(
'x', 3, 1, mesh, color, sock);
3760 anim_move(
'x', 3, 3, mesh, color, sock);
3761 anim_move(
'y', 3, 3, mesh, color, sock);
3764 anim_move(
'z', 3, 3, mesh, color, sock);
3765 anim_move(
'x', 3, 3, mesh, color, sock);
3767 anim_move(
'x', 3, 1, mesh, color, sock);
3768 anim_move(
'z', 3, 1, mesh, color, sock);
3771 anim_move(
'x', 3, 3, mesh, color, sock);
3773 anim_move(
'x', 3, 1, mesh, color, sock);
3776 anim_move(
'x', 3, 2, mesh, color, sock);
3778 anim_move(
'x', 3, 2, mesh, color, sock);
3781 anim_move(
'z', 3, 2, mesh, color, sock);
3782 anim_move(
'x', 3, 3, mesh, color, sock);
3784 anim_move(
'x', 3, 1, mesh, color, sock);
3785 anim_move(
'z', 3, 2, mesh, color, sock);
3797 anim_move(
'y', 3, 3, mesh, color, sock);
3799 anim_move(
'y', 3, 1, mesh, color, sock);
3802 anim_move(
'x', 3, 3, mesh, color, sock);
3803 anim_move(
'y', 3, 3, mesh, color, sock);
3805 anim_move(
'y', 3, 1, mesh, color, sock);
3806 anim_move(
'x', 3, 1, mesh, color, sock);
3809 anim_move(
'z', 3, 1, mesh, color, sock);
3810 anim_move(
'y', 3, 1, mesh, color, sock);
3812 anim_move(
'y', 3, 3, mesh, color, sock);
3813 anim_move(
'z', 3, 3, mesh, color, sock);
3816 anim_move(
'z', 3, 2, mesh, color, sock);
3817 anim_move(
'y', 3, 1, mesh, color, sock);
3819 anim_move(
'y', 3, 3, mesh, color, sock);
3820 anim_move(
'z', 3, 2, mesh, color, sock);
3823 anim_move(
'y', 3, 2, mesh, color, sock);
3825 anim_move(
'y', 3, 2, mesh, color, sock);
3828 anim_move(
'y', 3, 1, mesh, color, sock);
3830 anim_move(
'y', 3, 3, mesh, color, sock);
3835 else if (c2 != NULL)
3839 for (
int i=2; i<8; i++)
3841 if ((rubik.corn_[3 * i] == c2[0] &&
3842 rubik.corn_[3 * i + 1] == c2[1] &&
3843 rubik.corn_[3 * i + 2] == c2[2]) ||
3844 (rubik.corn_[3 * i] == c2[1] &&
3845 rubik.corn_[3 * i + 1] == c2[2] &&
3846 rubik.corn_[3 * i + 2] == c2[0]) ||
3847 (rubik.corn_[3 * i] == c2[2] &&
3848 rubik.corn_[3 * i + 1] == c2[0] &&
3849 rubik.corn_[3 * i + 2] == c2[1]) ||
3850 (rubik.corn_[3 * i] == c2[2] &&
3851 rubik.corn_[3 * i + 1] == c2[1] &&
3852 rubik.corn_[3 * i + 2] == c2[0]) ||
3853 (rubik.corn_[3 * i] == c2[1] &&
3854 rubik.corn_[3 * i + 1] == c2[0] &&
3855 rubik.corn_[3 * i + 2] == c2[2]) ||
3856 (rubik.corn_[3 * i] == c2[0] &&
3857 rubik.corn_[3 * i + 1] == c2[2] &&
3858 rubik.corn_[3 * i + 2] == c2[1]))
3866 cout <<
"Location of c2 = {"<<c2[0]<<
","<<c2[1]<<
","<<c2[2]<<
"}: " 3876 anim_move(
'y', 3, 1, mesh, color, sock);
3878 anim_move(
'y', 3, 3, mesh, color, sock);
3881 anim_move(
'z', 3, 2, mesh, color, sock);
3882 anim_move(
'y', 3, 3, mesh, color, sock);
3884 anim_move(
'y', 3, 1, mesh, color, sock);
3885 anim_move(
'z', 3, 2, mesh, color, sock);
3888 anim_move(
'z', 3, 3, mesh, color, sock);
3889 anim_move(
'y', 3, 3, mesh, color, sock);
3891 anim_move(
'y', 3, 1, mesh, color, sock);
3892 anim_move(
'z', 3, 1, mesh, color, sock);
3895 anim_move(
'y', 3, 3, mesh, color, sock);
3897 anim_move(
'y', 3, 1, mesh, color, sock);
3900 anim_move(
'y', 3, 2, mesh, color, sock);
3902 anim_move(
'y', 3, 2, mesh, color, sock);
3912 cout <<
"twist_corners performing clockwise twist" << endl;
3914 anim_move(
'x', 3, 1, mesh, color, sock);
3915 anim_move(
'z', 1, 3, mesh, color, sock);
3916 anim_move(
'x', 3, 3, mesh, color, sock);
3917 anim_move(
'z', 1, 3, mesh, color, sock);
3918 anim_move(
'x', 3, 1, mesh, color, sock);
3919 anim_move(
'z', 1, 2, mesh, color, sock);
3920 anim_move(
'x', 3, 3, mesh, color, sock);
3921 anim_move(
'z', 1, 2, mesh, color, sock);
3927 cout <<
"twist_corners performing counter-clockwise twist" << endl;
3929 anim_move(
'y', 1, 1, mesh, color, sock);
3930 anim_move(
'z', 1, 1, mesh, color, sock);
3931 anim_move(
'y', 1, 3, mesh, color, sock);
3932 anim_move(
'z', 1, 1, mesh, color, sock);
3933 anim_move(
'y', 1, 1, mesh, color, sock);
3934 anim_move(
'z', 1, 2, mesh, color, sock);
3935 anim_move(
'y', 1, 3, mesh, color, sock);
3936 anim_move(
'z', 1, 2, mesh, color, sock);
3947 cout <<
"Entering solve_corner_orientations" << endl;
3957 for (
int i=0; i<8; i++)
3959 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
3968 cw = rubik.corn_[3 * i0 + 0] == corn_colors_[3 * i0 + 1];
3974 cw = rubik.corn_[3 * i0 + 0] == corn_colors_[3 * i0 + 2];
3981 if (i0 < 0) {
return; }
3985 cout <<
"First incorrectly oriented corner: " << i0 << endl;
3990 for (
int i=i0+1; i<8; i++)
3992 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
4000 cout <<
"Second incorrectly oriented corner: " << i1 << endl;
4006 for (
int i=i1+1; i<8; i++)
4008 if (rubik.corn_[3 * i + 0] != corn_colors_[3 * i + 0])
4018 cout <<
"Third incorrectly oriented corner: " << i2 << endl;
4022 int c0[3] = {rubik.corn_[3 * i0],
4023 rubik.corn_[3 * i0 + 1],
4024 rubik.corn_[3 * i0 + 2]
4026 int c1[3] = {rubik.corn_[3 * i1],
4027 rubik.corn_[3 * i1 + 1],
4028 rubik.corn_[3 * i1 + 2]
4030 int c2[3] = {rubik.corn_[3 * i2],
4031 rubik.corn_[3 * i2 + 1],
4032 rubik.corn_[3 * i2 + 2]
4040 int c0[3] = {rubik.corn_[3 * i0],
4041 rubik.corn_[3 * i0 + 1],
4042 rubik.corn_[3 * i0 + 2]
4044 int c1[3] = {rubik.corn_[3 * i1],
4045 rubik.corn_[3 * i1 + 1],
4046 rubik.corn_[3 * i1 + 2]
4056 int * e0,
int * e1,
int * e2)
4060 cout <<
"Entering permute_edges" << endl;
4067 for (
int i=0; i<12; i++)
4069 if ((rubik.edge_[2 * i] == e0[0] &&
4070 rubik.edge_[2 * i + 1] == e0[1]) ||
4071 (rubik.edge_[2 * i] == e0[1] &&
4072 rubik.edge_[2 * i + 1] == e0[0]))
4080 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4091 anim_move(
'z', 1, i0, mesh, color, sock);
4093 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4096 anim_move(
'x', 2, 3, mesh, color, sock);
4098 anim_move(
'x', 2, 1, mesh, color, sock);
4101 anim_move(
'y', 2, 3, mesh, color, sock);
4103 anim_move(
'y', 2, 1, mesh, color, sock);
4106 anim_move(
'x', 2, 2, mesh, color, sock);
4108 anim_move(
'x', 2, 2, mesh, color, sock);
4111 anim_move(
'y', 2, 1, mesh, color, sock);
4113 anim_move(
'y', 2, 3, mesh, color, sock);
4116 anim_move(
'y', 1, 1, mesh, color, sock);
4118 anim_move(
'y', 1, 3, mesh, color, sock);
4121 anim_move(
'y', 1, 3, mesh, color, sock);
4123 anim_move(
'y', 1, 1, mesh, color, sock);
4126 anim_move(
'x', 3, 1, mesh, color, sock);
4128 anim_move(
'x', 3, 3, mesh, color, sock);
4131 anim_move(
'x', 1, 1, mesh, color, sock);
4133 anim_move(
'x', 1, 3, mesh, color, sock);
4137 else if (e1 != NULL)
4141 for (
int i=1; i<12; i++)
4143 if ((rubik.edge_[2 * i] == e1[0] &&
4144 rubik.edge_[2 * i + 1] == e1[1]) ||
4145 (rubik.edge_[2 * i] == e1[1] &&
4146 rubik.edge_[2 * i + 1] == e1[0]))
4154 cout <<
"Location of piece belonging at " << 0 <<
" (e1) is " 4165 anim_move(
'y', 1, 1, mesh, color, sock);
4166 anim_move(
'z', 1, i1-1, mesh, color, sock);
4167 anim_move(
'y', 1, 3, mesh, color, sock);
4169 anim_move(
'y', 1, 1, mesh, color, sock);
4170 anim_move(
'z', 1, 5-i1, mesh, color, sock);
4171 anim_move(
'y', 1, 3, mesh, color, sock);
4177 anim_move(
'z', 3, (i1-1)%4, mesh, color, sock);
4178 anim_move(
'x', 3, 2, mesh, color, sock);
4180 anim_move(
'x', 3, 2, mesh, color, sock);
4181 anim_move(
'z', 3, (9-i1)%4, mesh, color, sock);
4187 anim_move(
'z', 2, (i1-5)%4, mesh, color, sock);
4188 anim_move(
'x', 3, 3, mesh, color, sock);
4190 anim_move(
'x', 3, 1, mesh, color, sock);
4191 anim_move(
'z', 2, (13-i1)%4, mesh, color, sock);
4195 else if (e2 != NULL)
4199 for (
int i=2; i<12; i++)
4201 if ((rubik.edge_[2 * i] == e2[0] &&
4202 rubik.edge_[2 * i + 1] == e2[1]) ||
4203 (rubik.edge_[2 * i] == e2[1] &&
4204 rubik.edge_[2 * i + 1] == e2[0]))
4212 cout <<
"Location of e2: " << i2 << endl;
4221 anim_move(
'x', 1, 3, mesh, color, sock);
4222 anim_move(
'y', 3, 1, mesh, color, sock);
4224 anim_move(
'y', 3, 3, mesh, color, sock);
4225 anim_move(
'x', 1, 1, mesh, color, sock);
4231 anim_move(
'z', 3, (i2-2)%4, mesh, color, sock);
4232 anim_move(
'y', 3, 2, mesh, color, sock);
4234 anim_move(
'y', 3, 2, mesh, color, sock);
4235 anim_move(
'z', 3, (10-i2)%4, mesh, color, sock);
4241 anim_move(
'z', 2, (i2-6)%4, mesh, color, sock);
4242 anim_move(
'y', 3, 3, mesh, color, sock);
4244 anim_move(
'y', 3, 1, mesh, color, sock);
4245 anim_move(
'z', 2, (14-i2)%4, mesh, color, sock);
4260 anim_move(
'y', 2, 1, mesh, color, sock);
4261 anim_move(
'z', 1, 1, mesh, color, sock);
4262 anim_move(
'y', 2, 3, mesh, color, sock);
4263 anim_move(
'z', 1, 2, mesh, color, sock);
4264 anim_move(
'y', 2, 1, mesh, color, sock);
4265 anim_move(
'z', 1, 1, mesh, color, sock);
4266 anim_move(
'y', 2, 3, mesh, color, sock);
4270 anim_move(
'y', 2, 1, mesh, color, sock);
4271 anim_move(
'z', 1, 3, mesh, color, sock);
4272 anim_move(
'y', 2, 3, mesh, color, sock);
4273 anim_move(
'z', 1, 2, mesh, color, sock);
4274 anim_move(
'y', 2, 1, mesh, color, sock);
4275 anim_move(
'z', 1, 3, mesh, color, sock);
4276 anim_move(
'y', 2, 3, mesh, color, sock);
4285 cout <<
"Entering solve_edge_locations" << endl;
4294 for (
int i=0; i<12; i++)
4296 if (!((rubik.edge_[2 * i] == edge_colors_[2 * i] &&
4297 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 1]) ||
4298 (rubik.edge_[2 * i] == edge_colors_[2 * i + 1] &&
4299 rubik.edge_[2 * i + 1] == edge_colors_[2 * i])))
4307 cout <<
"First incorrectly filled edge location: " << i0 << endl;
4310 if (i0 < 0) {
return; }
4314 if (i1 < 0 ) { i1 = -1 - i1; }
4317 cout <<
"Location of piece belonging at " << i0 <<
" is " << i1 << endl;
4322 for (
int i=i0+1; i<12; i++)
4324 if (i == i1) {
continue; }
4325 if (!((rubik.edge_[2 * i + 0] == edge_colors_[2 * i + 0] &&
4326 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 1]) ||
4327 (rubik.edge_[2 * i + 0] == edge_colors_[2 * i + 1] &&
4328 rubik.edge_[2 * i + 1] == edge_colors_[2 * i + 0])))
4336 cout <<
"Another incorrectly filled edge location: " << i2 << endl;
4339 if (i1 < 0 || i2 <0)
4341 cout <<
"Invalid configuration of edges" << endl;
4345 int e0[2] = {rubik.edge_[2 * i0], rubik.edge_[2 * i0 + 1]};
4346 int e1[2] = {rubik.edge_[2 * i1], rubik.edge_[2 * i1 + 1]};
4347 int e2[2] = {rubik.edge_[2 * i2], rubik.edge_[2 * i2 + 1]};
4356 int n,
int * e0,
int * e1,
int * e2,
int * e3)
4364 for (
int i=0; i<12; i++)
4366 if ((rubik.edge_[2 * i] == e0[0] &&
4367 rubik.edge_[2 * i + 1] == e0[1]) ||
4368 (rubik.edge_[2 * i] == e0[1] &&
4369 rubik.edge_[2 * i + 1] == e0[0]))
4377 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4388 anim_move(
'z', 1, i0, mesh, color, sock);
4390 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4393 anim_move(
'x', 2, 3, mesh, color, sock);
4395 anim_move(
'x', 2, 1, mesh, color, sock);
4398 anim_move(
'y', 2, 3, mesh, color, sock);
4400 anim_move(
'y', 2, 1, mesh, color, sock);
4403 anim_move(
'x', 2, 2, mesh, color, sock);
4405 anim_move(
'x', 2, 2, mesh, color, sock);
4408 anim_move(
'y', 2, 1, mesh, color, sock);
4410 anim_move(
'y', 2, 3, mesh, color, sock);
4413 anim_move(
'y', 1, 1, mesh, color, sock);
4415 anim_move(
'y', 1, 3, mesh, color, sock);
4418 anim_move(
'y', 1, 3, mesh, color, sock);
4420 anim_move(
'y', 1, 1, mesh, color, sock);
4423 anim_move(
'x', 3, 1, mesh, color, sock);
4425 anim_move(
'x', 3, 3, mesh, color, sock);
4428 anim_move(
'x', 1, 1, mesh, color, sock);
4430 anim_move(
'x', 1, 3, mesh, color, sock);
4434 else if (e1 != NULL)
4438 for (
int i=1; i<12; i++)
4440 if ((rubik.edge_[2 * i] == e1[0] &&
4441 rubik.edge_[2 * i + 1] == e1[1]) ||
4442 (rubik.edge_[2 * i] == e1[1] &&
4443 rubik.edge_[2 * i + 1] == e1[0]))
4451 cout <<
"Location of e1: " << i1 << endl;
4457 anim_move(
'x', 3, 3, mesh, color, sock);
4458 anim_move(
'y', 3, 3, mesh, color, sock);
4459 flip_edges(mesh, color, sock, 2, NULL, NULL);
4460 anim_move(
'y', 3, 1, mesh, color, sock);
4461 anim_move(
'x', 3, 1, mesh, color, sock);
4464 flip_edges(mesh, color, sock, 2, NULL, NULL);
4467 anim_move(
'x', 1, 3, mesh, color, sock);
4468 anim_move(
'y', 3, 1, mesh, color, sock);
4469 flip_edges(mesh, color, sock, 2, NULL, NULL);
4470 anim_move(
'y', 3, 3, mesh, color, sock);
4471 anim_move(
'x', 1, 1, mesh, color, sock);
4477 anim_move(
'z', 3, (i1-2)%4, mesh, color, sock);
4478 anim_move(
'y', 3, 2, mesh, color, sock);
4479 flip_edges(mesh, color, sock, 2, NULL, NULL);
4480 anim_move(
'y', 3, 2, mesh, color, sock);
4481 anim_move(
'z', 3, (10-i1)%4, mesh, color, sock);
4487 anim_move(
'z', 2, (i1-6)%4, mesh, color, sock);
4488 anim_move(
'y', 3, 3, mesh, color, sock);
4489 flip_edges(mesh, color, sock, 2, NULL, NULL);
4490 anim_move(
'y', 3, 1, mesh, color, sock);
4491 anim_move(
'z', 2, (14-i1)%4, mesh, color, sock);
4497 anim_move(
'x', 2, 3, mesh, color, sock);
4498 anim_move(
'z', 1, 3, mesh, color, sock);
4499 anim_move(
'x', 2, 1, mesh, color, sock);
4500 anim_move(
'z', 1, 3, mesh, color, sock);
4501 anim_move(
'x', 2, 3, mesh, color, sock);
4502 anim_move(
'z', 1, 3, mesh, color, sock);
4503 anim_move(
'x', 2, 1, mesh, color, sock);
4504 anim_move(
'z', 1, 3, mesh, color, sock);
4505 anim_move(
'x', 2, 3, mesh, color, sock);
4506 anim_move(
'z', 1, 2, mesh, color, sock);
4507 anim_move(
'x', 2, 1, mesh, color, sock);
4508 anim_move(
'z', 1, 3, mesh, color, sock);
4509 anim_move(
'x', 2, 3, mesh, color, sock);
4510 anim_move(
'z', 1, 3, mesh, color, sock);
4511 anim_move(
'x', 2, 1, mesh, color, sock);
4512 anim_move(
'z', 1, 3, mesh, color, sock);
4513 anim_move(
'x', 2, 3, mesh, color, sock);
4514 anim_move(
'z', 1, 3, mesh, color, sock);
4515 anim_move(
'x', 2, 1, mesh, color, sock);
4516 anim_move(
'z', 1, 2, mesh, color, sock);
4525 for (
int i=0; i<12; i++)
4527 if ((rubik.edge_[2 * i] == e0[0] &&
4528 rubik.edge_[2 * i + 1] == e0[1]) ||
4529 (rubik.edge_[2 * i] == e0[1] &&
4530 rubik.edge_[2 * i + 1] == e0[0]))
4538 cout <<
"Location of e0 = {"<<e0[0]<<
","<<e0[1]<<
"}: " << i0 << endl;
4544 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4549 anim_move(
'z', 1, i0, mesh, color, sock);
4550 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4551 anim_move(
'z', 1, 4-i0, mesh, color, sock);
4554 anim_move(
'x', 2, 3, mesh, color, sock);
4555 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4556 anim_move(
'x', 2, 1, mesh, color, sock);
4559 anim_move(
'y', 2, 3, mesh, color, sock);
4560 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4561 anim_move(
'y', 2, 1, mesh, color, sock);
4564 anim_move(
'x', 2, 2, mesh, color, sock);
4565 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4566 anim_move(
'x', 2, 2, mesh, color, sock);
4569 anim_move(
'y', 2, 1, mesh, color, sock);
4570 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4571 anim_move(
'y', 2, 3, mesh, color, sock);
4574 anim_move(
'y', 1, 1, mesh, color, sock);
4575 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4576 anim_move(
'y', 1, 3, mesh, color, sock);
4579 anim_move(
'y', 1, 3, mesh, color, sock);
4580 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4581 anim_move(
'y', 1, 1, mesh, color, sock);
4584 anim_move(
'x', 3, 1, mesh, color, sock);
4585 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4586 anim_move(
'x', 3, 3, mesh, color, sock);
4589 anim_move(
'x', 1, 1, mesh, color, sock);
4590 flip_edges(mesh, color, sock, 4, NULL, e1, e2, e3);
4591 anim_move(
'x', 1, 3, mesh, color, sock);
4595 else if (e1 != NULL)
4599 for (
int i=1; i<12; i++)
4601 if ((rubik.edge_[2 * i] == e1[0] &&
4602 rubik.edge_[2 * i + 1] == e1[1]) ||
4603 (rubik.edge_[2 * i] == e1[1] &&
4604 rubik.edge_[2 * i + 1] == e1[0]))
4612 cout <<
"Location of e1: " << i1 << endl;
4618 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4621 anim_move(
'y', 3, 1, mesh, color, sock);
4622 anim_move(
'x', 3, 1, mesh, color, sock);
4623 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4624 anim_move(
'x', 3, 3, mesh, color, sock);
4625 anim_move(
'y', 3, 3, mesh, color, sock);
4628 anim_move(
'y', 2, 1, mesh, color, sock);
4629 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4630 anim_move(
'y', 2, 3, mesh, color, sock);
4636 anim_move(
'z', 3, (i1-1)%4, mesh, color, sock);
4637 anim_move(
'x', 3, 2, mesh, color, sock);
4638 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4639 anim_move(
'x', 3, 2, mesh, color, sock);
4640 anim_move(
'z', 3, (9-i1)%4, mesh, color, sock);
4646 anim_move(
'z', 2, (i1-5)%4, mesh, color, sock);
4647 anim_move(
'x', 3, 3, mesh, color, sock);
4648 flip_edges(mesh, color, sock, 4, NULL, NULL, e2, e3);
4649 anim_move(
'x', 3, 1, mesh, color, sock);
4650 anim_move(
'z', 2, (13-i1)%4, mesh, color, sock);
4654 else if (e2 != NULL)
4658 for (
int i=2; i<12; i++)
4660 if ((rubik.edge_[2 * i] == e2[0] &&
4661 rubik.edge_[2 * i + 1] == e2[1]) ||
4662 (rubik.edge_[2 * i] == e2[1] &&
4663 rubik.edge_[2 * i + 1] == e2[0]))
4671 cout <<
"Location of e2: " << i2 << endl;
4677 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4680 anim_move(
'x', 1, 3, mesh, color, sock);
4681 anim_move(
'y', 3, 1, mesh, color, sock);
4682 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4683 anim_move(
'y', 3, 3, mesh, color, sock);
4684 anim_move(
'x', 1, 1, mesh, color, sock);
4690 anim_move(
'z', 3, (i2-2)%4, mesh, color, sock);
4691 anim_move(
'y', 3, 2, mesh, color, sock);
4692 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4693 anim_move(
'y', 3, 2, mesh, color, sock);
4694 anim_move(
'z', 3, (10-i2)%4, mesh, color, sock);
4700 anim_move(
'z', 2, (i2-6)%4, mesh, color, sock);
4701 anim_move(
'y', 3, 3, mesh, color, sock);
4702 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, e3);
4703 anim_move(
'y', 3, 1, mesh, color, sock);
4704 anim_move(
'z', 2, (14-i2)%4, mesh, color, sock);
4708 else if (e3 != NULL)
4712 for (
int i=3; i<12; i++)
4714 if ((rubik.edge_[2 * i] == e3[0] &&
4715 rubik.edge_[2 * i + 1] == e3[1]) ||
4716 (rubik.edge_[2 * i] == e3[1] &&
4717 rubik.edge_[2 * i + 1] == e3[0]))
4725 cout <<
"Location of e3: " << i3 << endl;
4731 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4737 anim_move(
'z', 3, (i3-3)%4, mesh, color, sock);
4738 anim_move(
'x', 1, 2, mesh, color, sock);
4739 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4740 anim_move(
'x', 1, 2, mesh, color, sock);
4741 anim_move(
'z', 3, (7-i3)%4, mesh, color, sock);
4747 anim_move(
'z', 2, (i3-4)%4, mesh, color, sock);
4748 anim_move(
'x', 1, 3, mesh, color, sock);
4749 flip_edges(mesh, color, sock, 4, NULL, NULL, NULL, NULL);
4750 anim_move(
'x', 1, 1, mesh, color, sock);
4751 anim_move(
'z', 2, (12-i3)%4, mesh, color, sock);
4757 anim_move(
'x', 2, 3, mesh, color, sock);
4758 anim_move(
'z', 1, 2, mesh, color, sock);
4759 anim_move(
'x', 2, 1, mesh, color, sock);
4760 anim_move(
'z', 1, 2, mesh, color, sock);
4761 anim_move(
'x', 2, 3, mesh, color, sock);
4762 anim_move(
'z', 1, 3, mesh, color, sock);
4763 anim_move(
'x', 2, 1, mesh, color, sock);
4764 anim_move(
'z', 1, 2, mesh, color, sock);
4765 anim_move(
'x', 2, 3, mesh, color, sock);
4766 anim_move(
'z', 1, 2, mesh, color, sock);
4767 anim_move(
'x', 2, 1, mesh, color, sock);
4768 anim_move(
'z', 1, 1, mesh, color, sock);
4778 cout <<
"Entering solve_edge_orientations" << endl;
4787 for (
int i=0; i<12; i++)
4789 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4797 cout <<
"First incorrectly oriented edge location: " << i0 << endl;
4800 if (i0 < 0) {
return; }
4804 for (
int i=i0+1; i<12; i++)
4806 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4814 cout <<
"Second incorrectly oriented edge location: " << i1 << endl;
4820 for (
int i=i1+1; i<12; i++)
4822 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4832 cout <<
"Third incorrectly oriented edge location: " << i2 << endl;
4836 for (
int i=i2+1; i<12; i++)
4838 if (rubik.edge_[2 * i] != edge_colors_[2 * i])
4846 cout <<
"Fourth incorrectly oriented edge location: " << i3 << endl;
4850 int e0[2] = {rubik.edge_[2 * i0], rubik.edge_[2 * i0 + 1]};
4851 int e1[2] = {rubik.edge_[2 * i1], rubik.edge_[2 * i1 + 1]};
4852 int e2[2] = {rubik.edge_[2 * max(i2,0)], rubik.edge_[2 * max(i2,0) + 1]};
4853 int e3[2] = {rubik.edge_[2 * max(i3,0)], rubik.edge_[2 * max(i3,0) + 1]};
4861 flip_edges(mesh, color, sock, 4, e0, e1, e2, e3);
4873 cout <<
"Solving top center block..." << endl;
4878 cout <<
"Solving top tier edges..." << endl;
4883 cout <<
"Solving center blocks..." << endl;
4887 cout <<
"Solving top tier corners..." << endl;
4891 cout <<
"Move count: " << count_ << endl;
4900 cout <<
"Solving center blocks in the middle tier..." << endl;
4905 cout <<
"Solving edge blocks in the middle tier..." << endl;
4909 cout <<
"Move count: " << count_ << endl;
4917 cout <<
"Solving corner block locations in the bottom tier..." << endl;
4922 cout <<
"Solving corner block orientations..." << endl;
4927 cout <<
"Solving edge block locations..." << endl;
4932 cout <<
"Solving edge block orientations..." << endl;
4943 cout <<
"Solving top center block..." << endl;
4948 cout <<
"Solving top tier edges..." << endl;
4953 cout <<
"Solving top tier corners..." << endl;
4958 cout <<
"Solving center blocks in the middle tier..." << endl;
4963 cout <<
"Solving edge blocks in the middle tier..." << endl;
4968 cout <<
"Solving corner block locations in the bottom tier..." << endl;
4973 cout <<
"Solving corner block orientations..." << endl;
4978 cout <<
"Solving edge block locations..." << endl;
4983 cout <<
"Solving edge block orientations..." << endl;
4987 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.