Nexus Learn

Lecture 4: Intelligent Agents: PEAS, Environments and Agent Types

Lecture Slides CS-511 Artificial Intelligence 9 min read Updated 8 Nov 2026

↓ Download slides (PowerPoint)

Recap of Lecture 3 and Homework Check

LAST LECTURE · 5 MIN

Turing machine

Limits

Turing Test

Tape, head, states, rules. (state, read) → (write, move, next).

Church-Turing thesis; the halting problem is undecidable.

Judge vs hidden human and machine. Chinese Room: syntax ≠ semantics.

Link: L03 said the Turing Test measures fooling people. Today: measure AI by what it DOES - rational agents.

Today's Plan (90 minutes)

ROADMAP

0-5

Recap of Lecture 3 and homework check

S02

5-8

Plan and learning outcomes

S03-S04

8-22

Module 1: Agents, percepts, agent function and program

S05-S08

22-38

Module 2: Rationality, performance measures and PEAS

S09-S13

38-52

Module 3: Properties of task environments

S14-S16

52-74

Module 4: Five agent types + Python demo

S17-S24

74-84

Class activity: PEAS, environment and agent type

S25

84-90

Mistakes, recap quiz, homework

S26-S28

Learning Outcomes (SLOs)

BY THE END OF THIS LECTURE YOU WILL BE ABLE TO

SLO 4.1

Define agent, sensor, actuator, percept sequence, agent function and agent program

→ CLO1 · C1 Remember

SLO 4.2

Explain rationality, performance measures, autonomy and why rational ≠ perfect

→ CLO1 · C2 Understand

SLO 4.3

Specify the PEAS description of a task environment

→ CLO1 · C2 Understand

SLO 4.4

Classify task environments by their seven properties

→ CLO1 · C2 Understand

SLO 4.5

Compare the five agent types and choose a suitable type for a task

→ CLO1 · C2 Understand

  • Course Learning Outcome(s) served
  • CLO1: Explain the applications of AI and agent-based approach to AI.

Slide 5

MODULE 1

What Is an Agent?

Anything that senses its world and acts on it

Agent and Environment

MODULE 1 · AGENTS

ENVIRONMENT

AGENT

The world around the agent: a room, a road, a chess board, a website

percepts

Sensors

  • Agent program
  • (the 'brain': decides)

Actuators

actions

Agent: anything that perceives its environment through sensors and acts on it through actuators.

Agents All Around Us

MODULE 1 · AGENTS

Percept: what the agent senses at ONE moment (one camera frame, one e-mail).

Percept Sequence, Agent Function and Agent Program

MODULE 1 · AGENTS

  • Percept sequence: everything the agent has ever perceived.
  • Agent function: maps every percept sequence → an action (a table, on paper).
  • Agent program: the code that implements the function on real hardware.
  • Agent = architecture (hardware) + program.

AGENT PROGRAM (PYTHON)

  • def reflex_agent(percept):
  • location, status = percept
  • if status == "Dirty":
  • return "Suck"
  • return "Right" if location == "A" else "Left"

Vacuum world: two squares A and B; each is Clean or Dirty. Actions: Left, Right, Suck, NoOp.

Slide 9

MODULE 2

Rational Agents and PEAS

How do we judge an agent, and how do we describe its task?

Rationality

MODULE 2 · RATIONAL AGENTS

A rational agent chooses the action that is EXPECTED to give the best performance, using what it has perceived and what it knows.

Performance measure

Prior knowledge

Possible actions

Percept sequence

How success is scored

What it knows about the environment

What it is able to do

What it has sensed so far

Good habits: gather information (look both ways), learn from experience, act autonomously (on own percepts).

Designing a Performance Measure

MODULE 2 · RATIONAL AGENTS

Rule: measure what you WANT in the environment, not how you think the agent should behave.

PEAS: Describing a Task Environment

MODULE 2 · PEAS

Exam tip: write PEAS as four labelled lines. Give at least three items in each line.

