Skip to content

Commit 254ac30

Browse files
committed
Fix missing for-loop increment in C frontier updater
1 parent dd001c8 commit 254ac30

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) since version
99
### Fixed
1010

1111
- Fixed dangling pointer in `Pathfinder.clear` method.
12+
- Fixed hang in `Pathfinder.rebuild_frontier` method.
1213

1314
## [19.4.0] - 2025-08-06
1415

tcod/path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int update_frontier_from_distance_iterator(
454454
int dist = get_array_int(dist_map, dimension, index);
455455
return TCOD_frontier_push(frontier, index, dist, dist);
456456
}
457-
for (int i = 0; i < dist_map->shape[dimension];) {
457+
for (int i = 0; i < dist_map->shape[dimension]; ++i) {
458458
index[dimension] = i;
459459
int err = update_frontier_from_distance_iterator(frontier, dist_map, dimension + 1, index);
460460
if (err) { return err; }

tcod/path.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,20 @@ def rebuild_frontier(self) -> None:
12461246
After you are finished editing :any:`distance` you must call this
12471247
function before calling :any:`resolve` or any function which calls
12481248
:any:`resolve` implicitly such as :any:`path_from` or :any:`path_to`.
1249+
1250+
Example::
1251+
1252+
>>> import tcod.path
1253+
>>> graph = tcod.path.SimpleGraph(
1254+
... cost=np.ones((5, 5), np.int8), cardinal=2, diagonal=3,
1255+
... )
1256+
>>> pf = tcod.path.Pathfinder(graph)
1257+
>>> pf.distance[:, 0] = 0 # Set roots along entire left edge
1258+
>>> pf.rebuild_frontier()
1259+
>>> pf.path_to((0, 2)).tolist() # Finds best path from [:, 0]
1260+
[[0, 0], [0, 1], [0, 2]]
1261+
>>> pf.path_to((4, 2)).tolist()
1262+
[[4, 0], [4, 1], [4, 2]]
12491263
"""
12501264
lib.TCOD_frontier_clear(self._frontier_p)
12511265
self._update_heuristic(None)

0 commit comments

Comments
 (0)