Rational Vacuum Agent PEAS and Pseudo-Code
Rational Vacuum Agent PEAS and Pseudo-Code
Performance Measure
The vacuum agent should clean all dirty locations while minimizing the number of actions taken.
Its performance is also based on energy efficiency, avoiding unnecessary movement, and
returning to the home location (A) after the environment is fully clean. The agent must also
avoid running out of energy and must empty its bag whenever full (capacity 10). These criteria
align with how rational agents maximize expected performance relative to their environment
(Russell & Norvig, 2021).
Environment
The environment is a static, fully observable 4x4 grid with labeled locations from A to P. Each
square may either be dirty or clean. Movement is limited to the four cardinal directions. The
environment contains no dynamic obstacles for this assignment but requires tracking dirt, energy
level, and bag capacity.
Actuators:
The agent has three actuators:
Sensors:
The vacuum agent uses the following sensors:
This PEAS description aligns with the standard agent-design framework discussed in artificial
intelligence literature (Poole & Mackworth, 2017).
def vacuum_agent():
global current_location, energy, bag_capacity
if energy <= 0:
return "FAILED - OUT OF ENERGY"
if environment[current_location] == "Dirty":
suck()
continue
if bag_capacity == MAX_CAPACITY:
go_home()
empty_bag()
next_loc = choose_next_location()
move_to(next_loc)
Action Functions
def suck():
global energy, bag_capacity
if environment[current_location] == "Dirty":
environment[current_location] = "Clean"
bag_capacity += 1
energy -= 1
def move_to(target):
global current_location, energy
# Move one step toward the target location
energy -= 1
current_location = target
Step-Toward Function
def step_toward(target):
(x1, y1) = location_coord[current_location]
(x2, y2) = location_coord[target]
Goal Test
def goal_achieved():
for loc in environment:
if environment[loc] == "Dirty":
return False
return current_location == "A"
Designing this rational vacuum agent helped reinforce how important the PEAS framework is in
guiding the structure of an intelligent system. By clearly defining the performance metrics,
environmental constraints, and required sensors and actuators, it becomes much easier to specify
the agent’s behavior logically and consistently. This mirrors what Russell and Norvig (2021)
emphasize: a rational agent is one that selects actions expected to maximize performance given
its available knowledge.
One key lesson learned from this assignment was the importance of structuring the environment
and agent functions in a modular way. Breaking down the behaviors into sensor checks, action
choices, movement functions, and goal-testing functions helped simplify the complexity of the
system. Another important insight was how constraints—such as limited energy (100 points) and
a finite bag capacity (10 dirt units)—significantly influence the agent’s strategy. These
constraints introduce realism, mirroring how real robotic vacuum systems must regularly
recharge or empty dust bins (Hoy, 2018).
Regarding whether the algorithm can reach the goal with the given 100 energy points, it is likely
to succeed under the static 4×4 grid conditions. The agent performs at most 16 cleaning actions
(if all squares are dirty) and a limited number of directional movements, all costing 1 energy
each. The grid is small enough that even multiple trips back to the home location will not exceed
the energy budget in most cases. However, energy becomes a more serious constraint when the
environment scales up.
If the static location becomes larger—such as an 8×8 or 20×20 grid—several changes are
required. First, the movement algorithm must be updated to include more efficient search and
path-planning methods, such as A* or Dijkstra’s algorithm, to reduce wasted energy traveling
long distances. Second, the agent may need recharge stations, since 100 energy points would not
be sufficient to traverse a large environment, return home, and continue cleaning. Additionally,
bag capacity would need to expand or the agent would need to empty itself more frequently.
In the real world, obstacles such as pets, furniture, humans, or dropped objects introduce
dynamic unpredictability that a static algorithm cannot handle. To manage these complexities,
the agent would need real-time obstacle detection using sensors such as infrared, LiDAR, or
bump sensors (Poole & Mackworth, 2017). It would also require dynamic replanning capabilities
so that if a path becomes blocked, the agent can adapt its route instantly rather than relying solely
on static navigation. Incorporating simultaneous localization and mapping (SLAM) would allow
the robot to maintain a constantly updated map of its environment, which is standard in modern
robotic vacuums.
Overall, this assignment illustrates that designing a rational agent, even in a simplified
environment, involves thoughtful consideration of constraints, environment representation, and
adaptive decision-making. It reinforces the idea that real-world intelligent agents must balance
limited resources, incomplete information, and changing conditions to behave rationally and
effectively.
Hoy, M. B. (2018). Alexa, Siri, Cortana, and more: An introduction to voice assistants. Medical
Reference Services Quarterly, 37(1), 81–88.
Russell, S. J., & Norvig, P. (2021). Artificial intelligence: A modern approach (4th ed.). Pearson.