PEAS Examples

MODULE 2 · PEAS

Notice: software agents have software sensors and actuators (clicks in, web pages out).

Slide 14

MODULE 3

Properties of Task Environments

Seven questions that decide how hard an agent's job is

Seven Properties of an Environment

MODULE 3 · ENVIRONMENTS

Hardest case: partially observable, multi-agent, stochastic, sequential, dynamic, continuous, unknown - like driving in Lahore.

Classifying Real Environments

MODULE 3 · ENVIRONMENTS

Semi-dynamic: the world does not change while the agent thinks, but its score does (chess clock).

Slide 17

MODULE 4

Five Types of Agents

From simple IF-THEN reflexes to agents that learn

1. Simple Reflex Agent

MODULE 4 · AGENT TYPES

Percept

What is the world like NOW?

Condition-action rule (IF ... THEN ...)

Action

  • Uses: only the current percept - no memory.
  • Rules: IF dirty THEN suck. IF dark THEN street light ON. IF car in front brakes THEN brake.
  • Works when: the environment is fully observable.
  • Weakness: no memory → can repeat useless actions forever (infinite loops).

Local example

An automatic street light on a Burewala road: IF it is dark THEN switch on. It does not remember yesterday.

2. Model-Based Reflex Agent

MODULE 4 · AGENT TYPES

Percept

Update internal state (using a model of the world)

Condition-action rule

Action

  • Adds: internal state = what it believes about the parts of the world it cannot see now.
  • Model: knowledge of how the world changes and what its actions do.
  • Works when: the environment is partially observable.

Example

A driver remembers the motorbike seen in the mirror one second ago, now hidden in the blind spot, and does not change lane.

Robot vacuum: builds a map of your room, so it knows which areas are already clean.

Demo: Reflex vs Model-Based Vacuum (Python)

MODULE 4 · AGENT TYPES

MODEL-BASED AGENT (FULL CODE: NOTES §4.3)

REAL OUTPUT

  • def make_model_agent():
  • model = {"A": None, "B": None} # internal state
  • def agent(percept):
  • location, status = percept
  • model[location] = status
  • if status == "Dirty":
  • model[location] = "Clean"
  • return "Suck"
  • if model["A"] == model["B"] == "Clean":
  • return "NoOp" # all clean: rest
  • return "Right" if location == "A" else "Left"
  • return agent
  • Simple reflex agent:
  • t=1 Suck at A A=Clean B=Dirty score=1
  • t=2 Right at B A=Clean B=Dirty score=1
  • t=3 Suck at B A=Clean B=Clean score=3
  • t=4 Left at A A=Clean B=Clean score=4
  • t=5 Right at B A=Clean B=Clean score=5
  • t=6 Left at A A=Clean B=Clean score=6
  • Model-based agent:
  • t=1 Suck at A A=Clean B=Dirty score=1
  • t=2 Right at B A=Clean B=Dirty score=1
  • t=3 Suck at B A=Clean B=Clean score=3
  • t=4 NoOp at B A=Clean B=Clean score=5
  • t=5 NoOp at B A=Clean B=Clean score=7
  • t=6 NoOp at B A=Clean B=Clean score=9
  • Final scores -> reflex: 6 | model-based: 9

Lesson: memory (internal state) lets the agent stop wasting energy: score 9 vs 6.

3. Goal-Based Agent

MODULE 4 · AGENT TYPES

Percept + state

What will happen if I do action A?

Does it reach my GOAL?

Action

  • Adds: a goal (a desired situation) and thinking about the future.
  • Needs: search and planning to find a sequence of actions (Lectures 10-18).
  • Strength: flexible - change the goal and the same agent still works.

Example

Google Maps: goal = reach UAF Sub Campus Burewala. It plans a route of turns that reaches the goal.

Limit: goals are yes/no. Many routes reach the goal - which one is BEST? → utility.

4. Utility-Based Agent

MODULE 4 · AGENT TYPES

Percept + state

What will happen if I do A?

