Q1. Consider a modified version of the vacuum environment, in which the geography of the
environment—its extent, boundaries, and obstacles—is unknown, as is the initial dirt
configuration. (The agent can go Up and Down as well as Left and Right.)
1. Can a simple reflex agent be perfectly rational for this environment? Explain.
No, a simple reflex agent can’t be rational because:
1) The agent has no memory it can’t remember which squares it has already visited or cleaned,
so it can’t systematically clean the room.
2) A deterministic rule can be stuck in an infinite loop for instance if u hit a will go right and
then forward can make it circle the first few circles forever while the other areas might stay
dirty forever. Obstacles make this easy to trigger.
3) With the layout unknown, no fixed rule table can be correct for all possible environments. A
rule that works in one room will loop in another.
4) Being perfectly rational would require remembering where it has been (an internal
state/model), which a simple reflex agent doesn’t have.
2. Can a simple reflex agent with a randomized agent function outperform a simple reflex agent?
Design such an agent and measure its performance on several environments.
Yes, randomization helps break the infinite loops.
A randomized agent function might be:
• If the current square is dirty → Suck
• Otherwise → move in a random direction (Up/Down/Left/Right)
The agents
Agent A (not random):
• If the square is dirty, suck.
• Otherwise, keep going right. If you hit a wall, go down.
Agent B (random):
• If the square is dirty, suck.
• Otherwise, move in a random direction (up, down, left or right).
Neither agent has memory. Each decides using only what it sees right now.
How to measure it
Make several different rooms (small, medium, large, with different walls and dirt). Put both
agents in the same rooms and give each the same number of steps. Then count how many
dirty squares each one cleaned.
, Room Dirty Squares Agent A (not Agent B (random)
random) cleaned cleaned
5x5 8 1.5 8.0
8x8 15 1.7 13.0
10x10 25 1.8 16.7
Q2. Let us examine the rationality of various vacuum-cleaner agent functions.
1. Show that the simple vacuum-cleaner agent function described in Figure 2.3 is indeed
rational under the assumptions listed on page.
1. Why the simple agent is rational
The simple agent does this: if the square is dirty, suck; if A is clean, go right; if B is clean, go
left.
The assumptions are:
• The agent scores one point for each clean square at each time step (over 1000 steps).
• The world has two squares, A and B. The layout is known, but the dirt and the starting
square are not.
• Clean squares stay clean, and Suck cleans the current square.
• The only actions are Left, Right and Suck, and moving into a wall does nothing.
• The agent correctly sees its location and whether the square is dirty.
Why it’s rational: the agent can’t do better in any starting situation.
• If the current square is dirty, sucking is the only way to gain a point, so Suck is best.
• If both squares are clean, nothing is left to gain. Moving back and forth costs nothing under
this performance measure, so it loses no points.
• If the current square is clean, the other square might be dirty, so moving there is the only
way to find out. Staying put would never discover it.
Describe a rational agent function for the case in which each movement costs one point.
Does the corresponding agent program require internal state?
. If each movement costs one point
The old agent is no longer rational. Moving back and forth forever when everything is clean
now loses a point every step.A rational agent function: if the square is dirty, suck. If the
square is clean and the agent believes the other square is clean, do nothing (NoOp). Only
move if the other square might still be dirty. Once both squares have been cleaned, the agent
must remember that it already cleaned the other square. With no memory, it can only see the
square it’s on, so it can’t tell whether the other square is clean. It would have to keep moving
to check, which costs points, or stop and risk missing dirt. Remembering the status of the
squares it has visited solves this.
Discuss possible agent designs for the cases in which clean squares can become dirty
and the geography of the environment is unknown. Does it make sense for the agent to
learn from its experience in these cases? If so, what should it learn? If not, why not?