public abstract class KBAgent extends AbstractAgent
function KB-AGENT(percept) returns an action
persistent: KB, a knowledge base
t, a counter, initially 0, indicating time
TELL(KB, MAKE-PERCEPT-SENTENCE(percept, t))
action <- ASK(KB, MAKE-ACTION-QUERY(t))
TELL(KB, MAKE-ACTION-SENTENCE(action, t))
t <- t + 1
return action
Figure 7.1 A generic knowledge-based agent. Given a percept, the agent adds
the percept to its knowledge base, asks the knowledge base for the best
action, and tells the knowledge base that it has in fact taken that action.| Modifier and Type | Field and Description |
|---|---|
protected KnowledgeBase |
KB |
program| Constructor and Description |
|---|
KBAgent(KnowledgeBase KB) |
| Modifier and Type | Method and Description |
|---|---|
abstract Action |
ask(KnowledgeBase KB,
Sentence actionQuery)
A wrapper around the KB's ask() method which translates the action (in the form of
a sentence) determined by the KB into an allowed 'Action' object from the current
environment in which the KB-AGENT resides.
|
Action |
execute(Percept percept)
Call the Agent's program, which maps any given percept sequences to an
action.
|
abstract Sentence |
makeActionQuery(int t)
MAKE-ACTION-QUERY constructs a sentence that asks what action should be
done at the current time.
|
abstract Sentence |
makeActionSentence(Action action,
int t)
MAKE-ACTION-SENTENCE constructs a sentence asserting that the chosen action was executed.
|
abstract Sentence |
makePerceptSentence(Percept percept,
int t)
MAKE-PERCEPT-SENTENCE constructs a sentence asserting that the agent
perceived the given percent at the given time.
|
isAlive, setAliveprotected KnowledgeBase KB
public KBAgent(KnowledgeBase KB)
public Action execute(Percept percept)
Agentexecute in interface Agentexecute in class AbstractAgentpercept - The current percept of a sequence perceived by the Agent.public abstract Sentence makePerceptSentence(Percept percept, int t)
percept - the given perceptt - the given timepublic abstract Sentence makeActionQuery(int t)
t - the current time.public abstract Sentence makeActionSentence(Action action, int t)
action - the chose action.t - the time at which the action was executed.public abstract Action ask(KnowledgeBase KB, Sentence actionQuery)
KB - the KB to ask.actionQuery - an action query.