9 Greedy Search

function greedy(P = ⟨S, s₀, A, τ, c, G⟩):
    agenda ← {s₀}                     # agenda is a set
    while agenda ≠ ∅:
        C ← arg min_{s ∈ agenda} h(s)
        s' ← any element of C
        for a ∈ A:
            s'' ← τ(s', a)
            if s'' ∈ G:               # goal found?
                return "done"
            agenda ← agenda ∪ {s''}   # goal not found, add s'' to agenda