Esempio n. 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;
        }
Esempio n. 2
0
        static void TestSolve(Func<Cube, ISolver> solverCreator)
        {
            var totalSolves = 100;
            var cube = new Cube();
            var solver = solverCreator(cube);

            Console.WriteLine("Performing {0} solves using {1}", totalSolves, solver);
            for (int i = 0; i < totalSolves; ++i)
            {
                cube.Reset();

                var seed = DateTime.Now.Ticks;
                var scrambleSequence = cube.Scramble(4+(int)(seed % 4), (int)seed);
                cube.Apply(scrambleSequence);
                solver.Solve();

                if (!cube.IsSolved())
                {
                    Console.WriteLine("Not solved (seed={0})!", seed);
                    Console.Write("Seq: ");
                    foreach (var turn in scrambleSequence)
                    {
                        Console.Write(turn); Console.Write(" ");
                    }
                    Console.WriteLine();
                    solver.Describe();
                    break;
                }
                if (i % 100 == 0)
                {
                    Console.WriteLine(i);
                }
            }
        }