Building Blocks of Intelligent Agents, Explained

UPI Study › Courses › Introduction to Artificial Intelligence › Free lessons › Lesson 2.4 Free with a free account

Building Blocks of Intelligent Agents

Introduction to Artificial Intelligence · Chapter 2: Intelligence, Cognition, and Agent DesignSection 2.4 · lesson 12 of 6914 min · free with a free account

← Expert Systems and AI Approaches to Complex ChallengesNext lesson: Reactive Agents: Condition-Action Responses →

Earn 3 college credits for Introduction to Artificial IntelligenceRecommended for credit by NCCRS · Computer Science 373 · self-paced · one payment, lifetime access

In this lesson

Describing agent tasks with PEAS, rating environments, and writing agent programs.

  • Write a PEAS description for an agent's task
  • Classify a task environment using five properties and explain what each harder property demands
  • Distinguish the agent function from the agent program and explain why lookup tables fail
  • Explain how the performance measure shapes rational behavior

Free study notes

Get this lesson's notes by email

The key points and 4 practice questions with answers, in your inbox. One email, free.

One email. Unsubscribe in one click.

Transcript

Everything said in the video, section by section (2,000 words). Read along, or search it.

Opening Question

Four Questions Before Any Code

Two engineers get new jobs on the same morning. One must build a cleaning robot. The other must build a self-driving taxi. Neither one can write any code yet. First, each must answer four questions. What counts as doing the job well? What world will the agent work in? What can it do to that world? And what can it sense? Those answers shape every design choice that follows. So let's learn to ask them clearly, and see the simple program shape that puts the answers to work.

PEAS

Performance, Environment, Actuators, Sensors

Engineers write the answers down as a four-part checklist called PEAS. Writing it first prevents vague goals and forgotten details. The letter P stands for the performance measure: what counts as doing well. For the taxi, that's safe, legal, fast and comfortable trips, low fuel use, and profit. The letter E stands for the environment, the world it works in: roads, traffic, pedestrians, weather, and passengers. The letter A stands for the actuators, the parts that change the world: steering, accelerator, brake, indicators, horn, and a display screen. And S stands for the sensors, what it can sense: cameras, radar, GPS, the speedometer, a microphone, and passenger requests. Here's how the four parts fit together. The agent sits inside its environment, the world it works in. Sensors carry information from the environment into the agent. Actuators carry the agent's actions back out. And the performance measure sits outside the agent. It judges the results in the environment, not what the agent meant to do. The same four parts fit very different agents. A robot vacuum is judged on a clean floor, done quickly, quietly and cheaply. It works among rooms, furniture, pets and people. It acts with wheels, brushes and suction, and it senses bumps, dirt, cliffs and its own battery. A spam filter is judged on spam caught, and few good emails blocked. Its world is an inbox, with incoming mail and spammers. It acts by moving or flagging a message, and it senses the text, the sender, the links, and your not-spam clicks. Smart irrigation is judged on healthy plants and little wasted water. It works in a garden bed, acts with a valve and pump, and senses soil moisture, rain and time.

Writing It Well

Specific Measures and Real Tradeoffs

A good PEAS description is specific. Clean is vague. Every square clean, for as much of the day as possible, can be measured. Real tasks have goals that pull against each other, like speed against safety, or cleaning against noise. So the measure must say how to trade them off. And list every sensor and actuator the agent really has. It can act only on what it senses, and change only what it can move.

Environment Properties

Five Questions That Rate Difficulty

The same agent can do well in one world, and fail in another. Five questions rate how demanding an environment is, and each has an easier answer and a harder one. Observable: can the agent see everything it needs? Fully observable is easier. Partially observable, with important facts hidden, is harder. Deterministic: does the same action always give the same result? If chance is involved, the world is stochastic. Episodic: does each decision stand alone? If today's choice changes tomorrow's options, it's sequential. Static: does the world wait while the agent thinks? If it keeps changing, it's dynamic. Discrete: can the possibilities be listed one by one? If values like speed or position vary smoothly, it's continuous.

