Avoid false path invalidation while airborne

This commit is contained in:
Tanner committed 2026-11-17 22:07:19 +00:00
1 parent 928ce064eb
commit 2ecaa9a30a
3 files changed
+71 -4

No files matched your search

+11 -3
View File
@@ -300,17 +300,25 @@ class Pathfinder(AStar):
return self.check_parkour(start, offset)
return False
def path_prefix_is_valid(self, route, steps=2):
"""Check upcoming route nodes against the current loaded block state."""
previous = None
def path_prefix_is_valid(self, route, steps=2, start=None,
skip_start_edge=False):
"""Check upcoming route nodes without treating midair start as blocked."""
previous = tuple(start) if start is not None else None
first_edge = True
for point in route[:steps]:
node = tuple(point)
if previous is not None and node == previous:
# A* includes its start in the reconstructed route. The bot
# may currently be jumping/falling through that cell.
continue
if not self._can_stand_at(node):
return False, node
if (previous is not None and
not (first_edge and skip_start_edge) and
not self._path_edge_is_valid(previous, node)):
return False, node
previous = node
first_edge = False
return True, None
def neighbors(self, node):