Interactive laboratory · Artificial Intelligence

How does a goal-based agent work?

Explore a vacuum-cleaner agent that observes a room, maintains an internal model, predicts the consequences of actions and chooses actions that move it towards its goal.

1. The environment: a room

AgentDirtyObstacleClean

The agent can move north, south, east or west, and can clean the cell it occupies. Grey cells are obstacles.

Agent's current internal stateStep 0
The agent has not observed the room yet.

2. Inside the goal-based agent

AGENT
Sensors
Perceive current location and dirt in the current cell
↓ percept
What the world is like now
Update the internal map using the latest percept
How the world evolves
Movement and cleaning rules
What my actions do
Predict the result of each action
↓ simulate candidate actions
What the world will be like if I do action A
Predict next position and remaining dirt
↓ compare with goal
Goals
All reachable dirty cells are clean
What action I should do now
Choose an action that makes progress
↓ action
Actuators
Move or vacuum
The agent repeats this cycle after every action.
ENVIRONMENT
Ready to begin

Press “Next agent step” to follow one complete decision cycle. The highlighted boxes show which parts of the architecture are active.

Decision trace

  • The agent is waiting for its first percept.
Perception

Sensors provide a percept: the agent's current location and whether the current cell is dirty.

Internal state

The agent records its latest percepts in an internal state. In this simplified demonstration, the planner also has access to the known room map.

Prediction and goals

The agent uses its action model to predict outcomes and checks whether an action helps achieve the goal.

Action and feedback

The actuators move or clean. The room changes, and the agent receives a new percept.

Teaching note: This is a deliberately simplified, deterministic goal-based agent. It uses a known map and breadth-first search to find a route to the nearest dirty cell. It cleans when standing on dirt. The goal is reached when every non-obstacle cell is clean.