Пример #1
0
 /// <summary>
 /// Positions the cube so the given color is the up face
 /// </summary>
 /// <param name="color">Color of top face</param>
 public void set_up_face(FaceVal color)
 {
     if (Front.Color == color)
     {
         cu();
     }
     else if (Left.Color == color)
     {
         cr();
         cu();
     }
     else if (Right.Color == color)
     {
         cl();
         cu();
     }
     else if (Back.Color == color)
     {
         cd();
     }
     else if (Down.Color == color)
     {
         cd();
         cd();
     }
 }
Пример #2
0
        /// <summary>
        /// Positions the up edge so it is the given color
        /// </summary>
        /// <param name="color">Color of Edge</param>
        private void position_up_edge(FaceVal color)
        {
            var upColor           = Cube.Up.Color;
            var foundEdgePosition = search_edge(upColor, color);

            if (foundEdgePosition == FaceName.FaceNone)
            {
                return;  //  should NEVER happen
            }
            var face = face_val_to_index(color);

            var sequence = TopEdgeMoves[(int)foundEdgePosition][face];

            Cube.execute_sequence(sequence);
        }
Пример #3
0
        /// <summary>
        /// Get the face that matches the given color
        /// </summary>
        /// <param name="face">Color of face</param>
        /// <returns>Face index</returns>
        private int face_val_to_index(FaceVal face)
        {
            if (face == Cube.Back.Color)
            {
                return((int)FaceSide.BackFace);
            }
            if (face == Cube.Left.Color)
            {
                return((int)FaceSide.LeftFace);
            }
            if (face == Cube.Right.Color)
            {
                return((int)FaceSide.RightFace);
            }

            return((int)FaceSide.FrontFace);
        }
Пример #4
0
        /// <summary>
        /// Position the middle front right edge of the cube
        /// </summary>
        /// <param name="side">Color of face. Should always be right face color</param>
        private void position_middle_front_right_edge(FaceVal side)
        {
            var pos = search_edge(Cube.Front.Color, side);

            // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
            switch (pos)
            {
            case FaceName.MiddleFaceLeft:
                Cube.execute_sequence("l di li di fi d f d ri d r d f di fi");
                break;

            case FaceName.MiddleFaceLeftReverse:
                Cube.execute_sequence("l di li di fi d f f di fi di ri d r");
                break;

            default:
            // ReSharper disable once RedundantCaseLabel
            case FaceName.MiddleFaceFront:
                break;

            case FaceName.MiddleFaceFrontReverse:
                Cube.execute_sequence("ri d r d f di fi d ri d r d f di fi");
                break;

            case FaceName.MiddleFaceRight:
                Cube.execute_sequence("bi d b d r di ri di f di fi di ri d r");
                break;

            case FaceName.MiddleFaceRightReverse:
                Cube.execute_sequence("bi d b d r di ri ri d r d f di fi");
                break;

            case FaceName.MiddleFaceBack:
                Cube.execute_sequence("b di bi di li d l d d ri d r d f di fi");
                break;

            case FaceName.MiddleFaceBackReverse:
                Cube.execute_sequence("b di bi di li d l d f di fi di ri d r");
                break;

            case FaceName.BottomFaceUp:
                Cube.execute_sequence("d d f di fi di ri d r");
                break;

            case FaceName.BottomFaceUpReverse:
                Cube.execute_sequence("di ri d r d f di fi");
                break;

            case FaceName.BottomFaceLeft:
                Cube.execute_sequence("di f di fi di ri d r");
                break;

            case FaceName.BottomFaceLeftReverse:
                Cube.execute_sequence("ri d r d f di fi");
                break;

            case FaceName.BottomFaceDown:
                Cube.execute_sequence("f di fi di ri d r");
                break;

            case FaceName.BottomFaceDownReverse:
                Cube.execute_sequence("d ri d r d f di fi");
                break;

            case FaceName.BottomFaceRight:
                Cube.execute_sequence("d f di fi di ri d r");
                break;

            case FaceName.BottomFaceRightReverse:
                Cube.execute_sequence("d d ri d r d f di fi");
                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Position the upper left front corner
        /// </summary>
        /// <param name="color1">First color of corner</param>
        /// <param name="color2">Second color of corner</param>
        /// <param name="color3">Third color of corner</param>
        private void position_up_left_front_corner(FaceVal color1, FaceVal color2, FaceVal color3)
        {
            var pos = search_corner(color1, color2, color3);

            // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
            switch (pos)
            {
            default:
            // ReSharper disable once RedundantCaseLabel
            case CornerName.CornerUlf123:
                break;

            case CornerName.CornerUlf231:
                Cube.execute_sequence("l di li d l di li");
                break;

            case CornerName.CornerUlf312:
                Cube.execute_sequence("fi d f di fi d f");
                break;

            case CornerName.CornerUlb132:
                Cube.execute_sequence("b d bi d l di li");
                break;

            case CornerName.CornerUlb213:
                Cube.execute_sequence("b di bi d d l di li");
                break;

            case CornerName.CornerUlb321:
                Cube.execute_sequence("b fi d bi f");
                break;

            case CornerName.CornerUrf132:
                Cube.execute_sequence("ri d d r fi d f");
                break;

            case CornerName.CornerUrf213:
                Cube.execute_sequence("ri l di r li");
                break;

            case CornerName.CornerUrf321:
                Cube.execute_sequence("f d d f f d f");
                break;

            case CornerName.CornerUrb123:
                Cube.execute_sequence("bi fi d d f b");
                break;

            case CornerName.CornerUrb231:
                Cube.execute_sequence("bi di l di li b");
                break;

            case CornerName.CornerUrb312:
                Cube.execute_sequence("r d d ri di fi d f");
                break;

            case CornerName.CornerDlf132:
                Cube.execute_sequence("di fi d d f di fi d f");
                break;

            case CornerName.CornerDlf213:
                Cube.execute_sequence("di fi d f");
                break;

            case CornerName.CornerDlf321:
                Cube.execute_sequence("d l di li");
                break;

            case CornerName.CornerDlb123:
                Cube.execute_sequence("fi d d f di fi d f");
                break;

            case CornerName.CornerDlb231:
                Cube.execute_sequence("fi d f");
                break;

            case CornerName.CornerDlb312:
                Cube.execute_sequence("d d l di li");
                break;

            case CornerName.CornerDrf123:
                Cube.execute_sequence("l d d li d l di li");
                break;

            case CornerName.CornerDrf231:
                Cube.execute_sequence("d d fi d f");
                break;

            case CornerName.CornerDrf312:
                Cube.execute_sequence("l di li");
                break;

            case CornerName.CornerDrb132:
                Cube.execute_sequence("l d li d l di li");
                break;

            case CornerName.CornerDrb213:
                Cube.execute_sequence("fi d d f");
                break;

            case CornerName.CornerDrb321:
                Cube.execute_sequence("l d d li");
                break;
            }
        }