def __init__(self, methodName='runTest'): super(TestMAstar, self).__init__(methodName) self.g1 = GridWithWeights(4, 4) self.g2 = EightDirectionGrid(4, 4) self.g3 = DynamicBoundGrid(4, 4) self.g4 = DynamicBoundGridWithShortcuts(4, 4) self.g5 = DenseGraph(self.g4) self.g6 = DualityGraph(4, 4)
class TestGrid8D(unittest.TestCase): def __init__(self, methodName='runTest'): super(TestGrid8D, self).__init__(methodName) self.g = EightDirectionGrid(4, 4) def test_case1(self): self.assertSetEqual( set(self.g.neighbors((1, 1))), set([(2, 0), (1, 0), (0, 0), (2, 1), (0, 1), (2, 2), (1, 2), (0, 2)]))
import os import sys import time import matplotlib.pyplot as plt root = os.path.join(os.path.dirname(__file__), '..') sys.path.append(root) from graph.grid8d import EightDirectionGrid from graph.duality_graph import DualityGraph from pathfinder.astar import a_star_search from pathfinder.util import reduce_path, reconstruct_path from shape.Octagon import solid_octagon from shape.OctagonLine import solid_octagon_line if __name__ == '__main__': grid1 = EightDirectionGrid(10000, 10000) grid2 = DualityGraph(10000, 10000) p = 0.0 # for pos in solid_octagon(510, 1000, 20): # grid1.walls.add(pos) # grid2.walls.add(pos) # start1, goal1 = (0, 500), (600, 5100) # start2, goal2 = (10, 500), (600, 5200) # start3, goal3 = (20, 500), (600, 5300) for pos in solid_octagon_line((550, 500), (550, 5500), 20): grid1.walls.add(pos) grid2.walls.add(pos)
def __init__(self, methodName='runTest'): super(TestGrid8D, self).__init__(methodName) self.g = EightDirectionGrid(4, 4)