Intro

Abstract

This project implements an incremental variant of A* search, one of the most widely used pathfinding algorithms in games. By distributing the computation accross multiple frames, the algorithm avoids blocking the main game loop and helps maintain a stable frame rate. Another modification of A* allows it to return partial solutions when the goal cannot be found.

flowchart TD
    Start([Start: FindPathIncremental])
    Expand[Expand up to max nodes]
    Goal{Goal found?}
    Complete[Complete<br/>Path ready]
    Frontier{Frontier empty?}
    Partial[Partial<br/>Closest node returned]
    InProgress[InProgress<br/>More nodes can be expanded]

    Start --> Expand --> Goal
    Goal -- Yes --> Complete
    Goal -- No --> Frontier
    Frontier -- Yes --> Partial
    Frontier -- No --> InProgress

  • Each call to FindPathIncremental() processes a limited number of nodes (maxNumNodesToExplore) rather than the entire graph.
  • The current state of the search is indicated by the enum PathSearchResultType
    • InProgress
    • Partial
    • Complete

Finding the closest node to the goal

  • To find the closest node to the goal:
    • In the SearchNodeRecords of closedNodes, use the metadata to estimate the cost to the goal node
    • If nodes are tied, use the one with smallest CostSoFar
    • For null heuristic/Dijkstra’s, since h(n) = 0, compute the euclidean distance manually

A-star Implementation

  • Increment FindPathIncremental(), which calculates an incremental update of A* and may be called several times before the goal is found (if possible)

Incremental graph search (DFS/BFS)

  • A sample incremental search program, BasicPathSearchImpl.cs, can be used as a guide
    • It does NOT use heuristics (so it’s not A*). It’s basically a priority-queue–based BFS/DFS hybrid that runs in chunks

Priority Queue

  • The SimplePriorityQueue<int, float> simulates queue and stack behavior
    • BFS: Elements added with increasing priority
    • DFS: Elements added with negative increasing priority

Millington Pseudocode

Unit Tests

SubmissionNavMesh Generation