public void Create_NewAStarGrid4X4WithBlocked16_FindPath()
        {
            GridSearchNode initialState = _basicWorld4X416.GetInitialSearchNode <GridSearchNode>();
            AStarMax       astar        = new AStarMax(initialState, new GoalOnLocation(_basicWorld4X416.Goal));

            Assert.IsNotNull(astar);
            astar.Run(Int32.MaxValue);
            var maxGoal = astar.GetMaxGoal();

            Assert.AreEqual(10, maxGoal.g);
        }
        public void Create_NewAStarGrid3X3_findPath()
        {
            GridSearchNode initialState = _basicWorld3X3.GetInitialSearchNode <GridSearchNode>();
            AStarMax       astar        = new AStarMax(initialState, new GoalOnLocation(_basicWorld3X3.Goal));

            Assert.IsNotNull(astar);
            astar.Run(Int32.MaxValue); //Prevent stoping by time, should stop only when goal found
            var maxGoal = astar.GetMaxGoal();

            Assert.AreEqual(8, maxGoal.g);
        }
        public void Basic_Hbsd_findPathAstar()
        {
            GridSearchNode  initialState   = _basicBlocked5X5World.GetInitialSearchNode <GridSearchNode>();
            IPrunningMethod prunningMethod = new HashedBasicSymmetryDetectionPrunning();
            Solver          solver         = new AStarMax(initialState, prunningMethod, new GoalOnLocation(_basicBlocked5X5World.Goal));

            Assert.IsNotNull(solver);
            solver.Run(Int32.MaxValue); //Prevent stoping by time, should stop only when goal found
            var maxGoal = solver.GetMaxGoal();

            Assert.AreEqual(20, maxGoal.g);
        }
        public void Run_NewAStarSnake()
        {
            World    w             = new World(4, 2);
            var      heuristicFunc = new SnakeLegalHeuristic();
            Snake    snake         = new Snake(w, 0, heuristicFunc);
            AStarMax astar         = new AStarMax(snake, new ImplicitGoal());

            astar.Run(100);
            var maxGoal = astar.GetMaxGoal();

            Assert.IsNotNull(maxGoal);
        }
        public void AStarGrid_BasicRun_BCCHeuristicsHBSD_Success()
        {
            GridSearchNode initialState = _basicWorldT1S0.GetInitialSearchNode <GridSearchNode>();
            AStarMax       astar        = new AStarMax(initialState, new HashedBasicSymmetryDetectionPrunning(), new GoalOnLocation(_basicWorldV1.Goal));

            Assert.IsNotNull(astar);
            var howEnded = astar.Run(Int32.MaxValue);
            var maxGoal  = astar.GetMaxGoal();

            Assert.IsNotNull(maxGoal);
            Assert.AreEqual(State.Ended, howEnded);
        }
        public void AStarGrid_BasicRunWithBCCHeuristics_Success()
        {
            GridSearchNode initialState = _basicWorldV1.GetInitialSearchNode <GridSearchNode>();
            AStarMax       astar        = new AStarMax(initialState, new GoalOnLocation(_basicWorldV1.Goal));

            Assert.IsNotNull(astar);
            var howEnded = astar.Run(Int32.MaxValue);
            var maxGoal  = astar.GetMaxGoal();

            Assert.IsNotNull(maxGoal);
            Assert.AreEqual(State.Ended, howEnded);
        }
        public void Run_AStarGrid4X4WithBlocked16_StopsByMemoryConstraint()
        {
            GridSearchNode initialState = _basicWorld4X416.GetInitialSearchNode <GridSearchNode>();
            AStarMax       astar        = new AStarMax(initialState, new GoalOnLocation(_basicWorld4X416.Goal));

            Assert.IsNotNull(astar);
            var howEnded = astar.Run(Int32.MaxValue, 1); //One MB memory limit
            var maxGoal  = astar.GetMaxGoal();

            Assert.IsNull(maxGoal);
            Assert.AreEqual(State.StoppedByMemoryLimit, howEnded);
        }
        public void Run_NewAStarBox()
        {
            World w             = new World(5, 2, 2);
            var   heuristicFunc = new SnakeNoneHeuristic();

            int[]        snakeHeads = new int[] { 0, 31 };
            BoxCartesian b          = new BoxCartesian(w, snakeHeads, new BoxNoneHeuristic(), heuristicFunc);
            AStarMax     astar      = new AStarMax(b, new ImplicitGoal());

            astar.Run(1);
            var maxGoal = astar.GetMaxGoal();

            Assert.IsNotNull(maxGoal);
        }
        public void AStarGrid_BasicRun_BCCHeuristicsRSD_Success2()
        {
            RsdGridSearchNode initialState             = _basicWorldBccAndPruningCheck.GetInitialSearchNode <RsdGridSearchNode>();
            ReachableSymmetryDetectionPrunning pruning = new ReachableSymmetryDetectionPrunning();
            AStarMax astar = new AStarMax(initialState, pruning, new GoalOnLocation(_basicWorldV1.Goal));

            Assert.IsNotNull(astar);
            pruning.setAstarOpenList(astar.OpenList);
            var howEnded = astar.Run(Int32.MaxValue);
            var maxGoal  = astar.GetMaxGoal();

            Assert.IsNotNull(maxGoal);
            Assert.AreEqual(State.Ended, howEnded);
        }
