コード例 #1
0
ファイル: Program.cs プロジェクト: ThorMutoAsmund/CubeBasics
        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]);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: ThorMutoAsmund/CubeBasics
        static void TestMinMaxSteps()
        {
            var totalSolves = 3000;
            var cube = new Cube();
            var solver = new SolverClassic(cube);

            var maxSteps = 0;
            var minSteps = 100000;
            var stepAverage = 0;

            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(25, (int)seed);
                cube.Apply(scrambleSequence);
                solver.Solve();

                var steps = solver.TotalStepsWithoutParity;
                if (steps < minSteps)
                {
                    minSteps = steps;
                }
                if (steps > maxSteps)
                {
                    maxSteps = steps;
                }
                stepAverage += steps;

                if (i % 100 == 0)
                {
                    Console.WriteLine(i);
                }
            }

            Console.WriteLine("Minimum number of steps in a solve: {0}", minSteps);
            Console.WriteLine("Maximum number of steps in a solve: {0}", maxSteps);
            Console.WriteLine("Average number of steps in a solve: {0:N2}", stepAverage / totalSolves);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ThorMutoAsmund/CubeBasics
        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);
                }
            }
        }