Skip to content
Alexandre Mondaini Calvão edited this page Dec 3, 2025 · 2 revisions

Labelle Pathfinding Wiki

Welcome to the Labelle Pathfinding wiki! This library provides a self-contained pathfinding system for Zig game development.

Quick Start

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);
}

Pages

Architecture

┌─────────────────────────────────────────────────────┐
│                 PathfindingEngine                    │
├─────────────────────────────────────────────────────┤
│  Graph Layer                                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────────────┐  │
│  │  Nodes   │  │  Edges   │  │ DirectionalEdges │  │
│  └──────────┘  └──────────┘  └──────────────────┘  │
├─────────────────────────────────────────────────────┤
│  Pathfinding Layer                                   │
│  ┌──────────────────────────────────────────────┐  │
│  │           Floyd-Warshall (all pairs)          │  │
│  └──────────────────────────────────────────────┘  │
├─────────────────────────────────────────────────────┤
│  Entity Layer                                        │
│  ┌──────────┐  ┌──────────┐  ┌──────────────────┐  │
│  │ Positions│  │  Paths   │  │    Movement      │  │
│  └──────────┘  └──────────┘  └──────────────────┘  │
├─────────────────────────────────────────────────────┤
│  Spatial Layer                                       │
│  ┌──────────────────┐  ┌────────────────────────┐  │
│  │ QuadTree (nodes) │  │  QuadTree (entities)   │  │
│  └──────────────────┘  └────────────────────────┘  │
└─────────────────────────────────────────────────────┘

Connection Modes

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

When to Use What

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

Clone this wiki locally