Worked Examples

Chess, Poker, Sorting Robot, and Taxi

Here's how four environments rate, from easiest to hardest. Chess sits at the easy end of most: both players see the whole board, every move has an exact result, and the pieces never move on their own. But chess is sequential, since every move shapes the rest of the game. And it's static only if you ignore the clock. Poker hides the other players' cards, and the deal is chance. So it's partially observable and stochastic, as well as sequential. A robot sorting parts on a moving belt treats each part alone, so it's episodic. But it can't see everything, chance plays a part, the belt moves, and positions vary smoothly. And a self-driving taxi is hard on all five. It can't see around corners, other drivers are unpredictable, every turn shapes the trip, traffic moves while it decides, and speed is continuous.

Agent Demands

What Each Hard Answer Requires

Each hard answer asks more of the agent. In a partially observable world, it must remember what it saw, or guess carefully. A vacuum can't see dirt in a room it isn't in. In a stochastic world, it must prepare for several outcomes. A wheel might slip, so a turn may not go as planned. Sequential means thinking about future consequences. Watering a garden today changes what it needs tomorrow. Dynamic means deciding quickly, and checking again and again. A car must brake before the pedestrian reaches the road. And continuous means handling endless values, usually by rounding. A steering wheel can turn to any angle, not just left or right.

Quick Check

Rating a Crossword Solver

Quick check. A program solves crossword puzzles. It sees the whole grid at once. As it works, the grid fills up, letter by letter, and every word it writes limits which words can fit later. Which property is on the harder side here: partially observable, sequential, or dynamic? Pause, and decide. Sequential. Every word it writes changes the options for the words that come after it, so earlier choices matter later. Dynamic is the tempting pick, because the grid keeps changing. But it changes only when the program writes. Nothing moves while it thinks, so the world is static. And since it sees the whole grid, it's fully observable.

Key Terms

Percept History, Function, Program, Architecture

Now, two phrases that sound alike, but mean different things. An agent's percept history is everything it has sensed so far. The agent function says, for every possible percept history, which action the agent chooses. The agent program is the actual code that carries out that function on a real device. That device, with its sensors, actuators and computer, is called the architecture.

Analogy

Square Root as Function and Method

Mathematics has a good parallel. The function square root matches every number with its root. Nobody stores a giant table of every number and its root. A calculator runs a short method, and gets the same answers. The function says what the answer is. The program is how it's produced. And many different programs can carry out the same function.

Vacuum World

A Two-Square Agent Function Table

To see why this matters, take a tiny world with just two squares, A and B. Each square is either clean or dirty. A vacuum agent senses two things: which square it's in, and whether that square is dirty. It can move Left, move Right, or Suck up dirt. Its agent function is a table: every possible history of percepts gets an action. Dirty in A? Suck. Dirty in B? Suck too. Clean in A? Move right. Clean in B? Move left. And longer histories get entries too. Clean in A, then dirty in B? Suck. And so on, for every history, however long.

Table Explosion

Why a Lookup Table Fails

Why not just store that whole table? Because it explodes. There are four possible percepts: two squares, each clean or dirty. So there are 4 histories after one step, 16 more of length two, and 64 more of length three. Each extra step multiplies by four. A life of 10 steps needs about 1.4 million entries. A life of 20 steps needs about 1.5 trillion. And after about 133 steps, the table would need more entries than there are atoms in the observable universe, roughly 10 to the 80th. Real agents sense far more than four things. One camera image holds millions of pixel values, so a table is hopeless. Good design means writing a short program that makes the right choices, without ever storing the table.

Rationality

Rational for the Measure It Is Given

Now rationality, stated precisely. A rational agent chooses the action expected to maximize its performance measure, given its percept history and what it already knows. Notice the first ingredient: the measure. The agent is rational for the measure it's given. A badly written measure gives behavior that's rational, but not what anyone wanted. Take the same vacuum, with two measures. Score one point for every unit of dirt sucked up, and a rational vacuum sucks up dirt, dumps it back out, and sucks it up again. Score one point for each clean square at each time step, minus a little for every move, and it cleans the squares, then stops moving. The rule: measure the outcome you want in the environment, not the behavior you think will produce it.

