public void GivenValidHeuristic_ShouldBuildSmallerGraph() { var map2D = new Map2D(14, 14); var goalPosition = map2D.Tiles[11, 12]; var pathFinder = new PathFinder <Tile>(_heuristic, 14 * 14, map2D.IndexMap(), map2D.NeighboursManhattan()); var graph = pathFinder.BuildGraph(map2D.Tiles[0, 2], goalPosition); var test = graph.Where(x => x != null).Select(x => x.Heuristic).ToList(); Assert.AreEqual(63, graph.Count(x => x != null)); }
public void TwoDimensionalLargeTest() { _map2D = new Map2D(20, 20); var pathFinder = new PathFinder <Tile>(_heuristic, 20 * 20, _map2D.IndexMap(), _map2D.NeighboursManhattan()); var path = pathFinder.Path(_map2D.Tiles[0, 0], _map2D.Tiles[19, 19]); Assert.AreEqual(38, path.Length); }
public void GivenNoHeuristic_ShouldBuildBigGraph() { var map2D = new Map2D(14, 14); var goalPosition = map2D.Tiles[11, 12]; var pathFinder = new PathFinder <Tile>(delegate { return(0); }, 14 * 14, map2D.IndexMap(), map2D.NeighboursManhattan()); var graph = pathFinder.BuildGraph(map2D.Tiles[0, 2], goalPosition); Assert.AreEqual(192, graph.Count(x => x != null)); }
public void TwoDimensionalTest() { _map2D = new Map2D(4, 4); var pathFinder = new PathFinder <Tile>(_heuristic, 4 * 4, _map2D.IndexMap(), _map2D.NeighboursManhattan()); _map2D.Tiles[0, 1].IsBlocking = true; _map2D.Tiles[2, 0].IsBlocking = true; var path = pathFinder.Path(_map2D.Tiles[0, 0], _map2D.Tiles[3, 3]); Assert.AreEqual(6, path.Length); }