CSE 4355 W1 Β· Class 2 Agents, PEAS and environments
Sakeef Sani β†— ↓ PDF

CSE 4355Week 1Class 2Sunday Β· 9:30 AM – 10:50 AM80 min

Agents, PEAS and environments

One skeleton for every AI system: percepts in, actions out.

S present Β· L lecturer notes Β· β†’ next step Β· F full screen Β· P presenter window
01 Cold open 0–7 min

Is a Pathao rider an agent? Are you?

The agent loop Percepts in, actions out, forever. Switch examples to see the same skeleton everywhere.
AgentRobot vacuumf(percept sequence) β†’ actionEnvironmentTwo dirty roomsSensors: Dirt sensor, locationActuators: Wheels, suctionperceptaction

Right now: percept [A, Dirty] β†’ action Suck

Anything that perceives its environment through sensors and acts on it through actuators is an agent.

One loop covers a robot vacuum, a dispatcher app and a medical device. Switch examples and watch the same skeleton.

02 Concept 7–14 min

Agent function vs agent program

Everything an agent has perceived so far is its percept sequence. Its behaviour is fully described by the agent function:

f:Pβˆ—β†’Af : \mathcal{P}^{*} \rightarrow \mathcal{A}

The agent program implements f on real hardware.

Gotcha

As a table, f needs βˆ‘t=1T∣P∣t\sum_{t=1}^{T}|\mathcal{P}|^t rows. A chess agent's table would have more rows than atoms in the universe. AI = writing small programs that behave rationally, not tables.

Percept sequenceAction
[A, Clean]Right
[A, Dirty]Suck
[B, Clean]Left
[A, Clean], [A, Clean]Right
[A, Clean], [A, Dirty]Suck
… (it never ends)…
03 Live lab 14–25 min

What makes an agent rational?

Rationality depends on four things: the performance measure, prior knowledge, the actions available, and the percept sequence so far.

A rational agent selects the action expected to maximise its performance measure, given the evidence and its built-in knowledge.

Vacuum world +1 per clean square per time step. Moving can cost 1. Which agent is rational?
A ●●●
β—‰
B ●●●
t = 0 Score = 0 Per step = β€”
Press Step or Play. Log shows percept β†’ action (reward).
04 Think deeper 25–29 min

Critical thinking Β· be careful what you reward

1 Trap

A startup rewards its vacuum agent +1 every time it performs Suck. The agent can also drop dirt from its bin.

What does a perfectly rational agent do? What should the performance measure be instead?

Work it out first.
Press Solve when the class has an answer.

05 Live lab 29–35 min

PEAS: specify the task first

Before designing any agent, write its task environment in four letters. Most bad AI projects skip this step.

PEAS builder Pick an agent. Class shouts answers first, then reveal each letter.
06 Worked example 35–42 min

Worked example: an agro-spraying drone

Given

Your lecturer co-founded an agro-drone startup for precision pesticide spraying on Bangladeshi farms.

Find

The full PEAS, the six environment properties, and a justified agent type (the exam-CQ structure).

Method: Russell & Norvig Ch. 2 (PEAS, task environments)

Solution

Predict the answer first. Then reveal one step at a time.

07 Live lab 42–51 min

Six questions about any environment

Observable?

Can sensors see everything relevant now?

Agents?

Do other agents' choices affect yours?

Deterministic?

Is the next state fixed by state + action?

Episodic?

Does today's decision change tomorrow?

Static?

Does the world change while you think?

Discrete?

Finite states, or smooth quantities?

Environment classifier Click a cell to cycle options. Fill the table in pairs, then press Check.
TaskObservableAgentsDeterministic?Episodic?Static?Discrete?
Crossword puzzle
Chess with a clock
Ludo
Poker
Driving a taxi in Dhaka
Medical diagnosis
Classifying skin-lesion photos

Some cells are genuinely debatable (is a photo classifier's world static or semi-dynamic?). Defend your answer and you get the mark.

08 Live lab 51–57 min

Five agent designs, each smarter than the last

Five agent designs Each one adds a single new idea to the one before it.
SensorsWhat the world is like nowCondition–action rulesAction

New idea

Nothing: if condition then action.

Example

Automatic door, the AC thermostat, the vacuum reflex agent.

Weakness

Blind to history. Loops forever in partially observable worlds.

Pro tip

The hardest case is partially observable, multi-agent, stochastic, sequential, dynamic and continuous: driving a CNG through Dhaka at 6 pm. That is why self-driving is still hard.

09 Your turn 57–61 min

Your turn Β· 1: a Ludo bot

04:00
2 Exam CQ

Write the PEAS for an agent that plays Ludo on a phone against three humans.

Classify its environment on all six properties.

Work it out first.
Press Solve when the class has an answer.

10 Your turn 61–64 min

Your turn Β· 2: which agent type?

3 Warm-up

(a) An automatic hand dryer. (b) A robot vacuum that maps your flat. (c) A route planner that minimises time and toll cost together. (d) A spam filter that improves from your "not spam" clicks.

Work it out first.
Press Solve when the class has an answer.

11 Think deeper 64–68 min

Critical thinking Β· rational, but for whom?

Think deeper

A ride-hailing dispatcher maximises total company revenue. It is perfectly rational. Is it a good agent?

Argue it in pairs for two minutes. There may be more than one defensible answer.

Think deeper

Is a chess engine's world static? What about the same engine playing with a clock?

Argue it in pairs for two minutes. There may be more than one defensible answer.

12 Think deeper 68–71 min

Critical thinking Β· design a performance measure

4 Design

Dhaka Medical College's emergency department wants an agent that assigns incoming patients to doctors.

Write its performance measure as a formula or a ranked list. Include at least one hard constraint and one way the measure could be gamed.

Work it out first.
Press Solve when the class has an answer.

13 Real world 71–74 min

The agent inside an insulin pump

BME corner

For a person with type 1 diabetes, a "hybrid closed-loop" system (first approved in the US in 2016) is an agent: a continuous glucose monitor is the sensor, the pump is the actuator, and an algorithm decides the dose every few minutes. The patient still announces meals, hence "hybrid".

Partially observable (the sensor reads fluid under the skin, minutes behind the blood) and stochastic (meals, exercise, stress), so it needs an internal model.

The measure is asymmetric: too high is bad over years, too low is dangerous within minutes. So a sensible design is utility-based and cautious, not "high β†’ inject".

14 Pop quiz 74–78 min

Pop quiz

Score 0

Question 1 / 5

An agent function maps…

15 Recap 78–80 min

Three things to remember

01

Agent = sensors + actuators + a program implementing f: percept sequence β†’ action. Rational = best expected performance, not perfect.

02

Specify with PEAS; classify the environment on six properties. The properties decide what kind of agent you need.

03

Reflex β†’ model-based β†’ goal-based β†’ utility-based β†’ learning. Next week: goal-based agents that search, and logic. Assignment 1 is published.