Allow sign-bounded work destinations via any route

This commit is contained in:
Tanner committed 2026-11-14 17:35:23 +00:00
1 parent cdb90730bd
commit 2191f99a29
2 files changed
+25 -22

No files matched your search

+15 -11
View File
@@ -138,7 +138,7 @@ class SignReadingTests(unittest.TestCase):
'shape': 'square', 'side': 'front',
}])
def test_work_paths_obey_sign_boundary_but_cache_paths_do_not(self):
def test_work_paths_check_destination_only_but_cache_paths_bypass_signs(self):
sign_data = {'front_text': {'messages': [
'mosfet1', 'stay within 25 square', '', '',
]}}
@@ -150,23 +150,27 @@ class SignReadingTests(unittest.TestCase):
world = World(Munch(chunks=chunks, job=job, name='mosfet1',
pos=(0, 64, 0)))
route = [(0, 64, 0), (50, 64, 0), (24, 64, 0)]
astar_calls = []
class FixedPathfinder:
@staticmethod
def astar(_start, _place):
return [(0, 64, 0), (20, 64, 0), (30, 64, 0)]
def astar(start, place):
astar_calls.append((start, place))
return route
with patch('mosfet.world.path.Pathfinder', return_value=FixedPathfinder()):
# The work target is inside, so even a route well outside is okay.
self.assertEqual(world.path_to_place((0, 64, 0), (24, 64, 0)),
route)
# An out-of-bounds destination is rejected before pathfinding.
self.assertIsNone(world.path_to_place((0, 64, 0), (30, 64, 0)))
self.assertEqual(len(astar_calls), 1)
# Support/cache paths do not use work-sign limits.
job.active_machine = cache_machine
self.assertEqual(world.path_to_place(
(0, 64, 0), (30, 64, 0)),
[(0, 64, 0), (20, 64, 0), (30, 64, 0)])
policy = {'position': (0, 64, 0), 'distance': 25, 'shape': 'square'}
self.assertTrue(World._path_allowed_by_sign(
[(30, 64, 0), (27, 64, 0), (24, 64, 0)], policy))
self.assertFalse(World._path_allowed_by_sign(
[(30, 64, 0), (32, 64, 0), (24, 64, 0)], policy))
(0, 64, 0), (30, 64, 0)), route)
six_square = {'position': (-158, 71, -248),
'distance': 6, 'shape': 'square'}