cs 380: artificial intelligence rational agentssanti/teaching/2013/cs380/...solitaire chess...

41
CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTS 9/25/2013 Santiago Ontañón [email protected] https://www.cs.drexel.edu/~santi/teaching/2013/CS380/intro.html

Upload: others

Post on 27-Mar-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTS

9/25/2013 Santiago Ontañón [email protected] https://www.cs.drexel.edu/~santi/teaching/2013/CS380/intro.html

Page 2: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

• Do you think a machine can be made that replicates human intelligence?

Page 3: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Outline • What is an Agent? • Rationality • Agents and Environments • Agent Types

(these slides are adapted from Russel & Norvig’s official slides)

Page 4: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Outline • What is an Agent? • Rationality • Agents and Environments • Agent Types

(these slides are adapted from Russel & Norvig’s official slides)

Page 5: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

What is an Agent? • Agent: autonomous entity which observes and acts upon

an environment and directs its activity towards achieving goals.

• Example agents: •  Humans •  Robots •  Software agents •  ATMs •  etc.

Page 6: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

What is an Agent?

•  Theoretically:

•  In practice: the agent runs on a physical system (e.g. a computer) to produce

Agents and environments

?

agent

percepts

sensors

actionsenvironment

actuators

Agents include humans, robots, softbots, thermostats, etc.

The agent function maps from percept histories to actions:

f : P∗ → A

The agent program runs on the physical architecture to produce f

Chapter 2 4

f : P ⇤ ! A

f

Page 7: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

What is an Agent?

•  Theoretically:

•  In practice: the agent runs on a physical system (e.g. a computer) to produce

Agents and environments

?

agent

percepts

sensors

actionsenvironment

actuators

Agents include humans, robots, softbots, thermostats, etc.

The agent function maps from percept histories to actions:

f : P∗ → A

The agent program runs on the physical architecture to produce f

Chapter 2 4

f : P ⇤ ! A

f

Maps sequences of percepts to actions

Page 8: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Vacuum Cleaner

• Percepts: •  Location sensor and Dirt sensor

• Actions: •  Left, Right, Suck, Wait

Room A Room B

Vacuum-cleaner world

A B

Percepts: location and contents, e.g., [A, Dirty]

Actions: Left, Right, Suck, NoOp

Chapter 2 5

Page 9: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Vacuum Cleaner

• Percepts: •  Location sensor and Dirt sensor

• Actions: •  Left, Right, Suck, Wait

Room A Room B

Vacuum-cleaner world

A B

Percepts: location and contents, e.g., [A, Dirty]

Actions: Left, Right, Suck, NoOp

Chapter 2 5

[A, Clean]

Page 10: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Vacuum Cleaner A vacuum-cleaner agent

Percept sequence Action[A, Clean] Right[A, Dirty] Suck[B, Clean] Left[B, Dirty] Suck[A, Clean], [A, Clean] Right[A, Clean], [A, Dirty] Suck... ...

function Reflex-Vacuum-Agent( [location,status]) returns an action

if status = Dirty then return Suckelse if location = A then return Rightelse if location = B then return Left

What is the right function?Can it be implemented in a small agent program?

Chapter 2 6

Page 11: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Vacuum Cleaner A vacuum-cleaner agent

Percept sequence Action[A, Clean] Right[A, Dirty] Suck[B, Clean] Left[B, Dirty] Suck[A, Clean], [A, Clean] Right[A, Clean], [A, Dirty] Suck... ...

function Reflex-Vacuum-Agent( [location,status]) returns an action

if status = Dirty then return Suckelse if location = A then return Rightelse if location = B then return Left

What is the right function?Can it be implemented in a small agent program?

Chapter 2 6

Two questions:

•  What is the function?

•  Can it be implemented as a computer program? (How?)

Page 12: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Outline • What is an Agent? • Rationality • Agents and Environments • Agent Types

(these slides are adapted from Russel & Norvig’s official slides)

Page 13: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Rationality • As we discussed last class, “intelligence” is an ill-defined

concept.

•  Let us assume a performance measure, for example: •  $1 per room cleaned •  $10 per room cleaned minus $1 per each movement •  etc.

• Rational agent: •  Chooses actions that maximize the expected value of the

performance measure given the current percept sequence.

Page 14: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Rationality • As we discussed last class, “intelligence” is an ill-defined

concept.

•  Let us assume a performance measure, for example: •  $1 per room cleaned •  $10 per room cleaned minus $1 per each movement •  etc.

• Rational agent: •  Chooses actions that maximize the expected value of the

performance measure given the current percept sequence.

Performance measure is given (external) to the agent.

Page 15: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Rationality •  Imagine two agents A and B whose performance measure

is defined by how many $ they make at the casino. •  A and B play one game of Black Jack •  A plays the move that theoretically has higher chances of winning •  B plays a different, more risky move •  B ends up winning

• Which agent is rational?

Page 16: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Rationality •  Imagine two agents A and B whose performance measure

is defined by how many $ they make at the casino. •  A and B play one game of Black Jack •  A plays the move that theoretically has higher chances of winning •  B plays a different, more risky move •  B ends up winning

• Which agent is rational? A is the rational agent •  Rationality does not imply clairvoyance •  Rationality does not imply omniscient •  Thus, rational does not mean successful

Page 17: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Outline • What is an Agent? • Rationality • Agents and Environments • Agent Types

(these slides are adapted from Russel & Norvig’s official slides)

Page 18: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

How do we Design a Rational Agent? •  To design a rational agent, we first need to define its

environment, performance measure, etc.

• PEAS: •  Performance •  Environment •  Actions •  Sensors (percepts)

