Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion catanatron/catanatron/models/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ def longest_acyclic_path(board: Board, node_set: Set[int], color: Color):
while len(agenda) > 0:
node, path_thus_far = agenda.pop()

# Issue #378: Skip nodes occupied by enemy settlements.
# A settlement interrupts the road (Catan rule). We don't explore
# from a node that has an enemy settlement.
if board.is_enemy_node(node, color):
continue

able_to_navigate = False
for neighbor_node in STATIC_GRAPH.neighbors(node):
edge = tuple(sorted((node, neighbor_node)))
Expand All @@ -377,4 +383,4 @@ def longest_acyclic_path(board: Board, node_set: Set[int], color: Color):

paths.extend(paths_from_this_node)

return max(paths, key=len)
return max(paths, key=len) if paths else []
Loading