Esempio n. 10
0
 public void Compare_AStar_To_DfBNB()
 {
     foreach (var world in _worlds)
     {
         AStarMax astar = new AStarMax(world.GetInitialSearchNode <GridSearchNode>(), new GoalOnLocation(world.Goal));
         Assert.IsNotNull(astar);
         astar.Run(Int32.MaxValue);
         var      AstarMaxGoal = astar.GetMaxGoal();
         DfBnbMax dfbnb        = new DfBnbMax(world.GetInitialSearchNode <GridSearchNode>(), new GoalOnLocation(world.Goal));
         Assert.IsNotNull(dfbnb);
         dfbnb.Run(Int32.MaxValue);
         var DfbnbMaxGoal = dfbnb.GetMaxGoal();
         Assert.AreEqual(AstarMaxGoal.g, DfbnbMaxGoal.g);
     }
 }
Esempio n. 11
0
        public void setAstarSolve_BasicWorld4x4_SolveCorrectly()
        {
            ReachableSymmetryDetectionPrunning rsd = new ReachableSymmetryDetectionPrunning();
            AStarMax solver = new AStarMax(_basicWorld4x4.GetInitialSearchNode <RsdGridSearchNode>(), rsd, new GoalOnLocation(_basicWorld4x4.Goal));

            rsd.setAstarOpenList(solver.OpenList);
            Assert.IsNotNull(rsd);
            Assert.IsNotNull(solver);
            var howEnded = solver.Run(10);

            Assert.AreEqual(State.Ended, howEnded);
            var goal = (RsdGridSearchNode)solver.GetMaxGoal();

            Assert.IsNotNull(goal);
            Assert.AreEqual(14, goal.g);
        }
Esempio n. 12
0
        public void Integration_altbccWithRsdBug_ShouldFindSolution()
        {
            _specialCase01 = new World(File.ReadAllText(@"..\..\altbcc-rsd-bug001.grd"), new AlternateStepsBiconnectedComponentsHeuristic());
            var      prune = new ReachableSymmetryDetectionPrunning();
            AStarMax astar = new AStarMax(_specialCase01.GetInitialSearchNode <RsdGridSearchNode>(), prune, new GoalOnLocation(_specialCase01.Goal));

            Assert.IsNotNull(astar);
            prune.setAstarOpenList(astar.OpenList);
            astar.Run(Int32.MaxValue);
            var      AstarMaxGoal = astar.GetMaxGoal();
            DfBnbMax dfbnb        = new DfBnbMax(_specialCase01.GetInitialSearchNode <GridSearchNode>(), new GoalOnLocation(_specialCase01.Goal));

            Assert.IsNotNull(dfbnb);
            dfbnb.Run(Int32.MaxValue);
            var DfbnbMaxGoal = dfbnb.GetMaxGoal();

            Assert.AreEqual(AstarMaxGoal.g, DfbnbMaxGoal.g);
        }