Beispiel #1
0
 def test_find_path_out_of_limits(self):
     s = Space((48,32,8))
     p = PathManager(s)
     for x in range(48):
         for y in range(32):
             s[(x,y,6)] = 1
     s[(31,27,7)] = 1
     try:
         p.find_path((31,28,7),(31,27,8))
         self.fail('Expected IndexError')
     except IndexError:
         pass
Beispiel #2
0
 def test_find_path(self):
     s = Space((6,6,3))
     p = PathManager(s)
     for x in range(6):
         for y in range(6):
             s[(x,y,0)] = 1
     self.assertEqual(len(p.find_path((1,2,1),(4,5,1))), 4)
Beispiel #3
0
 def test_find_path_inside_block(self):
     s = Space((3,2,3))
     p = PathManager(s)
     for x in range(3):
         for y in range(2):
             s[(x,y,0)] = 1
     s[(1,0,2)] = 1
     self.assertEqual(p.find_path((2,0,1),(1,0,2)), None)
Beispiel #4
0
 def test_find_path_3d(self):
     s = Space((3,2,3))
     p = PathManager(s)
     for x in range(3):
         for y in range(2):
             s[(x,y,0)] = 1
     s[(1,0,1)] = 1
     e = [(1,0,2),(0,0,1)]
     self.assertEqual(p.find_path((2,0,1),(0,0,1)), e)
Beispiel #5
0
 def test_find_path_prefer_flat(self):
     s = Space((4,2,4))
     p = PathManager(s)
     for x in range(4):
         for y in range(2):
             s[(x,y,0)] = 1
     # two paths, via 2,0,1 or 2,1,1: find the preferred path for flat
     f = p.find_path((1,0,1),(3,0,1))
     not_f0 = (2,0,1) if f[0] == (2,1,1) else (2,1,1)
     # turn into a hill
     s[f[0]] = 1
     # should path around it
     h = p.find_path((1,0,1),(3,0,1))
     self.assertEqual(h[0], not_f0)
     # block new path entirely
     s[h[0]] = 1
     s[(h[0][0],h[0][1],h[0][2]+1)] = 1
     # should be back to first, one step up
     f[0] = (f[0][0], f[0][1], f[0][2]+1)
     self.assertEqual(p.find_path((1,0,1),(3,0,1)), f)
Beispiel #6
0
 def test_no_path(self):
     s = Space((3,2,3))
     p = PathManager(s)
     for x in range(3):
         for y in range(2):
             s[(x,y,0)] = 1
     s[(1,0,1)] = 1
     s[(1,0,2)] = 1
     s[(1,1,1)] = 1
     s[(1,1,2)] = 1
     self.assertEqual(p.find_path((2,0,1),(0,0,1)), None)