An agent perceives its environment through sensors and acts on it through actuators. Describing an AI problem starts by pinning down four things — its PEAS — and the properties of its environment, which decide which techniques will work.
Environment → Sensors → percept → Agent program → Actuators → action → Environment
The vacuum world
The textbook toy: two squares, A and B, each clean or dirty. The agent perceives (location, status) and can Suck, move Left or Right. The performance measure awards one point per clean square per time step:
def reflex_vacuum_agent(percept):
location, status = percept
if status == "Dirty":
return "Suck"
return "Right" if location == "A" else "Left"
def run(agent, world, location="A", steps=6):
score, actions = 0, []
for _ in range(steps):
action = agent((location, world[location]))
actions.append(action)
if action == "Suck":
world[location] = "Clean"
elif action in ("Left", "Right"):
location = "B" if action == "Right" else "A"
score += sum(s == "Clean" for s in world.values()) # performance measure
return actions, score
actions, score = run(reflex_vacuum_agent, {"A": "Dirty", "B": "Dirty"})
print(actions) # ['Suck', 'Right', 'Suck', 'Left', 'Right', 'Left']
print(score) # 10 ← 1 + 1 + 2 + 2 + 2 + 2PEAS — specifying the task
| Agent | Performance measure | Environment | Actuators | Sensors |
|---|---|---|---|---|
| Self-driving taxi | Safe, fast, legal, comfortable trip; profit | Roads, traffic, pedestrians, weather, passengers | Steering, accelerator, brake, signals, display | Cameras, LiDAR, radar, GPS, speedometer, odometer |
| Medical diagnosis system | Healthy patient, low cost, few tests | Patient, hospital, staff | Display questions, tests, diagnoses, treatments | Keyboard entry of symptoms, test results |
| Chess program | Win / draw / loss | Board, opponent, clock | Moves on the board | Board state |
| Spam filter | Spam caught, legitimate mail kept | Mail stream, users | Mark as spam / deliver | Message text, headers, sender reputation |
Properties of task environments
| Dimension | Easy end | Hard end | What it changes |
|---|---|---|---|
| Observability | Fully observable — sensors show the whole relevant state | Partially observable — noisy sensors, hidden state | Hidden state → agent must keep internal state / beliefs |
| Agents | Single-agent | Multi-agent — competitive or cooperative | Opponents → game theory, adversarial search |
| Determinism | Deterministic — next state fixed by state + action | Stochastic (nondeterministic) — outcomes uncertain | Uncertainty → probabilities, expected utility |
| Episodes | Episodic — each decision independent (classify one image) | Sequential — actions affect the future (chess) | Sequential → planning ahead |
| Change | Static — world waits while agent thinks | Dynamic — world changes meanwhile | Dynamic → time pressure, anytime algorithms |
| State/time | Discrete — finite states and actions | Continuous — positions, speeds | Continuous → optimisation, control theory |
| Knowledge | Known — rules/physics given | Unknown — must learn how the world works | Unknown → exploration, learning |
| Task | Observable | Agents | Deterministic | Episodic | Static | Discrete |
|---|---|---|---|---|---|---|
| Crossword puzzle | Fully | Single | Yes | Sequential | Static | Discrete |
| Chess with a clock | Fully | Multi | Yes | Sequential | Semi | Discrete |
| Poker | Partially | Multi | Stochastic | Sequential | Static | Discrete |
| Taxi driving | Partially | Multi | Stochastic | Sequential | Dynamic | Continuous |
| Image classification | Fully | Single | Yes | Episodic | Static | Continuous |
What does PEAS stand for?
Is a rational agent always successful?
What's the difference between the agent function and the agent program?