Is a Pathao rider an agent? Are you?
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.
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:
The agent program implements f on real hardware.
As a table, f needs βt=1Tββ£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 sequence | Action |
|---|---|
| [A, Clean] | Right |
| [A, Dirty] | Suck |
| [B, Clean] | Left |
| [A, Clean], [A, Clean] | Right |
| [A, Clean], [A, Dirty] | Suck |
| β¦ (it never ends) | β¦ |
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.
Press Step or Play. Log shows percept β action (reward).
Critical thinking Β· be careful what you reward
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.
PEAS: specify the task first
Before designing any agent, write its task environment in four letters. Most bad AI projects skip this step.
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.
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?
| Task | Observable | Agents | Deterministic? | 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.
Five agent designs, each smarter than the last
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.
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.
Your turn Β· 1: a Ludo bot
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.
Your turn Β· 2: which agent type?
(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.
Critical thinking Β· rational, but for whom?
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.
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.
Critical thinking Β· design a performance measure
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.
The agent inside an insulin pump
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".
Pop quiz
Question 1 / 5
An agent function mapsβ¦
Three things to remember
Agent = sensors + actuators + a program implementing f: percept sequence β action. Rational = best expected performance, not perfect.
Specify with PEAS; classify the environment on six properties. The properties decide what kind of agent you need.
Reflex β model-based β goal-based β utility-based β learning. Next week: goal-based agents that search, and logic. Assignment 1 is published.