Intelligent Agents
An agent perceives an environment through sensors and acts on it through actuators; its behavior is an agent function mapping percept sequences to actions. A rational agent chooses, for each percept sequence, the action that maximizes its expected performance measure given its knowledge.
╌╌╌╌
An agent is anything that perceives its environment through sensors
and acts on that environment through actuators. A human agent has eyes and
ears for sensors, hands and legs for actuators; a robot has cameras and range
finders for sensors and motors for actuators; a software agent receives
keystrokes and network packets and acts by writing files and sending packets.
The definition is deliberately thin, because it is meant to be a lens for
analyzing systems, not a line that divides the world into agents and non-agents.
A pocket calculator, viewed this way, is an agent that outputs 4 on the percept
2 + 2 = — an unhelpful reading, but not a wrong one. AI reserves its attention
for the interesting end of that spectrum: agents with real computational
resources whose task environment demands nontrivial decisions.1
This lesson works through three ideas in order. What an agent is (the percept-to-action loop). What it means for an agent to be good (rationality). And how to specify the problem an agent faces (PEAS and the properties of task environments). The companion lesson, agent architectures, then shows how to build one. Every later chapter — search, logic, probability, learning — is a way of computing the action a rational agent should take in some class of environment.
Agents and the agent function
At any instant an agent has a percept: whatever its sensors report. Its percept sequence is the complete history of everything it has perceived. The central premise: an agent's action at any instant can depend on the entire percept sequence to date, but on nothing it has not perceived. So an agent's behavior is captured in full by an agent function mapping every percept sequence to an action.2
Equivalently: given the full sensing history, the next action is determined. This map is the agent function
where is the set of percepts, the set of finite percept sequences, and the set of actions. A percept sequence is , and the action at step is . The function is an external, mathematical description — a (usually infinite) table pairing each percept history with a response. Internally, is realized by an agent program running on a physical device. Keep the two distinct: is the abstract specification, the program is the concrete implementation. The distinction returns when we ask how much memory a program needs to reproduce a given .
Take the vacuum-cleaner world. Two squares and , each either clean or dirty; the agent perceives its square and whether it is dirty, and acts in . A simple agent function is: if the current square is dirty, suck; otherwise move to the other square. The design question of the whole field, in miniature, is: what is the right way to fill out that table? That is what rationality answers.
Writing out the tabulation shows is a finite object here even though it is infinite in general. Because this function depends only on the current percept, , so only the four one-step percepts matter and is four rows.
| Percept sequence (last percept) | Action |
|---|---|
Right | |
Suck | |
Left | |
Suck |
Rationality
A rational agent does the right thing — it fills out every entry of the agent
function correctly. But right
cannot mean whatever the agent believes is right,
or an agent could be rational by simply deluding itself. Rightness is
judged from outside, by a performance measure that scores sequences of
environment states (not agent states). For the vacuum agent, a good measure
might award one point per clean square at each time step over a lifetime of 1000
steps, perhaps with a penalty for wasted motion. As a design rule, it is better
to specify performance in terms of what one actually wants in the environment than
in terms of how one imagines the agent should behave — otherwise the agent will
game the letter of the measure. (Reward amount of dirt cleaned,
and a rational
agent will dump dirt back on the floor so it can clean it again.)3
What is rational at a given moment depends on four things: the performance measure, the agent's prior knowledge of the environment, the actions available to it, and its percept sequence to date. Assembling them gives the definition the rest of the course rests on.
Written as a choice rule: with performance measure over environment-state sequences, prior knowledge , and percepts , the rational action is
the action whose expected performance is greatest given everything known so far.
Two words in that definition do heavy lifting. Expected: rationality maximizes expected performance , not actual performance . This is the difference between rationality and omniscience. An omniscient agent knows the actual outcome of its actions; no real agent does. Crossing an empty street is rational even if, freakishly, a cargo door falls from a passing airliner and flattens you — the percept sequence gave no reason to expect it, so the choice was correct even though the outcome was catastrophic. Rationality is about making the best decision given what you could know, not about being right after the fact.
To see what maximize the performance measure
means, score the simple vacuum agent
above. Fix with , the
geography and initial dirt known, the start square random. Trace the worst start
( dirty, dirty, agent in ): suck ( clean), move right,
suck ( clean), both clean thereafter. Score: at , at ,
for each remaining step — of a possible .
Against this measure, in this fully observable environment, the agent is
rational: no does better, since two squares cannot both be clean before the
agent has visited each, so the two lost points are unavoidable. Change the measure
— penalize each move by one point to model energy — and the same agent is no longer
rational; the rational agent now halts once both squares are clean rather than
oscillate. Rationality is relative to the four inputs; changing any one can change
which is rational.
Given the percept sequence: rationality is relative to the information available. If an agent does not look before crossing a busy road, its percept sequence will not warn it of the approaching truck — but that does not license the crossing. A rational agent should first take the looking action, because looking maximizes expected performance. Acting to improve future percepts is called information gathering, and it is a genuine part of rational behavior. A rational agent should also learn: use its percepts to correct and extend whatever prior knowledge it started with. An agent that relies wholly on its designer's prior knowledge, rather than its own percepts, lacks autonomy; a truly rational agent is autonomous, learning enough to compensate for partial or incorrect priors.4
Specifying the task: PEAS
Before designing an agent, specify the problem it must solve. Rationality is defined relative to a performance measure, an environment, and the agent's sensors and actuators — group these four under the heading task environment, and remember them by the acronym PEAS: Performance, Environment, Actuators, Sensors. The first step in building any agent is to specify the PEAS as fully as possible.5
Take an automated taxi driver — a task still somewhat beyond current technology, and open-ended enough to exercise every part of the framework.
| PEAS | Automated taxi |
|---|---|
| Performance | safe, fast, legal, comfortable trip; maximize profits |
| Environment | roads, other traffic, pedestrians, customers, weather |
| Actuators | steering, accelerator, brake, signal, horn, display |
| Sensors | cameras, sonar, speedometer, GPS, odometer, accelerometer, engine sensors, keyboard |
The performance measure already exposes real design tension: safety, speed, and
profit conflict, so the agent needs a way to trade them off — a hint that goals
alone will not be enough. The same template describes agents in purely software
environments, where sensors
are keyboard input and actuators
are screen
output; what matters is not whether the environment is physical but how complex
the coupling between behavior, percepts, and performance is.
| Agent | Performance | Environment | Actuators | Sensors |
|---|---|---|---|---|
| Medical diagnosis | healthy patient, reduced costs | patient, hospital, staff | display of questions, tests, diagnoses | keyboard entry of symptoms, findings |
| Part-picking robot | fraction of parts in correct bins | conveyor belt with parts | jointed arm and hand | camera, joint-angle sensors |
| Refinery controller | purity, yield, safety | refinery, operators | valves, pumps, heaters, displays | temperature, pressure, chemical sensors |
| Interactive English tutor | student's score on a test | set of students, testing agency | display of exercises, corrections | keyboard entry |
Work one all the way through to see how the PEAS specification drives the design. Take a spam filter, an agent almost everyone runs. Its PEAS is compact but every entry carries a design consequence.
| PEAS | Spam filter |
|---|---|
| Performance | fraction correctly classified; heavier penalty for a lost real message than for a spam that slips through |
| Environment | the stream of incoming email, the sender population, the user who marks mistakes |
| Actuators | file to inbox, file to spam, flag as uncertain |
| Sensors | the raw message: headers, body text, links, attachments |
Two design facts fall straight out of the P and the E. The asymmetric penalty in
Performance tells the agent to bias toward the inbox when unsure — a false
spam
is worse than a false inbox
— which is a threshold choice, not a new
mechanism. And the Environment contains an adversary: spammers change their
messages precisely to defeat the filter, so the sender population is non-stationary
and the agent must keep learning. That single observation is why spam filtering is
a machine-learning problem and not a fixed rulebook, and it is visible in the PEAS
before any algorithm is chosen. Specifying PEAS well is most of the analysis.
Properties of task environments
Task environments vary along a handful of dimensions, and those dimensions — more than anything else — determine which agent design and which family of techniques is appropriate. The definitions here are informal; later chapters sharpen each one.6
- Fully vs. partially observable. Write the current percept as and the environment state as . The environment is fully observable if determines the action-relevant part of at each instant; then the agent needs no internal state. It is partially observable if sensors are noisy, inaccurate, or miss part of — a vacuum agent with only a local dirt sensor cannot tell whether the other square is dirty. An environment with no sensors is unobservable.
- Single-agent vs. multi-agent. Solving a crossword is single-agent; chess is two-agent. What makes an entity count as an agent (rather than as stochastic scenery) is whether 's behavior is best described as maximizing a performance measure that depends on agent 's behavior. Chess is competitive (the opponent's gain is your loss); taxi driving is partly cooperative (everyone wants to avoid collisions) and partly competitive (only one car fits the parking space).
- Deterministic vs. stochastic. Deterministic if the next state is a function of the current state and action, ; stochastic if instead governed by a distribution . Taxi driving is stochastic — traffic is never exactly predictable, tires blow out. An environment that is not fully observable or not deterministic is uncertain. Nondeterministic is subtly different: outcomes are listed as possible values with no probabilities attached.
- Episodic vs. sequential. In an episodic environment, experience divides into atomic episodes — one percept, one action — and the next episode does not depend on actions taken in previous ones. An assembly-line defect spotter is episodic. In a sequential environment, a current decision can affect all future ones; chess and taxi driving are sequential, and demand looking ahead.
- Static vs. dynamic. If the environment can change while the agent deliberates, it is dynamic; otherwise static. Taxi driving is dynamic — the world does not wait while the agent decides. Crossword puzzles are static. If the environment itself holds still but the agent's performance score keeps ticking (chess with a clock), the environment is semidynamic.
- Discrete vs. continuous. This applies to the state, to time, and to the agent's percepts and actions. Chess has a finite set of states and a discrete set of moves; taxi driving sweeps continuously through speeds, positions, and steering angles.
A seventh axis, known vs. unknown, refers not to the environment itself but
to the agent's knowledge of its laws of physics
— whether it is given the
outcomes (or outcome probabilities) of its actions. This is not the same as
observability: solitaire is known but partially observable (you know the rules,
but not the face-down cards), while a new video game can be fully observable yet
unknown (the screen shows everything, but you don't yet know what the buttons do).
| Task environment | Observable | Agents | Deterministic | Episodic | Static | Discrete |
|---|---|---|---|---|---|---|
| Crossword puzzle | Fully | Single | Deterministic | Sequential | Static | Discrete |
| Chess with a clock | Fully | Multi | Deterministic | Sequential | Semi | Discrete |
| Poker | Partially | Multi | Stochastic | Sequential | Static | Discrete |
| Backgammon | Fully | Multi | Stochastic | Sequential | Static | Discrete |
| Taxi driving | Partially | Multi | Stochastic | Sequential | Dynamic | Continuous |
| Medical diagnosis | Partially | Single | Stochastic | Sequential | Dynamic | Continuous |
| Image analysis | Fully | Single | Deterministic | Episodic | Semi | Continuous |
| Part-picking robot | Partially | Single | Stochastic | Episodic | Dynamic | Continuous |
| Refinery controller | Partially | Single | Stochastic | Sequential | Dynamic | Continuous |
| Interactive English tutor | Partially | Multi | Stochastic | Sequential | Dynamic | Discrete |
The hardest case is partially observable, multi-agent, stochastic, sequential, dynamic, continuous, and unknown — which is roughly the real world, and roughly what taxi driving is. Almost every technique in the course is a way of coping with one or more of these axes.
Footnotes
- Russell & Norvig, AIMA 3rd ed., §2.1 — Agents and Environments: the sensor/actuator definition of an agent, and the point that
agent
is an analytical stance rather than an absolute category (the hand-held calculator as a degenerate agent). ↩ - Russell & Norvig, AIMA 3rd ed., §2.1 — the percept sequence and the agent function mapping percept sequences to actions, and the distinction between the agent function (external, mathematical) and the agent program (internal, concrete). ↩
- Russell & Norvig, AIMA 3rd ed., §2.2 — Good Behavior: The Concept of Rationality; the performance measure evaluates sequences of environment states, and should be designed around what one wants in the environment rather than how one thinks the agent should behave. ↩
- Russell & Norvig, AIMA 3rd ed., §2.2.2 — Omniscience, Learning, and Autonomy: rationality maximizes expected (not actual) performance, is relative to the percept sequence, and requires information gathering, learning, and autonomy. ↩
- Russell & Norvig, AIMA 3rd ed., §2.3.1 — Specifying the Task Environment: the PEAS description (Performance, Environment, Actuators, Sensors) and the automated-taxi worked example. ↩
- Russell & Norvig, AIMA 3rd ed., §2.3.2 — Properties of Task Environments: fully vs. partially observable, single- vs. multi-agent, deterministic vs. stochastic, episodic vs. sequential, static vs. dynamic, discrete vs. continuous, and known vs. unknown. ↩
╌╌ END ╌╌