This is the vacuum cleaner example of the book "Artificial intelligence: A Modern Approach" (4th edition).

enter image description here

Consider the simple vacuum-cleaner agent that cleans a square if it is dirty and moves to the other square if not; this is the agent function tabulated as follows.

Percept sequence                      Action
[A,Clean]                             Right
[A,Dirty]                             Suck
[B,Clean]                             Left
[B,Dirty]                             Suck
[A,Clean], [A,Clean]                  Right
[A,Clean], [A,Dirty]                  Suck
.                                      .
.                                      .
[A,Clean], [A,Clean], [A,Clean]       Right
[A,Clean], [A,Clean], [A,Dirty]       Suck
.                                      .    

The characteristics of environment and performance function are as follow:

  • The performance measure awards one point for each clean square at each time step, over a "lifetime" of 1000 time steps.

  • The "geography" of the environment is known a priori (the above figure) but the dirt distribution and the initial location of the agent are not. Clean squares stay clean and sucking cleans the current square. The Right and Left actions move the agent one square except when this would take the agent outside the environment, in which case the agent remains where it is.

  • The only available actions are Right, Left, and Suck.

  • The agent correctly perceives its location and whether that location contains dirt.

In the book, it is stated that under these circumstances the agent is indeed rational. But I do not understand such percept sequence that consists of multiple [A, clean] percepts, e.g. {[A, clean], [A, clean]}. In my opinion, after first [A, clean], the agent must be gone to the right square; So, the sequence {[A, clean], [A, clean]} will never be perceived.

In other words, the second perception of [A, clean] is the consequence of acting left or suck action after perceiving the first [A, clean]. Therefore, we can conclude the agent is not rational.

Please, help me to understand it.


2 Answers 2


You are correct that the robot should never perceive two [A, Clean] events in a row, as it should have moved when perceiving the first one.

However, this only applies to a perfect agent, which always successfully executes all its actions. What if the dog walks past and blocks the exit to room B? Then the Right action fails, and the agent is still in A. But now, it might only listen to [B, ?] events, because obviously it must now be in room B, since it executed a Right command.

Having a simple tabulated agent function like this is clearly not adequate for real world problems, as where do you stop? How many [A, Clean] events do you want to list? And, if you start again, why do you have lists of perceptions in the first place? The initial [A, Clean] in the list should suffice, as it would still attempt to move right if it processes perceptions with no internal state/memory.

But bearing in mind that physical actions can fail in the real world, the agent is still rational, it's just overly cautious: it doesn't try to suck when the location is clean, or move away when it's dirty. It just wants to make sure it's really clean before moving away.

  • $\begingroup$ Thank you for the answer. But in the assumptions we have: "The Right and Left actions move the agent one square except when this would take the agent outside the environment, in which case the agent remains where it is." So it seems that the closure can not occur. What is your opinion? $\endgroup$
    – user153245
    Oct 24, 2021 at 4:04

The table represents the agent function which takes as input the perception sequence

In the Vacuum example the rational decision does not depend on the perception sequence, or rather only on the last entry of the perception sequence.

Think of a more complex game where the optimal decision changes after you have perceived something in the past. An example could be you are standing in front of a door and need a key.

* [A:door] -> Walk right
* ...
* [A:door] ... [found key] ... [A:door] -> Open door

Such a table is intended to be used as a look-up table for the optimal decision for every situation including the past.
Depending on the setting in could make sense to limit the table to a maximum length of a perception sequence; for the vacuum world to length one.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .