Real-World Applications

Where pathfinding lives in the wild

Every GPS query, every game NPC, every network packet uses these algorithms. The concepts we've explored—BFS, Dijkstra, A*—aren't academic exercises. They're the backbone of systems you use every day.

Let's explore where pathfinding appears in the wild, and how the same fundamental ideas adapt to vastly different domains.

GPS Navigation

When you ask your phone for directions, a sophisticated system springs into action. At its heart? A* or bidirectional Dijkstra, running on a graph where nodes are intersections and edges are road segments.

But there's a catch: road networks are huge. The United States alone has tens of millions of road segments. Running Dijkstra from scratch for every query would be impractical.

Preprocessing for Speed

Modern GPS systems use Contraction Hierarchies, a clever preprocessing technique. The idea: pre-compute shortcuts between important intersections. When you later search for a route, you can skip over less important roads entirely, dramatically reducing the search space.

Think of it like this: if you're driving from New York to Los Angeles, you don't need to consider every residential street in Kansas. The preprocessed data lets the algorithm focus on highways and major routes.

The Graph Structure

A road network forms a weighted graph where:

  • Nodes are intersections or decision points
  • Edges are road segments
  • Weights encode travel time (not just distance—accounting for speed limits, traffic patterns, and road quality)

The heuristic for A* is typically straight-line distance divided by maximum possible speed, ensuring admissibility while providing useful guidance.

Interactive: GPS Route Finding

GPS Navigation

Every GPS query runs a variant of A* on a massive road network. Here, we're finding the best route between California cities, considering real traffic conditions.

San FranciscoSan JoseOaklandSacramentoStocktonFresnoBakersfieldLos AngelesSan DiegoLas VegasRenoModesto
Start
Destination
Heavy traffic
Moderate

Click cities to set start/destination. Toggle traffic to see how congestion affects route planning.

Watch how A* explores cities, guided by both the actual road distances (g-score) and the straight-line estimate to the destination (h-score). In a real GPS system, this search happens across millions of nodes in milliseconds, thanks to preprocessing and sophisticated data structures.

Game AI and NPCs

Games present a different challenge. Characters need to navigate in real-time through complex, often changing environments. The player doesn't want to wait while the goblin figures out how to chase them.

Navigation Meshes

Instead of a dense grid, games often use navigation meshes (navmeshes). The walkable area is divided into convex polygons—typically triangles. Characters pathfind between polygon centroids, then smooth the resulting path.

This approach offers several advantages:

  • Far fewer nodes than a fine grid
  • Naturally handles irregular terrain
  • Easy to update when doors open or obstacles move

Steering Behaviors

A* finds where to go, but not how to get there smoothly. Steering behaviors handle the low-level movement:

  • Seek: Accelerate toward a target point
  • Arrive: Slow down as you approach (no overshooting!)
  • Avoid: Steer around obstacles not captured in the path
  • Separate: Maintain distance from other characters

The combination of high-level pathfinding and low-level steering creates natural-looking movement.

Interactive: Game AI Navigation

Game AI Navigation

Game characters use A* to navigate around obstacles in real-time. Enemies patrol predefined paths while the player's character pathfinds to wherever you click.

👹👹🧙
Click anywhere to navigate
🧙Player
👹Patrol Enemy
Wall
Crate

Click anywhere to send the character navigating. Notice how A* finds a discrete path through the grid, then the character smoothly follows it, avoiding obstacles along the way.

Network Routing

The internet is a graph. Routers are nodes, network links are edges. When you load a webpage, data packets traverse this graph from server to you.

OSPF: Dijkstra at Scale

Open Shortest Path First (OSPF) is one of the most widely used routing protocols. Each router maintains a map of the network topology and runs Dijkstra's algorithm to compute shortest paths to all destinations.

When the network changes—a link goes down, a new router comes online—routers flood updates to their neighbors. The distributed system converges on a consistent view, and paths are recalculated.

Beyond Shortest Path

Real network routing considers more than just distance:

  • Load balancing: Spread traffic across multiple paths
  • Quality of Service: Prioritize certain traffic types
  • Failure tolerance: Maintain backup routes
  • Policy routing: Respect business relationships between networks

The algorithms grow more complex, but the foundation remains: graph search, weighted edges, finding good paths.

Interactive: Network Packet Routing

Network Routing

Internet routers use algorithms like OSPF (based on Dijkstra) to find paths for packets. Click links to simulate failures and watch traffic reroute automatically.

💻User 1💻User 2ARouter ABRouter BCRouter CDRouter DERouter ERCore🖥️Server
💻Client
Router
🖥️Server
Active Link
Failed

Click on network links to toggle failures. Watch how packets automatically find alternate routes to reach the server!

Watch packets flow through the network. Click on links to simulate failures—the routing protocol automatically finds alternate paths, just like the real internet does when cables are cut or routers fail.

Robotics

Robots face unique pathfinding challenges. They have physical size, momentum, and can't turn on a dime. The environment may be partially unknown or changing.

D* and Dynamic Replanning

D* (D-Star) and its variants handle changing environments efficiently. Rather than replanning from scratch when an obstacle appears, D* incrementally updates the existing solution. For a robot exploring unknown territory, this saves enormous computation.

RRT: Random Trees in High Dimensions

A robotic arm has many joints—each joint angle is a dimension in "configuration space." Traditional grid-based pathfinding fails in these high-dimensional spaces.

Rapidly-exploring Random Trees (RRT) take a different approach:

  1. Pick a random point in the space
  2. Extend the nearest existing tree node toward it
  3. Check if the extension is valid (no collisions)
  4. Repeat until the goal is reachable

This random sampling efficiently explores high-dimensional spaces where grid-based methods would be computationally infeasible.

Physical Constraints

Robot pathfinding must also consider:

  • Velocity and acceleration limits
  • Turning radius constraints
  • Stability (for walking robots)
  • Energy consumption

The path isn't just about getting from A to B—it's about doing so in a physically achievable way.

Puzzle Solving

State-space search treats puzzle configurations as nodes in a graph. Each valid move creates an edge to a new configuration. Solving the puzzle means finding a path from start to goal.

The 8-puzzle is a classic example: a 3×3 grid with tiles numbered 1-8 and one empty space. Tiles slide into the empty space. The goal is to arrange them in order.

A* for Puzzles

A* works beautifully here:

  • State: Current tile arrangement
  • Neighbors: States reachable in one move
  • g(n): Number of moves made
  • h(n): Manhattan distance—sum of how far each tile is from its goal position

The Manhattan distance heuristic is admissible (never overestimates) because each tile must move at least that many steps, and tiles can't pass through each other.

Interactive: 8-Puzzle Solver

8-Puzzle Solver

The 8-puzzle is a classic AI problem. A* uses Manhattan distance as the heuristic—the sum of how far each tile is from its goal position.

0:00
0 moves
12345678

Click adjacent tiles to slide them. Green tiles are in the correct position. Use hints or watch the AI solve it optimally!

Shuffle the puzzle and watch A* find the optimal solution. The algorithm explores states guided by the heuristic, efficiently navigating through the millions of possible configurations.

Navigation Meshes in 3D

Let's see how navigation meshes work in a 3D environment. The walkable surface is decomposed into triangles, and pathfinding happens on this simplified representation.

Interactive: 3D Navigation Mesh

3D Navigation Mesh

Games decompose walkable surfaces into convex polygons. Characters pathfind between polygon centers, then follow the smoothed path. Drag to rotate the view!

NavMesh
Start
Goal
Path

The blue triangles form the navigation mesh—the walkable area. Obstacles (gray boxes) carve out holes. The pathfinder searches through connected triangles to find a route from start to goal.

In practice, the path through triangle centers gets smoothed into a natural curve. Characters then follow this smoothed path using steering behaviors.

The Common Thread

Despite the diversity—roads, games, networks, robots, puzzles—the core ideas remain:

1. Represent the problem as a graph

  • Nodes are states or positions
  • Edges connect reachable states
  • Weights encode costs or preferences

2. Search intelligently

  • Use heuristics when available
  • Balance exploration and exploitation
  • Handle changing conditions gracefully

3. Adapt to constraints

  • Scale matters: preprocess large graphs
  • Real-time matters: incrementally update
  • Physics matters: consider feasibility

The algorithms you've learned—BFS, Dijkstra, A*—are tools in a toolkit. Understanding their strengths and assumptions lets you apply them to new domains, or recognize when you need something different.

Key Takeaways

  • GPS systems use A* with preprocessed shortcuts (Contraction Hierarchies) to search massive road networks in milliseconds
  • Game AI combines pathfinding on navigation meshes with steering behaviors for smooth, realistic movement
  • Network routing (OSPF) runs Dijkstra at each router, with distributed updates when topology changes
  • Robotics uses specialized algorithms like D* (for dynamic environments) and RRT (for high-dimensional configuration spaces)
  • Puzzle solving frames puzzles as graph search, with A* guided by problem-specific heuristics like Manhattan distance
  • The same fundamental concepts—graph representation, weighted search, heuristic guidance—appear across all these domains
  • Understanding the basics lets you adapt techniques to new problems you'll encounter