Quick Check

A Chatbot Scored on Speed

Quick check. A help-desk chatbot is scored on one thing only: how quickly each chat ends. Acting rationally for that measure, what will it learn to do? Solve each problem fully, end chats before they're solved, or ask for more and more details? Pause, and decide. End chats before they're solved. Closing a chat fast is exactly what the measure rewards, whether or not the customer got help. Solving each problem fully is what the owner wanted, but it takes longer, so this measure punishes it. The fix is to score the outcome: problems really solved, and customers satisfied.

Two More Ideas

Information Gathering and Autonomy

Two more ideas about rational agents. First, gathering information is rational. Looking both ways before you cross doesn't move you forward, but it improves what you know, and so your choice. Agents in partially observable worlds sometimes act just to find out more. Second, autonomy. An agent that relies only on what its designer built in is fragile. A more autonomous agent adjusts, using its own experience, when that built-in knowledge is incomplete or wrong.

Program Skeleton

Percept In, Action Out

However clever an agent is, its program follows the same skeleton. It takes in the current percept. It may update something it remembers. It chooses an action, and sends that action out. Then it waits for a new percept, and runs again, once for every percept, for as long as it lives.

Table-Driven Agent

Looking Up the Whole History

The most direct program uses the lookup table. Call it the table-driven agent. It keeps a list of every percept so far. Each time, it adds the new percept to that list, looks the whole list up in the table, and returns the action it finds. It follows the skeleton exactly. Its only flaw is that enormous table.

Compact Program

Three Rules Replace the Table

A short program can often do the same job. For the two-square vacuum, three rules reproduce the sensible choices. If the square is dirty, suck. Otherwise, if it's in A, move right. If it's in B, move left. A lookup table stores every history, and grows four times bigger with every step. These three rules stay the same size forever, and anyone can read them and fix them.

Worked Example

A Smart Irrigation Program

Here's everything working together, in a smart irrigation system. Rate its environment. It's partially observable, since one probe measures only one spot. It's stochastic, because rain may or may not come as forecast. It's sequential, since water given today changes what the soil needs tomorrow. And it's dynamic and continuous: moisture and time keep changing, smoothly. Because it's sequential, its program remembers one thing: how many minutes the valve has been open today. Once a minute, it reads the soil and the forecast. If the daily limit is reached, it closes the valve. If the soil is dry and no rain is expected, it adds a minute and opens the valve. Otherwise, it closes it.

Key Takeaways

PEAS, Environments, and Agent Programs

To sum up. PEAS describes a task in four parts: performance measure, environment, actuators and sensors. Five questions rate an environment, from observable to discrete, and the harder answers demand more of the agent. An agent function says what to do for every percept history. An agent program is the short code that does it, because a lookup table explodes. A rational agent maximizes the measure it's given, so measure the outcome you want. And every agent program shares one skeleton: percept in, update memory, choose an action.

Reflection

PEAS for a Device at Home

Here's something to think about. Pick a device in your home that has a sensor and an actuator. Write its PEAS description. Then ask: which of the five environment properties make its job harder?

About Introduction to Artificial Intelligence at UPI Study

Introduction to Artificial Intelligence (Computer Science 373) is a self-paced online course of 69 video lessons in 9 chapters, from intelligent agents and search to game strategy, neural networks, logic and reasoning, machine learning, language, robotics and AI ethics. It carries a NCCRS credit recommendation for 3 semester credits.

Every lesson transcript is free on pages like this one, and the videos are free with a free UPI Study account. Enrolling adds a practice quiz after each lesson, the graded work and final exam that earn the credit, lifetime access, and an official transcript on completion. UPI Study has helped over 130,000 students with college credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Compare: AI vs Current Trends in CS and IT

Why take it here

Why students take Introduction to Artificial Intelligence with UPI Study

