Example #1
0
        private void FindFailureX10000ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var       stopwatch   = Stopwatch.StartNew();
            const int SearchCount = 10;

            for (int i = 0; i < SearchCount; i++)
            {
                var scramble       = Scrambler.Scamble();
                var solutionFinder = new ShortestSolutionFinder(WellKnownSolvers.Roux);
                var(foundSolution, description, states) = solutionFinder.FindSolution(
                    Rotator.ApplyMoves(Puzzle.Solved, scramble));

                if (!foundSolution)
                {
                    this.txtScrambleMoves.Text = scramble;
                    this.UpdateSolutionUI(description, states);
                    return;
                }
            }
            stopwatch.Stop();

            this.txtScrambleMoves.Text       = string.Empty;
            this.txtSolutionMoves.Text       = string.Empty;
            this.txtSolutionDescription.Text = $"{SearchCount} solutions found in {stopwatch.ElapsedMilliseconds}ms.";
            this.Refresh();
        }
Example #2
0
        private void cmdSolve_Click(object sender, EventArgs e)
        {
            var solutionFinder = new ShortestSolutionFinder(WellKnownSolvers.Roux);

            var(_, description, states) = solutionFinder.FindSolution(
                Rotator.ApplyMoves(Puzzle.Solved, this.txtScrambleMoves.Text));

            UpdateSolutionUI(description, states);
        }