def test_noPath(self): grid = SearchGrid(3, 1) grid.set(1, 0, INPENETRABLE) pathFinder = PathFinder(grid) foundPath = pathFinder.find((0, 0), (2, 0)) self.assertEqual(None, foundPath)
def test_directPathBlockedByImpenetrable(self): grid = SearchGrid(5, 5) grid.set(1, 0, INPENETRABLE) pathFinder = PathFinder(grid) foundPath = pathFinder.find((0, 0), (2, 0)) self.assertEqual([(0, 0), (0, 1), (1, 1), (2, 1), (2, 0)], foundPath)
def test_shortestPathGoesOverExtraCostCell(self): grid = SearchGrid(5, 5) grid.set(1, 0, EXTRACOST) grid.set(1, 1, INPENETRABLE) pathFinder = PathFinder(grid) foundPath = pathFinder.find((0, 0), (2, 0)) self.assertEqual([(0, 0), (1, 0), (2, 0)], foundPath)
def test_set(self): grid = SearchGrid(5, 5) grid.set(1, 1, 10) self.assertEqual(10, grid.get(1, 1))