Exemplo n.º 1
0
        /*
         * This method scrambles a virtual cube, as such
         * it cannot be used with a real cube.
         */
        public static void Randomizer(Cube a, int count)
        {
            Random rand = new Random();
            int    aux;

            for (int i = 0; i < count; i++)
            {
                aux = rand.Next() % 5;
                switch (aux)
                {
                case 0:
                    a.TurnRowCW();
                    break;

                case 1:
                    a.TurnRowCCW();
                    break;

                case 2:
                    a.Roll();
                    break;

                case 3:
                    a.TurnCubeCW();
                    break;

                case 4:
                    a.TurnCubeCCW();
                    break;
                }
            }
            GoToInitial(a);
        }
Exemplo n.º 2
0
 /*
  * This method scrambles a virtual cube, as such
  * it cannot be used with a real cube.
  */
 public static void Randomizer(Cube a, int count)
 {
     Random rand = new Random();
     int aux;
     for (int i = 0; i < count; i++) {
         aux = rand.Next () % 5;
         switch (aux) {
         case 0:
             a.TurnRowCW ();
             break;
         case 1:
             a.TurnRowCCW ();
             break;
         case 2:
             a.Roll ();
             break;
         case 3:
             a.TurnCubeCW ();
             break;
         case 4:
             a.TurnCubeCCW ();
             break;
         }
     }
     GoToInitial (a);
 }
Exemplo n.º 3
0
        /*
         * This method translates the string retrieved from Kociemba's two-phase
         * algorithm into movements of the virtual and real cube (if instantiated).
         */
        public static void TranslateMove(String move, Cube a)
        {
            string aux;
            bool   turn = false;

            for (int i = 0; i < move.Length; i++)
            {
                aux = move.Substring(i, 1);
                switch (aux)
                {
                case "U":
                case "D":
                case "L":
                case "R":
                case "F":
                case "B":
                    turn = true;
                    GoToFace(aux, a);
                    break;

                default:
                    continue;
                }
                if (turn)
                {
                    turn = false;
                    aux  = move.Substring(i + 1, 1);
                    switch (aux)
                    {
                    case "\'":
                        a.TurnRowCCW();
                        break;

                    case "2":
                        a.TurnRow180();
                        break;

                    default:
                        a.TurnRowCW();
                        break;
                    }
                }
            }
            a.RestArm();
        }
Exemplo n.º 4
0
        /*
         * This method translates the string retrieved from Kociemba's two-phase
         * algorithm into movements of the virtual and real cube (if instantiated).
         */
        public static void TranslateMove(String move, Cube a)
        {
            string aux;
            bool turn = false;

            for (int i = 0; i < move.Length; i++){
                aux = move.Substring (i, 1);
                switch (aux) {
                case "U":
                case "D":
                case "L":
                case "R":
                case "F":
                case "B":
                    turn = true;
                    GoToFace (aux, a);
                    break;
                default:
                    continue;
                }
                if (turn){
                    turn = false;
                    aux = move.Substring (i + 1, 1);
                    switch (aux) {
                    case "\'":
                        a.TurnRowCCW ();
                        break;
                    case "2":
                        a.TurnRow180 ();
                        break;
                    default:
                        a.TurnRowCW ();
                        break;
                    }
                }
            }
            a.RestArm ();
        }