2.1 Agents and Environments
An agent maps percept histories to actions. The task environment can be described by PEAS: performance measure, environment, actuators, and sensors.
Artificial Intelligence · Chapter 2
An agent perceives through sensors and acts through actuators. Its behavior is judged by how well it achieves a performance measure in its environment.
An agent maps percept histories to actions. The task environment can be described by PEAS: performance measure, environment, actuators, and sensors.
A rational agent selects the action expected to maximize performance, given its percepts, prior knowledge, available actions, and computational limits. Rationality is not omniscience.
Tasks vary by observability, determinism, episodic or sequential structure, dynamics, discreteness, and whether one or many agents participate. These properties shape suitable designs.
An agent program runs on an architecture. Simple reflex, model-based, goal-based, and utility-based designs represent progressively richer ways to select actions; learning improves behavior from experience.
Percept: the current sensor reading. Agent function: maps percept histories to actions. PEAS: performance measure, environment, actuators, sensors—the task specification. A reflex policy uses a condition-action rule; a model-based agent additionally tracks relevant state.
In this two-room world, the trace is A dirty → Suck; A clean, B dirty → Move to B; B dirty → Suck; both clean → NoOp. The demo’s environment exposes both dirt flags, so it can stop once both rooms are clean; a partially observable version would need to remember which rooms it has checked.
Interactive lab
A reflex agent senses its current square and dirt status. Step through its policy: clean if dirty; otherwise move toward the other square, unless both are known clean.
Percept: A is dirty
Action: —
Ready. The agent starts in A.
This fully observable toy world uses dirt sensors and a location sensor; it has no hidden rooms or stochastic outcomes.
if dirty(here): Suck; else if other is dirty: Move; else: NoOp. Inputs are current location L and the two-room dirt vector D. Each button press checks the current room and at most one other room: O(1) policy time. The fixed two-room world stores two dirt flags and a location, O(1) state; if generalized to N rooms as a dirt array, world-state storage is O(N). From the default state it reaches NoOp in four presses. Rendering N rooms separately costs O(N) time per update and O(N) UI elements. The constant-time policy assumes dirt status for the other room is available to the agent.