How machines search, reason and learnIntroduction to Artificial Intelligence covers how AI systems are built: intelligent agents, search and heuristics, game strategy, logic, neural networks, machine learning, language and perception, and the ethics of AI. It is a common upper-level course in computer science degrees.
Credit at a fraction of the priceThe same 3 credits can cost $750 or more at a US college. Here it is one payment, self-paced, with lifetime access.
Finish your degree soonerTransfer credits reduce the courses you still owe, so you can graduate earlier or lighten a heavy semester.
Strengthen an applicationA completed college-level course on an official transcript shows admissions and scholarship committees you can do the work.
Study on your own scheduleNo start dates, no deadlines. Watch the lessons, practice, and take the final when you are ready.
130,000+students helped with college creditsACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Where the credit goes

Universities that work with NCCRS

Introduction to Artificial Intelligence carries a NCCRS credit recommendation. These universities work with NCCRS; some are UPI Study's signed partners. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

Find my college → Not listed? Ask Athena in the corner of this page, or book a 15-minute call.

FAQ

Questions students ask us

About Building Blocks of Intelligent Agents

What does PEAS stand for in AI?
PEAS stands for performance measure, environment, actuators, and sensors, a four-part checklist for describing an agent's task before designing it. For a self-driving taxi, the performance measure includes safe, legal, fast, and comfortable trips; the environment includes roads, traffic, and pedestrians; the actuators include steering, accelerator, and brake; and the sensors include cameras, radar, GPS, and the speedometer.
What are the properties of a task environment in AI?
Five properties rate how demanding an environment is: fully or partially observable, deterministic or stochastic, episodic or sequential, static or dynamic, and discrete or continuous. The second option in each pair is harder. Chess is fully observable, deterministic, and discrete but sequential. A self-driving taxi is on the hard side of all five, since it cannot see around corners and traffic keeps moving while it decides.
What is the difference between an agent function and an agent program?
The agent function is the mapping from every possible percept history to an action, while the agent program is the actual code that carries out that function on a real device. Storing the function as a lookup table explodes: a two-square vacuum with four possible percepts needs about 1.4 million entries for a 10-step life. Three short rules can produce the same sensible choices.
Why does the performance measure matter for a rational agent?
A rational agent chooses actions expected to maximize whatever performance measure it is given, so a badly chosen measure produces rational but unwanted behavior. A vacuum scored on dirt sucked up could dump dirt and suck it up again, and a help-desk chatbot scored only on chat speed would end chats before solving problems. The fix is to measure the outcome wanted in the environment, not the behavior expected to produce it.

About the Introduction to Artificial Intelligence course

How many college credits is Introduction to Artificial Intelligence?
Introduction to Artificial Intelligence (Computer Science 373) carries a NCCRS credit recommendation for 3 semester credits. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.
How much does Introduction to Artificial Intelligence cost and what is included?
$250, paid once, with lifetime access: all 69 video lessons, a practice quiz after each, the graded work and final exam, and an official transcript when you finish. Students who want several courses choose UPI Study PRO instead.
Which universities accept UPI Study credits?
UPI Study has signed partner agreements with universities such as Thomas Edison State University, University of the People and Charter Oak State College, and works with universities such as Penn State, SNHU and SUNY. ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities. Use "Find my college" on this page to check yours.
How long does Introduction to Artificial Intelligence take?
It is self-paced with no deadlines. The 69 lessons total about 16 hours of video; most students add reading and practice time and finish in a few weeks to a few months, on their own schedule.
How are the exams done?
Quizzes and assignments are online in the course. The final exam is taken online with proctoring; a person on the UPI Study team checks assignments, usually within two days.
How do my credits reach my college?
When the course shows 100% complete, request the official transcript from your dashboard. It is sent to the college you name, and you can send it to more than one. Check your college first with "Find my college" on this page, or ask Athena.

Ready for the full course? Earn 3 credits in Introduction to Artificial Intelligence.

69 video lessons, a quiz after each one, and the graded work that earns the credit. Recommended for credit by NCCRS.

Introduction to Artificial Intelligence
3 credits · NCCRS
Enroll →