Reflex Agent Vacuum Cleaner
Reflex Agent Vacuum Cleaner
• Importance:
Agent Function in Vacuum Cleaner
World
Reflex Agent Code
• class VacuumCleanerAgent:
• def __init__(self):
• self.location = 'A'
• self.environment = {'A': 'Dirty', 'B': 'Dirty'}
• def perceive(self):
• return self.environment[self.location]
• def act(self):
Code Explanation: Part 1
• 1. `class VacuumCleanerAgent:`
• - Defines the agent as a class.
• 2. `def __init__(self):`
• - Initializes the agent's location and
environment.
• 3. `self.location = 'A'`
• - Starts the agent in location 'A'.
Code Explanation: Part 2
• 4. `def perceive(self):`
• - Allows the agent to sense the current state
(clean/dirty) of its location.
• 5. `def act(self):`
• - Implements the agent's action rules:
• a. Clean the location if it's dirty.
• b. Move to the other location if it's clean.