Add combat job with safe target filtering
This commit is contained in:
1 parent
2ecaa9a30a
commit
1b9f973db3
12 files changed
+486
-7
No files matched your search
@@ -5,7 +5,8 @@ from munch import Munch
|
||||
from mosfet.bot import _recover_invalid_path
|
||||
from mosfet.game import Game
|
||||
from mosfet.info import blocks
|
||||
from mosfet.path import Pathfinder
|
||||
from mosfet.path import AStarTimeout, Pathfinder
|
||||
from mosfet.world import World
|
||||
|
||||
|
||||
class FakeChunks:
|
||||
@@ -44,6 +45,37 @@ class DoorNavigationTests(unittest.TestCase):
|
||||
finder = Pathfinder(g)
|
||||
self.assertFalse(finder.bair((1, 64, 0)))
|
||||
|
||||
def test_world_pathfinder_receives_custom_timeout(self):
|
||||
calls = []
|
||||
|
||||
class FakePathfinder:
|
||||
def __init__(self, global_state, timeout):
|
||||
calls.append((global_state, timeout))
|
||||
|
||||
@staticmethod
|
||||
def astar(start, destination):
|
||||
return [start, destination]
|
||||
|
||||
world = World.__new__(World)
|
||||
world.g = Munch(job=None)
|
||||
with patch('mosfet.world.path.Pathfinder', FakePathfinder):
|
||||
route = world.path_to_place(
|
||||
(0, 64, 0), (1, 64, 0), timeout=0.1)
|
||||
|
||||
self.assertEqual(route, [(0, 64, 0), (1, 64, 0)])
|
||||
self.assertEqual(calls, [(world.g, 0.1)])
|
||||
|
||||
def test_pathfinder_honors_custom_search_timeout(self):
|
||||
g = Munch(chunks=FakeChunks({}), crawling=False,
|
||||
unopenable_doors=set())
|
||||
with patch('mosfet.path.time.monotonic', return_value=10.0):
|
||||
finder = Pathfinder(g, timeout=0.1)
|
||||
|
||||
self.assertEqual(finder.timeout, 0.1)
|
||||
with patch('mosfet.path.time.monotonic', return_value=10.101):
|
||||
with self.assertRaises(AStarTimeout):
|
||||
finder.neighbors((0, 64, 0))
|
||||
|
||||
def test_path_prefix_detects_new_obstacles_and_missing_support(self):
|
||||
class TerrainChunks:
|
||||
def __init__(self):
|
||||
|
||||
Reference in new issue
Block a user