public void RectNodesFromEmptyUnevenGridLatticeTest() { List <RectifyRectangle> result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice(10, 20)); Assert.AreEqual(1, result.Count, "Didn't get the single Rectangle as expected"); List <RectifyRectangle> result2 = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice(15, 10)); Assert.AreEqual(1, result2.Count, "Didn't get the single Rectangle as expected"); }
public void TestSingleCellObstruction() { var result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice(10)); var pathfinder = new RectifyPathfinder(result, StandardLatticeParams); pathfinder.ReplaceCellAt(new Position(2, 4), 7); var resultPath = pathfinder.CalculatePath(new Position(3, 4), new Position(1, 3)); Assert.AreEqual(4, resultPath.Count, "path was not length 4 as expected"); resultPath = pathfinder.CalculatePath(new Position(3, 4), new Position(1, 4)); Assert.AreEqual(5, resultPath.Count, "path was not length 5 as expected"); }
public void BiggerSequentialEdgeAdditionTest() { var result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice(10)); var pathfinder = new RectifyPathfinder(result, StandardLatticeParams); //add edges to the same cell one after another pathfinder.ReplaceCellEdgeAt(new Position(6, 4), Direction.West, EdgeType.Wall); pathfinder.ReplaceCellEdgeAt(new Position(6, 4), Direction.South, EdgeType.Wall); pathfinder.ReplaceCellEdgeAt(new Position(7, 4), Direction.West, EdgeType.Wall); var resultPath = pathfinder.CalculatePath(new Position(3, 3), new Position(8, 2)); Assert.AreNotEqual(0, resultPath.Count, "Did not find expected path"); }
public void TestPathAfterNewEdges() { var result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice(10, 10)); var pathfinder = new RectifyPathfinder(result, StandardLatticeParams); for (int i = 0; i < 10; i++) { pathfinder.ReplaceCellEdgeAt(new Position(7, i), Direction.West, EdgeType.Wall); } var resultPath = pathfinder.CalculatePath(new Position(0, 6), new Position(9, 5)); Assert.AreEqual(0, resultPath.Count, "Did not generate a zero path as expected"); pathfinder.ReplaceCellEdgeAt(new Position(5, 2), Direction.North, EdgeType.Wall); resultPath = pathfinder.CalculatePath(new Position(0, 6), new Position(9, 5)); Assert.AreEqual(0, resultPath.Count, "Did not generate a zero path as expected"); }
public void SequentialEdgeAdditionTest() { var result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice()); var pathfinder = new RectifyPathfinder(result, StandardLatticeParams); //add edges to the same cell one after another pathfinder.ReplaceCellEdgeAt(new Position(1, 1), Direction.West, EdgeType.Wall); var resultPath = pathfinder.CalculatePath(new Position(0, 1), new Position(1, 1)); Assert.AreNotEqual(2, resultPath.Count, "Did not path around wall edge as expected"); pathfinder.ReplaceCellEdgeAt(new Position(1, 1), Direction.South, EdgeType.Wall); resultPath = pathfinder.CalculatePath(new Position(0, 1), new Position(1, 1)); Assert.AreNotEqual(2, resultPath.Count, "Did not path around wall edge as expected"); pathfinder.ReplaceCellEdgeAt(new Position(1, 1), Direction.East, EdgeType.Wall); resultPath = pathfinder.CalculatePath(new Position(0, 0), new Position(2, 0)); Assert.AreEqual(3, resultPath.Count, "Did not path around wall edge as expected"); }
public void LatticeGetBoundsTest() { var result = Rectify.MakeRectangles(GridLatticeTestData.EmptyGridLattice()); Assert.AreEqual(1, result.Count, "Did not get 1 initial rectangles as expected"); var pathfinder = new RectifyPathfinder(result, StandardLatticeParams); var bounds = pathfinder.GetRectBordersFromPoint(new Position(0, 0)); Assert.AreEqual(3, bounds.Item2.xPos, "did not get 3 width as expected"); var altLattice = new GridLattice <IRectGrid>(10); GridLatticeTestData.InitGridLattice(altLattice); altLattice[0, 0, Direction.East] = new RectGridCell(1, 1); result = Rectify.MakeRectangles(altLattice); //cell at 0,0; the rest of the row (1,0 -> 10,0), and the rest of the grid (0,1 -> 10,10) Assert.AreEqual(3, result.Count, "Did not get 3 rectangles as expected"); var altfinder = new RectifyPathfinder(result, StandardLatticeParams); }