Agent and environment
An intelligent agent is a system that receives information about an environment and selects actions within it. Imagine a virtual delivery robot on a tiny map: it sees whether the next tile is clear, chooses to move or stop, and receives a new observation. The agent need not learn or use a language model. The important distinction is between the decision-maker and the world in which its decisions have effects.
Separate state, observation and action
State is the information needed to describe the relevant situation at a particular moment, such as the robot position, wall map and destination. An observation is the information available to the agent, which can be incomplete. An action is a choice such as moving right or stopping. The environment applies its rules to an action and may change state. The next observation comes from that resulting state. Feedback is information about what happened; it can include a success signal or a numerical reward. A goal describes a desired outcome, while a performance measure evaluates how well the overall task was performed.
Specify a task with PEAS
PEAS stands for Performance measure, Environment, Actuators and Sensors. For our virtual robot: performance means reach the destination without crossing walls, preferring fewer moves among successful runs; environment is a two-row, three-column grid; actuators are the simulated move-right and stop operations; sensors report whether the next tile is clear and whether the destination has been reached. Actuators are the mechanisms that carry out choices, not the choices themselves. A stop away from the destination is not success. A reward, such as −1 per move and +10 on reaching the goal, could provide a learning signal; it need not capture every part of the performance measure. This chapter does not train a model.
Make a small observation
The map uses . for a free tile and # for a wall. Coordinates are (x, y), starting at zero in the top-left corner. The first row is entirely clear; the second row has a wall in its middle. The code assumes a nonempty rectangular grid containing only these two symbols, valid free start and goal tiles, and tuple coordinates. It reports two facts rather than exposing the entire map.
def observe(grid, position, goal): x, y = position right_clear = x + 1 < len(grid[y]) and grid[y][x + 1] == "." return {"right_clear": right_clear, "at_goal": position == goal}
grid = ["...", ".#."]print(observe(grid, (0, 0), (2, 0)))print(observe(grid, (0, 1), (2, 0)))The first observation is {"right_clear": True, "at_goal": False} (Python prints single quotes). The second has both values false because a wall is immediately to the right. Two different positions or maps may produce the same observation; the agent cannot infer every hidden wall from it. At the right boundary, right_clear is false. To test partial observability, compare positions (0,0) and (1,0) with a goal at (2,0): the observations match even though the positions differ.
The environment controls transitions
A transition describes how the current state and an action produce the next state. This toy environment leaves the position unchanged when a right move would hit a wall or leave the grid. It does not count attempted collisions as successful moves. The move function is part of the environment, not the policy.
def move_right(grid, position): x, y = position if x + 1 < len(grid[y]) and grid[y][x + 1] == ".": return (x + 1, y) return position
grid = ["...", ".#."]print(move_right(grid, (0, 0)))print(move_right(grid, (0, 1)))print(move_right(grid, (2, 0)))The results are (1, 0), (0, 1), and (2, 0): a successful move, a blocked move and a boundary case. A position does not change just because the agent requests a move.
Classify the task environment
Fully observable means observations provide the relevant current state; partially observable means important information is hidden. Deterministic means the same state and action give the same next state; stochastic means outcomes are modeled with probabilities. Static means the world does not change while the agent decides; dynamic means it can. The grid is partially observable to this sensor, deterministic, static while deciding, discrete, single-agent and sequential because earlier moves affect later choices. Adding a probabilistic slip changes determinism without necessarily changing observability. Adding moving barriers changes the dynamics even if the full map is visible.
Common mistakes and practice
Do not equate observation with state, reward with the full objective, or a requested action with a successful transition. Write a PEAS specification for a fictional library shelf robot. Identify one hidden fact, one allowed action, one measurable success condition and one condition that should stop execution. Then predict observe(grid, (2, 0), (2, 0)): the right tile is not clear and the goal is reached. Next, use observations to select actions in Policies and agent types.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Agent and environment — understanding check
Apply agent and environment concepts to the fictional grid world.
Which part of the lesson grid-world state is not supplied in the two Boolean observation fields?
Which PEAS component describes the mechanism that carries out a move?
What is move_right(grid, (0, 1)) for the lesson map?
If a right move can randomly slip to another free tile, which description must change?
Which performance measure matches the lesson’s PEAS specification?