private void SetupWorld(int width, int height)
        {
            _world = WorldBuilder.CreateEmptyWorld(width, height);

            _costCalc      = new BooleanMapCostCalculator(_world);
            _heuristicCalc = new TargetedHeuristic(new Coordinate(0, 0));

            _explorer = new PathfinderEngine(_world.Width, _world.Height, _costCalc, _heuristicCalc);
        }
Esempio n. 2
0
        public void EnsureHorizontalAndVerticalMovementCostFunctionsCorrectly()
        {
            var world = new World <bool>(2, 1, true);

            var costCalculator = new BooleanMapCostCalculator(world);

            costCalculator.HorizontalAndVerticalMovementCost = 10;

            Assert.AreEqual(10, costCalculator.CalculateCost(0, 0, 1, 0, 1, 0));
            Assert.AreEqual(10, costCalculator.CalculateCost(0, 0, -1, 0, -1, 0));
            Assert.AreEqual(10, costCalculator.CalculateCost(0, 0, 0, 1, 0, 1));
            Assert.AreEqual(10, costCalculator.CalculateCost(0, 0, 0, -1, 0, -1));
        }
Esempio n. 3
0
        public void EnsureDiagonalMovementCostFunctionsCorrectly()
        {
            var world = new World <bool>(2, 2, true);

            var costCalculator = new BooleanMapCostCalculator(world);

            costCalculator.DiagonalMovementCost = 14;

            Assert.AreEqual(14, costCalculator.CalculateCost(0, 0, 1, 1, 1, 1));
            Assert.AreEqual(14, costCalculator.CalculateCost(0, 0, 1, -1, 1, -1));
            Assert.AreEqual(14, costCalculator.CalculateCost(0, 0, -1, 1, -1, 1));
            Assert.AreEqual(14, costCalculator.CalculateCost(0, 0, -1, -1, -1, -1));
        }
Esempio n. 4
0
        public void CheckICanIdentifyOpenAndClosedCells()
        {
            var world          = new World <bool>(1, 1, true);
            var costCalculator = new BooleanMapCostCalculator(world);

            // Open State
            world[0, 0] = true;
            var open = costCalculator.OpenCheck(0, 0);

            Assert.AreEqual(open, true);

            // Closed State
            world[0, 0] = false;
            open        = costCalculator.OpenCheck(0, 0);
            Assert.AreEqual(open, false);
        }
Esempio n. 5
0
        private void ExploreFrom(Coordinate from)
        {
            // Set Pins
            _mapHost.ShowBluePin(from);

            // Setup
            var costCalculator = new BooleanMapCostCalculator(_world)
            {
                BlockPartialDiagonals             = BlockPartialDiagonals,
                HorizontalAndVerticalMovementCost = EdgeMovementCost,
                DiagonalMovementCost = DiagonalMovementCost
            };
            var heuristic  = new EmptyHeuristicCalculator();
            var pathfinder = new PathfinderEngine(_world.Width, _world.Height, costCalculator, heuristic, _movementMode);

            PerformExplore(pathfinder, from);
        }
Esempio n. 6
0
        public void Execute(object parameter)
        {
            // Set Pins
            _mapHost.ShowBluePin(_from);
            _mapHost.ShowGreenPin(_to);

            // Setup
            var costCalculator = new BooleanMapCostCalculator(_world)
            {
                BlockPartialDiagonals = _blockPartialDiagonals
            };
            var heuristic  = new TargetedHeuristic(_to);
            var pathfinder = new PathfinderEngine(_world.Width, _world.Height, costCalculator, heuristic, _moveMode);

            _mapHost.ClearMap();

            pathfinder.ExploreFrom(_from);

            // TODO: Load Pathfinder into host
            // TODO: Reset WorkQueue
        }