AdvancedAbout 30 min

    A* Search

    Read the full article on Substack

    7 min read.

    An informed search algorithm that uses heuristics to guide the search. It guarantees the shortest path (if heuristic is admissible) and is usually much faster than Dijkstra.

    Think of it this way: Think of driving with a GPS. It doesn't just look at road distance; it also estimates the remaining time to the destination (Heuristic) to guide you, avoiding paths that clearly lead away from the goal.

    SG

    Start at (4,1), goal (4,11).

    1/153

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    g, h, or f?

    Sort

    Sort each description into the part of f(n) = g(n) + h(n) it describes.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    g(n) — cost so far

    Drop items here

    h(n) — heuristic

    Drop items here

    f(n) — priority

    Drop items here
    6 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    What is the role of the Heuristic (h) in A*?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going