Page 19: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example (informal): Automated Taxi • Performance:

• Environment:

• Actions:

• Sensors:

Page 20: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example (informal): Automated Taxi • Performance: profit, safety, legality, …

• Environment: streets, pedestrians, cars, weather, traffic lights/signs, …

• Actions: steering, throttle, break, horn, display, …

• Sensors: GPS, video, sonar, keyboard, accelerometers, microphones, …

Page 21: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance:

• Environment: • Actions:

• Sensors:

Page 22: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance:

• Environment: Chess board, and opponent.

• Actions:

• Sensors:

Page 23: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance: Once reached a terminal state (draw, win):

-1 for losing, 0 for draw, 1 for winning. • Environment: Chess board, and opponent.

• Actions:

• Sensors:

Page 24: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance: Once reached a terminal state (draw, win):

-1 for losing, 0 for draw, 1 for winning. • Environment: Chess board, and opponent.

• Actions: Pairs of coordinates: (x1,y1) à (x2, y2). Specify the source piece and the target position (for castling, the king’s move is specified).

• Sensors:

Page 25: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance: Once reached a terminal state (draw, win):

-1 for losing, 0 for draw, 1 for winning. • Environment: Chess board, and opponent.

• Actions: Pairs of coordinates: (x1,y1) à (x2, y2). Specify the source piece and the target position (for castling, the king’s move is specified).

• Sensors: Board perceived as a 8x8 matrix. Each element in the matrix can take one of the following values: E, BP, WP, BB, WB, BK, WN, BR, WN, BQ, WK, BK, WK

Page 26: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent • Performance: Once reached a terminal state (draw, win):

-1 for losing, 0 for draw, 1 for winning. • Environment: Chess board, and opponent.

• Actions: Pairs of coordinates: (x1,y1) à (x2, y2). Specify the source piece and the target position (for castling, the king’s move is specified).

• Sensors: Board perceived as a 8x8 matrix. Each element in the matrix can take one of the following values: E, BP, WP, BB, WB, BK, WN, BR, WN, BQ, WK, BK, WK

The environment might have lots of features (piece size and material,

opponent’s facial expression, etc.). When designing a rational agent, we only need to provide sensors for the

information that is necessary to achieve the agent’s goals (maximize

performance measure)

Page 27: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Example: Chess Agent

Environment

WR WN WB WK WQ WB WN WR

WP WP WP WP WP WP WP WP

BP BP BP BP BP BP BP BP

BR BN BB BK BQ BB BN BR

Percept

Page 28: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire

Chess

Backgammon

Taxi

StarCraft

Real Life

Page 29: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire No Yes Yes Yes Yes Yes

Chess

Backgammon

Taxi

StarCraft

Real Life

Page 30: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire No Yes Yes Yes Yes Yes

Chess Yes Yes Yes Yes Yes No

Backgammon

Taxi

StarCraft

Real Life

Page 31: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire No Yes Yes Yes Yes Yes

Chess Yes Yes Yes Yes Yes No

Backgammon Yes No Yes Yes Yes No

Taxi

StarCraft

Real Life

Page 32: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire No Yes Yes Yes Yes Yes

Chess Yes Yes Yes Yes Yes No

Backgammon Yes No Yes Yes Yes No

Taxi No No Yes No No No

StarCraft

Real Life

Page 33: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Environment Types Observable Deterministic Sequential Static Discrete Single-Agent

Solitaire No Yes Yes Yes Yes Yes

Chess Yes Yes Yes Yes Yes No

Backgammon Yes No Yes Yes Yes No

Taxi No No Yes No No No

StarCraft No Almost Yes No Yes No

Real Life No No (?) Yes No No (?) No

Page 34: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Outline • What is an Agent? • Rationality • Agents and Environments • Agent Types

(these slides are adapted from Russel & Norvig’s official slides)

Page 35: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Agent Types • We will cover 4 basic types:

•  Reactive agents (reflex agents) •  State-based agents •  Goal-based agents •  Utility-based agents

•  They can all incorporate learning

Page 36: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Reactive Agents Simple reflex agents

AgentEnvironm

entSensors

What the worldis like now

What action Ishould do nowCondition−action rules

Actuators

Chapter 2 20

Page 37: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

State-based Agents Reflex agents with state

Agent

Environment

Sensors

What action Ishould do now

State

How the world evolves

What my actions do

Condition−action rules

Actuators

What the worldis like now

Chapter 2 22

Page 38: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Goal-based Agents Goal-based agents

Agent

Environment

Sensors

What it will be like if I do action A

What action Ishould do now

State

How the world evolves

What my actions do

Goals

Actuators

What the worldis like now

Chapter 2 24

Page 39: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Utility-based Agents Utility-based agents

Agent

Environment

Sensors

What it will be like if I do action A

How happy I will be in such a state

What action Ishould do now

State

How the world evolves

What my actions do

Utility

Actuators

What the worldis like now

Chapter 2 25

Page 40: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Learning Agents Learning agentsPerformance standard

Agent

Environment

Sensors

Performance element

changes

knowledgelearning goals

Problem generator

feedback

Learning element

Critic

Actuators

Chapter 2 26

Page 41: CS 380: ARTIFICIAL INTELLIGENCE RATIONAL AGENTSsanti/teaching/2013/CS380/...Solitaire Chess Backgammon Taxi StarCraft Real Life Environment Types Observable Deterministic Sequential

Summary • Agents:

•  Interact with environments via actuators (actions) and sensors (percepts)

• Rational agent: maximizes expected performance

• PEAS

• Environment types

• Basic agent architectures