The agent program must map percepts to actions. Five basic designs, of increasing generality, are used.
Agent Architecture
An agent is architecture + program. The architecture is the computing device with sensors and actuators; the program is what we design. The simplest program, a table-driven agent, looks up the entire percept sequence in a table of actions. It is hopeless in practice: for a chess-like world the table would have more entries than atoms in the universe. We therefore need compact programs.
Simple Reflex Agents
A simple reflex agent chooses an action using only the current percept, through condition–action rules ("if car in front is braking then initiate braking"). The vacuum agent above is of this type. It is simple and fast, but works correctly only if the right decision can be made from the current percept alone, that is, the environment is fully observable. In partially observable settings it can loop forever.
Model-Based Reflex Agents
A model-based reflex agent keeps an internal state that summarises the percept history and holds a model of how the world works: how the world evolves independently of the agent, and how its own actions affect the world. It uses the model to update its picture of the current state before applying rules, so it can handle partial observability, for example remembering the cars behind it when changing lanes.
Goal-Based Agents
Knowing the current state is not enough if there are several things to do; the agent needs a goal describing a desirable situation, such as the passenger's destination. A goal-based agent uses search and planning to find action sequences that achieve the goal, considering "what will happen if I do this?". It is more flexible: to change the destination only the goal is changed, not the rules.
Utility-Based Agents
Goals give only a yes/no distinction between happy and unhappy states. A utility-based agent uses a utility function, a measure of how desirable a state is, so it can compare routes that are safer, faster or cheaper and handle conflicting goals and uncertainty by maximising expected utility.
Learning Agents
A learning agent improves with experience. It has four components: a performance element (selects actions, as in the agents above), a critic (judges how well the agent is doing against a fixed performance standard), a learning element (makes improvements) and a problem generator (suggests exploratory actions that lead to new experiences). Learning allows operation in unknown environments.
Definition: Reflex agent. An agent that selects actions on the basis of condition–action rules applied to the current percept (simple reflex) or to a model-based estimate of the current state (model-based).
Table 1.4: Five agent types
| Agent | Decides using | Handles |
|---|---|---|
| Simple reflex | Current percept and rules | Fully observable tasks |
| Model-based reflex | Internal state and world model | Partial observability |
| Goal-based | Goals, search, planning | Many possible action sequences |
| Utility-based | Utility function | Trade-offs and uncertainty |
| Learning | Experience and feedback | Unknown environments |
Example 1.4: Choosing an agent type
Problem: Which agent type fits: (a) a thermostat; (b) a self-driving car changing lanes; (c) a route planner choosing the best of several routes; (d) a spam filter that improves over time?
Solution:
- (a) Thermostat: if temperature < set point, heat on: simple reflex.
- (b) Lane change: must remember cars it cannot currently see: model-based reflex.
- (c) Route choice by time, cost and safety: utility-based (goal-based if only reaching the destination matters).
- (d) Improves from user feedback: learning agent.
Result: (a) simple reflex, (b) model-based, (c) utility-based, (d) learning.
def thermostat(temp, target=22):
return "heat on" if temp < target else "heat off"
class ModelBased:
def __init__(self):
self.last_dirty = None
def act(self, loc, status):
self.last_dirty = (loc, status == "Dirty")
return "Suck" if status == "Dirty" else "Move"
print([thermostat(t) for t in (18, 22, 25)])
a = ModelBased()
print(a.act("A", "Dirty"), a.last_dirty)
Output
['heat on', 'heat off', 'heat off']
Suck ('A', True)
Common mistakes
- Using a simple reflex agent in a partially observable environment.
- Confusing a goal (yes/no) with a utility (degree of preference).
- Treating the table-driven agent as practical.
- Forgetting that a learning agent still has a performance element.
Key takeaways
- Agent = architecture + program.
- Five types: simple reflex, model-based, goal-based, utility-based and learning.
- Model-based agents keep an internal state; utility-based agents maximise expected utility.
- Learning agents have performance element, critic, learning element and problem generator.
Practice questions
- Which agent type needs a model of the world?
- How does a utility-based agent differ from a goal-based agent?
- Name the four components of a learning agent.
Answers to the practice questions
- The model-based reflex agent (and goal- and utility-based agents also use one).
- It uses a utility function to compare how good states are, not just whether the goal is achieved.
- Performance element, critic, learning element and problem generator.
Sources
- Official BCA syllabus Artificial Intelligence, course code 26BCA404DS04, Unit I
