Bound retries for unreachable path recovery
This commit is contained in:
1 parent
d4eae5ee5f
commit
7ab354800b
4 files changed
+71
-6
No files matched your search
@@ -2,7 +2,7 @@ import unittest
|
||||
from unittest.mock import patch
|
||||
from munch import Munch
|
||||
|
||||
from mosfet.bot import _recover_invalid_path
|
||||
from mosfet.bot import PATH_RECOVERY_MAX_ATTEMPTS, _recover_invalid_path
|
||||
from mosfet.game import Game
|
||||
from mosfet.info import blocks
|
||||
from mosfet.path import AStarTimeout, Pathfinder
|
||||
@@ -214,6 +214,30 @@ class DoorNavigationTests(unittest.TestCase):
|
||||
self.assertEqual(g.path, [start, (0, 64, -1), (1, 64, 0), route[-1]])
|
||||
self.assertIsNone(g.navigation_recovery_target)
|
||||
|
||||
def test_unreachable_recovery_target_is_abandoned_after_bounded_retries(self):
|
||||
class NoRouteWorld:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
def path_to_place(self, start, target):
|
||||
self.calls.append((start, target))
|
||||
return None
|
||||
|
||||
goal = (5, 64, 0)
|
||||
world = NoRouteWorld()
|
||||
g = Munch(
|
||||
path=[], pos=(0.5, 64, 0.5), world=world,
|
||||
navigation_recovery_target=goal, navigation_retry_at=0.0,
|
||||
navigation_recovery_attempts=0, navigation_failed_target=None)
|
||||
|
||||
for now in range(1, PATH_RECOVERY_MAX_ATTEMPTS + 1):
|
||||
_recover_invalid_path(g, now=float(now))
|
||||
|
||||
self.assertEqual(len(world.calls), PATH_RECOVERY_MAX_ATTEMPTS)
|
||||
self.assertIsNone(g.navigation_recovery_target)
|
||||
self.assertEqual(g.navigation_failed_target, goal)
|
||||
self.assertEqual(g.navigation_recovery_attempts, 0)
|
||||
|
||||
def test_invalid_path_is_replanned_to_its_original_destination(self):
|
||||
class FakePathfinder:
|
||||
@staticmethod
|
||||
|
||||
Reference in new issue
Block a user