Agents and Environments.
Understand how AI agents interact with their environments through sensors and actuators. Learn about percepts, percept sequences, agent functions, agent programs, and real-world examples.
Artificial Intelligence is not only about machines learning patterns or solving mathematical problems. It is also about systems that observe their surroundings, make decisions, and take actions to achieve particular goals.
Think about a robot moving through a room. It uses sensors to detect obstacles, processes the information it receives, decides where to move, and uses its motors to perform that movement.
Similarly, a navigation application receives information about a user’s location and road conditions, evaluates possible routes, and recommends a suitable path.
In AI, systems that perceive their surroundings and act upon them are studied through the concepts of agents and environments.
Understanding these concepts is essential because they form the foundation for studying intelligent agents, decision-making, and problem-solving in Artificial Intelligence.
1. What Is an Agent in Artificial Intelligence?
An agent is an entity that perceives its environment through sensors and acts upon that environment through actuators.
In simple words, an agent observes what is happening around it and takes actions based on the information it receives.
An agent can be a physical machine, a software program, or another system capable of interacting with an environment.
Examples include:
- A robot that detects obstacles and moves around them.
- A self-driving car that observes roads and controls its movement.
- A chess-playing program that analyses a board and selects a move.
- A virtual assistant that receives a voice command and responds.
- A software system that monitors network activity and takes appropriate action.
An agent does not necessarily have to be a physical robot. A software program can also be an AI agent if it perceives information and takes actions within its environment.
2. What Is an Environment?
An environment is the external world or situation in which an agent operates.
It provides information to the agent and is affected by the agent’s actions.
For example:
- For a self-driving car, the environment includes roads, traffic, pedestrians, signals, and weather conditions.
- For a chess-playing program, the environment is the chessboard, including the positions of all pieces and the opponent’s moves.
- For a cleaning robot, the environment includes the room, furniture, walls, dirt, and other obstacles.
The environment supplies information that the agent needs to make decisions.
The agent then performs actions that may change the environment.
3. How Do Agents and Environments Interact?
An agent continuously interacts with its environment through two main processes:
- Perception: The agent receives information about its environment.
- Action: The agent performs an action based on the information it has received.
This interaction can be understood through a simple cycle:
Environment → Sensors → Agent → Actuators → Environment
Let’s understand each part.
3.1 Sensors
Sensors are the means through which an agent receives information from its environment.
They help an agent observe what is happening around it.
Examples include:
- Cameras that capture images.
- Microphones that receive sound.
- Temperature sensors that measure heat.
- GPS receivers that provide location information.
- Touch sensors that detect physical contact.
In a software agent, sensors do not have to be physical devices. They may be input mechanisms such as files, databases, user commands, or information received through an API.
3.2 Actuators
Actuators are the means through which an agent performs actions in its environment.
In physical systems, they may include motors, wheels, robotic arms, speakers, or other mechanisms.
Examples include:
- Motors that move a robot.
- Wheels that control a vehicle’s movement.
- Robotic arms that pick up objects.
- Speakers that produce voice responses.
In software systems, actions may include displaying a message, sending an email, updating a database, or calling an external service.
3.3 Percepts
A percept is the information an agent receives from its environment through its sensors at a particular moment.
For example, when a robot detects a wall using its distance sensor, the sensor reading is part of the robot’s percept.
A percept may contain one value or several pieces of information, depending on the system.
3.4 Percept Sequence
A percept sequence is the complete history of percepts that an agent has received up to a particular point in time.
This is important because some decisions depend not only on what is happening now but also on what the agent observed earlier.
For example, a self-driving car may consider its recent observations of a moving vehicle to estimate its direction and speed.
A system that uses only the current percept may behave differently from one that can use information from previous observations.
4. The Agent–Environment Interaction Cycle
Consider a simple cleaning robot.
Its task is to move around a room and clean dirty areas.
The interaction can be described in the following steps:
- The robot receives information about its surroundings through its sensors.
- It identifies whether the current location is clean or dirty.
- It decides whether to clean, move forward, or change direction.
- Its motors and cleaning mechanism perform the selected action.
- The environment changes, and the robot receives new information.
This cycle continues while the robot performs its task.
A simplified representation is:
| Stage | What happens |
|---|---|
| Environment | The room contains dirt and obstacles |
| Sensors | The robot detects dirt and obstacles |
| Agent | The robot processes the information |
| Decision | It selects an appropriate action |
| Actuators | Motors and cleaning mechanisms perform the action |
| New environment state | The room changes after the action |
The important point is that an agent does not simply receive information once and stop. It interacts with its environment repeatedly.
5. The Agent Function
An agent needs a mechanism for deciding which action to perform after receiving information.
In AI, this relationship is described using the agent function.
The agent function maps a percept sequence to an action.
In simple terms, it describes what action an agent should take based on everything it has perceived so far.
Mathematically, it can be represented as:
\[
f: P^* \rightarrow A
\]
Where:
- (f) represents the agent function.
- (P^*) represents all possible percept sequences.
- (A) represents the set of possible actions.
For example, consider a simple cleaning robot:
| Percept | Possible action |
|---|---|
| Current location is dirty | Clean |
| Current location is clean | Move to another location |
| Obstacle detected ahead | Change direction |
These are simplified rules for understanding the relationship between percepts and actions. A real agent may use more complex information and decision-making methods.
6. Agent Program and Agent Architecture
The terms agent program and agent architecture are closely related, but they do not mean the same thing.
Agent Program
An agent program is the software or set of instructions that implements the agent’s decision-making process.
It determines how the agent responds to the information it receives.
For example, a cleaning robot’s program may contain instructions for identifying dirt, avoiding obstacles, and selecting its next movement.
Agent Architecture
Agent architecture refers to the physical or computational platform on which the agent program runs.
It provides the resources needed to receive information and perform actions.
For a physical robot, the architecture may include:
- Sensors.
- Motors and other actuators.
- Processor or control unit.
- Memory.
- Communication hardware.
For a software agent, the architecture may include a computer, operating system, memory, and other software components.
Together, the architecture and agent program form an operating agent.
Agent = Architecture + Agent Program
The architecture provides the platform, while the program determines how the agent behaves.
7. Examples of Agents and Their Environments
Let’s examine a few examples to understand how these concepts apply in different situations.
7.1 Self-Driving Car
A self-driving car is a physical agent that operates in a complex and changing environment.
Environment:
- Roads.
- Other vehicles.
- Pedestrians.
- Traffic signals.
- Road signs.
- Weather conditions.
Sensors:
- Cameras.
- Radar.
- LiDAR.
- GPS.
- Other vehicle sensors.
Actions:
- Steering.
- Accelerating.
- Braking.
- Changing lanes.
- Stopping.
The car continuously observes its surroundings and uses the available information to decide how to move safely.
7.2 Chess-Playing Program
A chess-playing program is a software agent.
Environment:
- Chessboard.
- Pieces.
- Current positions.
- Opponent’s moves.
Inputs:
- Current board position.
- Available legal moves.
- Previous moves, when relevant.
Actions:
- Selecting and making a chess move.
The program analyses the available possibilities and selects a move according to its strategy.
7.3 Virtual Assistant
A virtual assistant is a software agent that interacts with users.
Environment:
- User commands.
- Conversation context.
- Available applications and services.
Inputs:
- Text messages.
- Voice commands.
- Other supported information.
Actions:
- Providing answers.
- Setting reminders.
- Searching for information.
- Performing supported tasks.
Its behaviour depends on the information it receives and the capabilities available to it.
7.4 Cleaning Robot
A cleaning robot operates in a physical environment such as a home or office.
Environment:
- Rooms.
- Furniture.
- Walls.
- Dirt.
- People and pets.
Sensors:
- Cameras.
- Distance sensors.
- Dirt sensors.
- Position sensors.
Actions:
- Moving.
- Turning.
- Cleaning.
- Avoiding obstacles.
It uses sensor information to decide where to move and what action to perform.
8. Why Agents and Environments Matter in AI
The concepts of agents and environments provide a common way to understand many different AI systems.
Whether we are studying a robot, a chess program, or a virtual assistant, we can ask the same basic questions:
- What is the agent?
- What environment does it operate in?
- What information can it perceive?
- What actions can it perform?
- What is it trying to achieve?
These questions help us describe how an AI system works without depending on a particular technology or programming language.
They also prepare us for studying different types of intelligent agents and how they make decisions.
Conclusion
An agent is an entity that perceives its environment through sensors and acts upon it through actuators.
The environment is the external world in which the agent operates. Their interaction forms a continuous cycle of perception and action.
We also learned about percepts, percept sequences, the agent function, agent programs, and agent architecture.
These concepts form the foundation of intelligent agent design. In the next article, we will explore the Types and Structure of Intelligent Agents, including how different agent designs use information to select their actions.
Quick quiz
5 questionsOriginally published at farhanpaal.com — https://farhanpaal.com/articles/agents-and-environments/
Keep a copy
Read offline as a printout or PDF.
farhanpaal.com