-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Alexandre Mondaini Calvão edited this page Dec 3, 2025
·
2 revisions
Welcome to the Labelle Pathfinding wiki! This library provides a self-contained pathfinding system for Zig game development.
const pathfinding = @import("pathfinding");
const Config = struct {
pub const Entity = u64;
pub const Context = *Game;
};
var engine = try pathfinding.PathfindingEngine(Config).init(allocator);
defer engine.deinit();
// Add waypoints
try engine.addNode(0, 0, 0);
try engine.addNode(1, 100, 0);
try engine.addNode(2, 200, 0);
// Connect and build paths
try engine.connectNodes(.{ .omnidirectional = .{ .max_distance = 150, .max_connections = 4 } });
try engine.rebuildPaths();
// Register entity and move
try engine.registerEntity(player, 0, 0, 100.0);
try engine.requestPath(player, 2);
// Game loop
while (engine.isMoving(player)) {
engine.tick(&game, delta);
}- PathfindingEngine - The main engine (recommended)
- Directional-Connections - Platformer-style orthogonal movement
- Spatial-Queries - Finding entities and nodes by position
- Callbacks - Responding to path events
- Algorithms - Direct usage of Floyd-Warshall and A*
┌─────────────────────────────────────────────────────┐
│ PathfindingEngine │
├─────────────────────────────────────────────────────┤
│ Graph Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │
│ │ Nodes │ │ Edges │ │ DirectionalEdges │ │
│ └──────────┘ └──────────┘ └──────────────────┘ │
├─────────────────────────────────────────────────────┤
│ Pathfinding Layer │
│ ┌──────────────────────────────────────────────┐ │
│ │ Floyd-Warshall (all pairs) │ │
│ └──────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────┤
│ Entity Layer │
│ ┌──────────┐ ┌──────────┐ ┌──────────────────┐ │
│ │ Positions│ │ Paths │ │ Movement │ │
│ └──────────┘ └──────────┘ └──────────────────┘ │
├─────────────────────────────────────────────────────┤
│ Spatial Layer │
│ ┌──────────────────┐ ┌────────────────────────┐ │
│ │ QuadTree (nodes) │ │ QuadTree (entities) │ │
│ └──────────────────┘ └────────────────────────┘ │
└─────────────────────────────────────────────────────┘
| Mode | Use Case | Description |
|---|---|---|
| Omnidirectional | Top-down games, RPGs | Connect to N closest neighbors within distance |
| Directional | Platformers, grid games | Connect only left/right/up/down |
| Scenario | Recommendation |
|---|---|
| New game project | Use PathfindingEngine
|
| Need spatial queries | Use PathfindingEngine
|
| Platformer game | Use PathfindingEngine with directional mode |
| Just need shortest paths | Use FloydWarshall or AStar directly |
| Integrating with existing ECS | Use legacy components or algorithms directly |