Beispiel #1
0
        /// <summary>
        /// This test shows that either the cube is solved and had no parity OR the UF BD cubies are swapped and it had parity
        /// </summary>
        /// <param name="solver"></param>
        /// <param name="cube"></param>
        /// <returns></returns>
        static int GetState(SolverM2 solver, Cube cube)
        {
            var state = cube.IsSolved() ? StateSolved : StateNotSolved;
            state += (solver.HasParity ? StateHasParity : 0);

            var cubie = cube[Sticker.sUF];
            if (cubie.Type != Sticker.sUF)
            {
                state += StateUFBDSwapped;
            }

            return state;
        }
Beispiel #2
0
        static void M2Stats()
        {
            var totalSolves = 1000;
            var cube = new Cube();
            var solver = new SolverM2(cube);
            var states = new Dictionary<int, int>();
            for (int i = 0; i < totalSolves; ++i)
            {
                cube.Reset();

                var seed = DateTime.Now.Ticks;
                var scrambleSequence = cube.Scramble(20+(int)(seed % 20), (int)seed);
                cube.Apply(scrambleSequence);
                solver.Solve(SolverM2.M2SolveMode.CornersParityEdges);
                
                var state = GetState(solver, cube);
                if (states.ContainsKey(state))
                {
                    states[state]++;
                }
                else
                {
                    states[state] = 1;
                }

                //if (state != 0 && state != 1 && state != 11 && state != 19)
                //{
                //    Console.WriteLine("FAIL");
                //    Console.WriteLine("Seed: {0}", seed);
                //    Console.Write("Seq: ");
                //    foreach (var turn in scrambleSequence)
                //    {
                //        Console.Write(turn); Console.Write(" ");
                //    }
                //    Console.WriteLine();
                //    Console.WriteLine("Parity: {0}", solver.HasParity ? "yes" : "no");
                //    solver.Describe();

                //    break;
                //}
            }

            Console.WriteLine();
            Console.WriteLine("STATS");
            foreach (int key in states.Keys)
            {
                Console.WriteLine("Key {0} = {1} times", key, states[key]);
            }
        }
Beispiel #3
0
 /// <summary>
 /// This test shows that the UF cubie is either correct or contains the DB cubie. either is 50-50
 /// </summary>
 /// <param name="solver"></param>
 /// <param name="cube"></param>
 /// <returns></returns>
 static int GetStateUFTest(SolverM2 solver, Cube cube)
 {
     var cubie = cube[Sticker.sUF];
     if (cubie.Type == Sticker.sUF && !cubie.IsCorrect)
     {
         return StateBufferRotated;
     }
     else if (cubie.Type != Sticker.sUF)
     {
         return (int)cubie.Type;
     }
     else
         return StateBufferOK;
 }
Beispiel #4
0
 /// <summary>
 /// This test shows that the cubie opposite the buffer (UB) always contains the right cubie rotated right!
 /// </summary>
 /// <param name="solver"></param>
 /// <param name="cube"></param>
 /// <returns></returns>
 static int GetStateOppositeBufferTest(SolverM2 solver, Cube cube)
 {
     var cubie = cube[Sticker.sUB];
     if (cubie.Type == Sticker.sUB && !cubie.IsCorrect)
     {
         return StateBufferRotated;
     }
     else if (cubie.Type != Sticker.sUB)
     {
         return StateBufferWrong;
     }
     else
         return StateBufferOK;
 }
Beispiel #5
0
 /// <summary>
 /// This test shows that when the DB cubie is not correct (that is contains the UF cubie) this cubie is always oriented 98 (rotated twice around x-axis)
 /// </summary>
 /// <param name="solver"></param>
 /// <param name="cube"></param>
 /// <returns></returns>
 static int GetStateDBOrientationTest(SolverM2 solver, Cube cube)
 {
     var cubie = cube[Sticker.sDB];
     if (cubie.Type == Sticker.sDB && !cubie.IsCorrect)
     {
         return StateBufferRotated;
     }
     else if (cubie.Type != Sticker.sDB)
     {
         return (int)cubie.Orientation;
     }
     else
         return StateBufferOK;
 }