How GOOD will that be? (utility)

Best action

  • Utility function: gives a score of how good (desirable) a state is.
  • Needed for: trade-offs between goals (fast vs cheap vs safe) and uncertainty (expected utility).
  • Rational choice: the action with the highest expected utility.

Example

Careem weighs arrival time, fare, driver rating and safety into one score and picks the best driver.

Goal vs utility: goal = 'reach Lahore' (yes/no). Utility = 'reach quickly, cheaply and safely' (a score).

5. Learning Agent

MODULE 4 · AGENT TYPES

Performance element

Critic

Learning element

Problem generator

  • Chooses the actions (the agent so far).
  • Spam filter: decides inbox or spam.
  • Tells how well it is doing.
  • You click 'Report spam' or 'Not spam'.
  • Improves the performance element from feedback.
  • Updates the spam model.
  • Suggests new actions to explore and learn.
  • Tries new kinds of decisions.

Why learn? an agent that learns can work in unknown environments and improve over time (Lectures 24-28).

Comparing the Five Agent Types

MODULE 4 · AGENT TYPES

Pattern: each type adds one idea: memory → goals → utility → learning.

Activity: Design the Agent

CLASS ACTIVITY · GROUPS OF 3 · 10 MIN

In groups of 3, choose ONE case. Write (a) PEAS, (b) the seven environment properties, (c) the best agent type, with reasons.

Smart irrigation for a wheat farm near Burewala (opens the tubewell when soil is dry)

A traffic-signal controller at a busy Vehari Chowk

A Ludo-playing app that plays against you

A WhatsApp customer-service bot for a mobile company

An AI that marks students' handwritten MCQ answer sheets

A cricket bowling machine that adjusts to the batsman

Common Mistakes

WATCH OUT

WRONG IDEA

CORRECT IDEA

✗ An agent must be a robot.

✓ Software is also an agent: spam filter, Careem app.

✗ Rational means perfect or all-knowing.

✓ Rational = best EXPECTED action with the information available.

✗ Performance measure = how the agent should behave.

✓ Measure what you want in the environment (clean floor), not behaviour.

✗ Chess is stochastic because the opponent is unknown.

✓ Chess is deterministic (no chance); the opponent makes it MULTI-agent.

✗ A goal-based agent always finds the best route.

✓ Goals are yes/no; choosing the BEST needs utility.

Recap Quiz

CHECK YOUR UNDERSTANDING · 5 MIN

  • Q1. In PEAS, 'A' stands for:
  • (a) Agents (b) Actuators (c) Actions (d) Accuracy
  • Q2. An agent that acts only on the current percept with IF-THEN rules is:
  • (a) Goal-based (b) Utility-based (c) Simple reflex (d) Learning
  • Q3. Ludo is stochastic because of:
  • (a) Other players (b) The dice (c) The board (d) The timer
  • Q4. Checking X-rays one by one, each decision independent, is:
  • (a) Episodic (b) Sequential (c) Dynamic (d) Multi-agent
  • Q5. 'How good will this outcome be?' is the question of a:
  • (a) Reflex agent (b) Model-based agent (c) Utility-based agent (d) Turing machine
  • Q6. In a learning agent, the part that gives feedback is the:
  • (a) Critic (b) Actuator (c) Problem generator (d) Sensor

Homework and Next Lecture

BEFORE THE NEXT CLASS

  • Task 1: Write PEAS for (a) a robot that picks ripe cotton, (b) an online exam proctoring AI.
  • Task 2: Classify these on all seven properties: football-playing robot, Sudoku solver, weather-forecasting system.
  • Task 3: For the robot vacuum demo, explain in 4-5 lines why the model-based agent scored higher.
  • Read: Russell & Norvig, Chapter 2 (Intelligent Agents).
  • Lab: Practical 2 this week - build a perceptron (a learning agent's brain) from scratch.

NEXT LECTURE

  • Lecture 5:
  • Knowledge Representation

← All CS-511 material