3. Knowledge Based Agents
3. Knowledge Based Agents
3. Knowledge Based Agents
KNOWLEDGE-BASED
AGENTS
KNOWLEDGE-BASED AGENTS
• Humans, it seems, know things; and what they know helps them do
things. These are not empty statements.
• The standard names for these operations are TELL and ASK,
respectively.
• In the process of answering this query, extensive reasoning may be done about
the current state of the world, about the outcomes of possible action sequences,
and so on.
• Third, the agent program TELLs the knowledge base which action was
chosen, and the agent executes the action.
THE WUMPUS WORLD
• The wumpus world is a cave consisting of rooms connected by passageways.
• Lurking somewhere in the cave is the terrible wumpus, a beast that eats
anyone who enters its room.
• The wumpus can be shot by an agent, but the agent has only one arrow.
• Some rooms contain bottomless pits that will trap anyone who wanders into
these rooms (except for the wumpus, which is too big to fall in).
• Performance measure:
a) +1000 for climbing out of the cave with the gold
b) –1000 for falling into a pit or being eaten by the wumpus
c) –1 for each action taken
d) –10 for using up the arrow
e) The game ends either when the agent dies or when the agent climbs
out of the cave.
THE WUMPUS WORLD
• Environment:
a) A 4 ×4 grid of rooms.
b) The agent always starts in the square labeled [1,1], facing to the
right.
c) The locations of the gold and the wumpus are chosen randomly,
with a uniform distribution, from the squares other than the start
square.
THE WUMPUS WORLD
• Actuators:
a) The agent can move For ward, Turn Left by 90◦ or Turn Right by 90◦.
b) The agent dies a miserable death if it enters a square containing a pit or a live wumpus.
c) If an agent tries to move forward and bumps into a wall, then the agent does not move.
d) The action Grab can be used to pick up the gold if it is in the same square as the agent.
e) The action Shoot can be used to fire an arrow in a straight line in the direction the
agent is facing.
f) The arrow continues until it either hits (and hence kills) the wumpus or hits a wall.
g) The agent has only one arrow, so only the first Shoot action has any effect.
h) Finally, the action Climb can be used to climb out of the cave, but only from square
[1,1].
THE WUMPUS WORLD
• Sensors:
The agent has five sensors, each of which gives a single bit of information:
a) In the square containing the wumpus and in the directly (not diagonally)
adjacent squares, the agent will perceive a Stench.
b) In the squares directly adjacent to a pit, the agent will perceive a Breeze.
c) In the square where the gold is, the agent will perceive a Glitter.
d) When an agent walks into a wall, it will perceive a Bump.
e) When the wumpus is killed, it emits a woeful Scream that can be
perceived any where in the cave.
THE WUMPUS WORLD
• The percepts will be given to the agent program in the form of a list of
five symbols.
• The agent program will get [Stench, Breeze, None, None, None].
The first step taken by the agent in the wumpus world.
(a) The initial situation, after percept [None, None, None, None, None].
(b) After one move, with percept [None, Breeze, None, None, None].
Two later stages in the progress of the agent.
(a) After the third move, with percept [Stench, None, None, None, None].
(b) After the fifth move, with percept [Stench, Breeze, Glitter, None, None].
THE WUMPUS WORLD
• The agent’s initial knowledge base contains the rules of the
environment, as described previously; in particular, it knows that it is
in [1,1] and that [1,1] is a safe square;
• The first percept is [None, None, None, None, None], from which the
agent can conclude that its neighboring squares, [1,2] and [2,1], are
free of dangers—they are OK.
• A cautious agent will move only into a square that it knows to be OK.
THE WUMPUS WORLD
• Let us suppose the agent decides to move forward to [2,1].
• The agent perceives a breeze (denoted by “B”) in [2,1], so there must
be a pit in a neighboring square.
• The pit cannot be in [1,1], by the rules of the game, so there must be a
pit in [2,2] or [3,1] or both.
• The notation “P?” in Figure indicates a possible pit in those squares.
• At this point, there is only one known square that is OK and that has
not yet been visited.
• So the prudent agent will turn around, go back to [1,1], and then
proceed to [1,2].
THE WUMPUS WORLD
• The agent perceives a stench in [1,2], resulting in the state of knowledge.
• But the wumpus cannot be in [1,1], by the rules of the game, and it
cannot be in [2,2] (or the agent would have detected a stench when it was
in [2,1]).
• Yet the agent has already inferred that there must be a pit in either
[2,2] or [3,1], so this means it must be in [3,1].
• In [2,3], the agent detects a glitter, so it should grab the gold and then return
home.
• Note that in each case for which the agent draws a conclusion from the
available information, that conclusion is guaranteed to be correct if the
available information is correct.