3 Breadth First Search

function bfs(P = ⟨S, s₀, A, τ, c, G⟩):
    agenda ← newQueue()
    agenda.enQueue(s₀)
    while not agenda.isEmpty():
        s ← agenda.deQueue()          # expand s
        for a ∈ A:
            s' ← τ(s, a)
            if s' ∈ G:                # goal found?
                return "done"
            agenda.enQueue(s')        # goal not found, add s' to queue

Evaluation