Simple Planning Agent

// global variables
kb // knowledge base
p  // initial plan
t  // a counter initially 0

// returns an action
function simple-planning-agent(percept)
    g // a goal
    current // a current state description

    tell(kb, make-percept-sentence(percept, t))
    current = state-description(kb, t)
    if (p == no-plan)
        g = ask(kb, make-goal-query(t))
        p = ideal-planner(current, g, kb)
    if (p == no-plan) or (p == empty)
        action = no-op
    else
        action = first(p)
        p = rest(p)
    tell(kb, make-action-sentence(action,t))
    t++

    return action
  • ideal-planner - a planning algorithm (can be any of the planners described in this chapter or chapter 12)
  • state-description - takes percept as input and returns state description that is required by planner
  • make-goal-query - used to ask the knowledge base what the next goal should be

Planning in Situational Calculus