Pathfinding with entity collision labels #302
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
john/McRogueFace#302
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Extend A* and Dijkstra pathfinding to optionally treat entities with a specific label as impassable obstacles. This enables collision-aware pathfinding without modifying the grid's walkability layer.
Proposed API
Entity-level (uses entity defaults from #252)
Grid-level (explicit parameters)
Implementation
Before computing A*/Dijkstra, build a transient walkability map:
collidelabel via spatial hashcell_poscells (including multi-tile #236) as unwalkableTransient map approach
Option A: Copy TCOD map — create a temporary copy, modify it, compute, discard. Simple but allocates.
Option B: Mark-and-restore — record which cells were changed, modify in place, compute, restore. No allocation but must be careful about concurrent access.
Option A is safer and clearer. For 8192×8192 grids (#252 target), the TCOD map copy is ~67MB. Consider a sparse approach: only copy the cells that need modification (the occupied cells), using TCOD's per-cell setters.
Optimal approach for large grids
TCOD_map_set_properties()This modifies only O(entities) cells rather than copying the entire map.
Cache invalidation
Dijkstra maps with collision labels must be invalidated when:
cell_pos)grid.step()handles this automatically after processing all turns.Dependencies
cell_posfor accurate cell occupancy)Files likely affected
src/UIGridPathfinding.h/cpp— addcollideparameter tofind_path()andget_dijkstra_map()src/UIGrid.h/cpp— Python method bindingssrc/UIEntity.h/cpp—entity.find_path()methodcell_pos— integer logical position decoupled from render positiongrid.step()— turn manager for entity behaviors #301Roadmap context
Part of the Grid & Entity Overhaul Roadmap (
docs/GRID_ENTITY_OVERHAUL_ROADMAP.md), Phase 3b (parallel track alongside behavior struct #300).For large grids (targeting 8192x8192): do NOT copy the TCOD map. Instead, mark-and-restore O(entities) cells. See roadmap for implementation details.
Designed with #252 (Grid/GridView) API in mind —
entity.find_path()will use entity's default walkability layer once #252 lands.