public void AstarMoveDownTest1() { // arrange var a = new Astar(new EuclidianHeuristic(), new DownAdjacement()); var grid = GetUnpassableMiddleGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(1, gridHeight - 1); // act var path = a.Process(grid, from, to); ; // assert Assert.IsTrue(path.Count() == 0, "Empty path"); }
public void AstarEmptyPathTestManh() { // arrange var a = new Astar(new ManhattanHeuristic(), new StraightAdjacement()); var grid = GetUnpassableMiddleGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(gridWidth - 1, gridHeight - 1); // act var path = a.Process(grid, from, to); ; // assert Assert.IsTrue(path.Count() == 0, "Empty path"); }
public void PathLenTest1() { //arrange var a = new Astar(new EuclidianHeuristic(), new StraightAdjacement()); var d = new Dijkstra(); var grid = GetTestGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(0, gridHeight - 1); //act var path1 = a.Process(grid, from, to); var path2 = d.Process(grid, from, to); //compare Assert.IsTrue(PathLen(path1) == PathLen(path2), "path length"); }
public void PathEndpointsTest() { //arrange var a = new Astar(new EuclidianHeuristic(), new StraightAdjacement()); var d = new Dijkstra(); var grid = GetTestGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(0, gridHeight - 1); //act var path1 = a.Process(grid, from, to); var path2 = d.Process(grid, from, to); //compare Assert.IsTrue(path1.First().Coordinates == path2.First().Coordinates, "first coord"); Assert.IsTrue(path1.Last().Coordinates == path2.Last().Coordinates, "last coord"); }
public void PathLenTest3() { var a = new Astar(new EuclidianHeuristic(), new StraightAdjacement()); var d = new Dijkstra(); double l1, l2; ICell[,] grid; IEnumerable<ICell> path1, path2; Coordinates from = new Coordinates(0, 0), to = new Coordinates(gridWidth - 1, gridHeight - 1); grid = GetRandomGrid(16); path1 = a.Process(grid, from, to); path2 = d.Process(grid, from, to); l1 = PathLen(path1); l2 = PathLen(path2); Assert.IsTrue(l1 == l2, "path length. A* = " + l1.ToString() + " Dijkstra = " + l2.ToString()); }
public void RandomPathTest() { var rand = new Random(); var a = new Astar(new EuclidianHeuristic(), new StraightAdjacement()); var d = new Dijkstra(); double l1 = 0, l2 = 0; ICell[,] grid; IEnumerable<ICell> path1, path2; Coordinates from = new Coordinates(0, 0), to = new Coordinates(gridWidth - 1, gridHeight - 1); int max = 10000; int count = 0; for (int i = 0; i < max; ++i) { grid = GetRandomGrid(rand); path1 = a.Process(grid, from, to); path2 = d.Process(grid, from, to); l1 = PathLen(path1); l2 = PathLen(path2); if (Math.Abs(l1 / l2) < 1.5) ++count; } Assert.IsTrue(count >= max * 0.6, "too many fails:" + (max - count).ToString()); }
public void AstarMoveDownTest2() { // arrange var a = new Astar(new EuclidianHeuristic(), new DownAdjacement()); var grid = GetUnpassableMiddleGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(0, gridHeight - 1); // act var path = a.Process(grid, from, to); ; // assert Assert.IsTrue(path.First().Coordinates == from, "first coord"); Assert.IsTrue(path.Last().Coordinates == to, "last coord"); }
public void AstarCreating4() { var a = new Astar(new EmptyHeuristic(), new EmptyAdjacement()); Assert.IsFalse(a == null, "Object not created"); }
public void AstarCreating3() { var a = new Astar(null, new EmptyAdjacement()); }
public void AstarCreating2() { var a = new Astar(new EmptyHeuristic(), null); }
public void AstarCreating1() { var a = new Astar(null, null); }
public void AstarSameCoordinatesTestManh() { // arrange var a = new Astar(new ManhattanHeuristic(), new StraightAdjacement()); var grid = GetUnpassableMiddleGrid(); var coord = new Coordinates(0, 0); // act var path = a.Process(grid, coord, coord); // assert Assert.IsTrue(path.First().Coordinates == coord, "Same-Same: first coord"); Assert.IsTrue(path.Last().Coordinates == coord, "Same-Same: last coord"); }
public void AstarPathFoundTestManh() { //arrange var a = new Astar(new ManhattanHeuristic(), new StraightAdjacement()); var grid = GetUnpassableMiddleGrid(); Coordinates from = new Coordinates(0, 0), to = new Coordinates(0, gridHeight - 1); //act var path = a.Process(grid, from, to); //assert Assert.IsTrue(path.First().Coordinates == from, "LT-LB: first coord"); Assert.IsTrue(path.Last().Coordinates == to, "LT-LB: last coord"); }