private void SecondLayer() { for (int c = 0; c < SideColors.Length; c++) { // Gets the edge that needs to be moved. Cubie edge = _cube.FindEdge(SideColors[c], SideColors[(c + 1) % 4]); if (!_cube.IsCubiePlacedCorrectly(edge)) { ChangeView(new CubeView(SideColors[c], FINAL_COLOR)); // If the edge is in the middle layer and it is located in the back face, // the view will be set to the back face. Then the program will use the algorithm to switch // the edges. if (edge.Y == 1) { if (edge.Z == 2) { ChangeView(new CubeView(SideColors[(c + 2) % 4], FINAL_COLOR)); } if (edge.X == 0) { AddMoveList(Algorithms.SecondLayerLeft); } else { AddMoveList(Algorithms.SecondLayerRight); } } // Sets the view. if (edge.UpColor == SideColors[c]) { ChangeView(new CubeView(SideColors[(c + 1) % 4], FINAL_COLOR)); } else { ChangeView(new CubeView(SideColors[c], FINAL_COLOR)); } // Rotates the upper layer until the edge is in the front face. while (edge.Z != 0) { AddMove(Move.Up); } // Use the algorithm to place the edge in the correct position. if (_cube.FindCenter((RubiksColor)edge.UpColor).LeftColor == edge.UpColor) { AddMoveList(Algorithms.SecondLayerLeft); } else { AddMoveList(Algorithms.SecondLayerRight); } } } }