Skip to content

Commit f125528

Browse files
committed
Explain weighted root preference and ignored additions
1 parent 12910cf commit f125528

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎tcod/path.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,14 +1205,15 @@ def clear(self) -> None:
12051205
lib.TCOD_frontier_clear(self._frontier_p)
12061206

12071207
def add_root(self, index: tuple[int, ...], value: int = 0) -> None:
1208-
"""Add a root node and insert it into the pathfinder frontier.
1208+
"""Add a root node for subsequent pathfinding.
12091209
12101210
`index` is the root point to insert. The length of `index` must match
12111211
the dimensions of the graph.
12121212
12131213
`value` is the distance to use for this root. Zero is typical, but
12141214
if multiple roots are added they can be given different weights.
1215-
The root is ignored if `value` is not less than its current distance.
1215+
Roots with lower `value` have higher priority and can suppress nearby
1216+
roots with higher values.
12161217
"""
12171218
index = tuple(index) # Check for bad input.
12181219
if self._order == "F": # Convert to ij indexing order.
@@ -1221,7 +1222,7 @@ def add_root(self, index: tuple[int, ...], value: int = 0) -> None:
12211222
msg = f"Index must be {self._distance.ndim} items, got {index!r}"
12221223
raise TypeError(msg)
12231224
if value >= self._distance[index]:
1224-
return
1225+
return # Keep existing routes when they are at least as cheap.
12251226
self._distance[index] = value
12261227
self._travel[index] = index
12271228
self._update_heuristic(None)

0 commit comments

Comments
 (0)