コード例 #1
0
        /// <summary>
        /// Function that solves the maze using the solver.
        /// </summary>
        public void Solve(IMazeSolver solver, Action <IEnumerable <IMazeCell> > solvedResultCallback)
        {
            if (solver == null)
            {
                throw new ArgumentNullException("solver", "Solver cannot be null");
            }

            if (solvedResultCallback == null)
            {
                throw new ArgumentNullException("solvedResultCallback", "Please provide a callback action");
            }


            _logger.LogInformation($"Solve Using: {solver.GetType().Name}");


            //calls solver's solve method.
            solver.Solve(this, (solvedPath) =>
            {
                if (solvedPath == null)
                {
                    solvedResultCallback(new List <IMazeCell>(0));//return a empty path if the solver could not solve the maze.
                }
                else
                {
                    solvedResultCallback(solvedPath);
                }
            });
        }
コード例 #2
0
        public void SB_SolveTest_01()
        {
            string testObject = "SWA.Ariadne.Logic.SolverBase.Solve";

            foreach (Type solverType in SolverFactory.SolverTypes)
            {
                Maze        maze       = SolverFactoryTest.NewMaze();
                IMazeDrawer mazeDrawer = null;
                IMazeSolver target     = SWA_Ariadne_Logic_SolverFactoryAccessor.CreateSolver(solverType, maze, mazeDrawer);
                target.Solve();

                Assert.IsTrue(maze.IsSolved, testObject + ": " + target.GetType().Name + " did not solve the maze.");
            }
        }
コード例 #3
0
ファイル: AboutBox.cs プロジェクト: wacker-muc/Ariadne
        private void FillMaze()
        {
            // Create a maze with fixed layout.
            mazeUserControl.Setup(5, 2, 3);

            // Draw the maze walls.
            mazeUserControl.MazePainter.PaintMaze(null);

            // Solve the maze.
            IMazeSolver solver = SolverFactory.CreateDefaultSolver(mazeUserControl.Maze, mazeUserControl.MazePainter);

            solver.Reset();
            solver.Solve();
        }