Docsity

Making Decisions - Artificial Intelligence Programming | CS 662, Exams of Computer Science

Toggle sidebar
bg1
Artificial Intelligence
Programming
Decision Making under Uncertainty
Chris Brooks
Department of Computer Science
University of San Francisco
Making decisions
At this point, we know how to describe the probability of
events occuring.
Or states being reached, in agent terms.
Knowing the probabilities of events is only part of the
battle.
Agents are really interested in maximizing performance.
Often, performance can be captured by utility.
Utility indicates the relative value of a state.
Departmentof Computer Science — University of San Francisco – p.1/??
Types of decision-making problems
Single-agent, deterministic, full information, episodic
We’ve done this with the reflex agent
Single-agent, deterministic, full information, sequential
We can use search here.
Single-agent, stochastic, partial information, episodic
Single-agent, stochastic, partial information, sequential
multiple-agent, deterministic, full information, episodic
Departmentof Computer Science — University of San Francisco
Types of decision-making problems
Single-agent, deterministic, full information, episodic
We’ve done this with the reflex agent
Single-agent, deterministic, full information, sequential
We can use search here.
Single-agent, stochastic, partial information, episodic
We can use utility and probability here
Single-agent, stochastic, partial information, sequential
We can extend our knowledge of probability and
utility to a Markov decision process.
multiple-agent, deterministic, full information, episodic
(or sequential)
This is game theory
Departmentof Computer Science — University of San Francisco – p.3/??
Expected Utility
In episodic, stochastic worlds, we can use expected
utility to select actions.
An agent will know that an action can lead to one of a
set Sof states.
The agent has a utility for each of these states.
The agent also has a probability that these states will be
reached.
The expected utility of an action is:
Ps∈SP(s)U(s)
The principle of maximum expected utility says that an
agent should choose the action that maximizes
expected utility.
Departmentof Computer Science — University of San Francisco – p.4/??
Example
Let’s say there are two levers.
Lever 1 costs $1 to pull. With p= 0.4, you win $2.
With p= 0.6you win nothing.
Lever 2 costs $2 to pull. With p= 0.1you win $10.
with p= 0.9you lose $1 (on top of the charge to pull).
Should you a) pull lever 1 b) pull lever2 c) pull neither?
Departmentof Computer Science — University of San Francisco
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Making Decisions - Artificial Intelligence Programming | CS 662 and more Exams Computer Science in PDF only on Docsity!

Artificial IntelligenceProgramming Decision Making under Uncertainty

Chris BrooksDepartment of Computer ScienceUniversity of San Francisco

Making decisions At this point, we know how to describe the probability ofevents occuring.^ Or states being reached, in agent terms. Knowing the probabilities of events is only part of thebattle. Agents are really interested in maximizing performance. Often, performance can be captured by

utility.

Utility indicates the relative value of a state.

Department of Computer Science — University of San Francisco – p.1/

??

Types of decision-making problem Single-agent, deterministic, full information, episodic^ We’ve done this with the reflex agent Single-agent, deterministic, full information, sequential^ We can use search here. Single-agent, stochastic, partial information, episodic Single-agent, stochastic, partial information, sequential multiple-agent, deterministic, full information, episodic

Department of Computer Science — University of San Fra

Types of decision-making problems Single-agent, deterministic, full information, episodic^ We’ve done this with the reflex agent Single-agent, deterministic, full information, sequential^ We can use search here. Single-agent, stochastic, partial information, episodic^ We can use utility and probability here Single-agent, stochastic, partial information, sequential^ We can extend our knowledge of probability andutility to a Markov decision process. multiple-agent, deterministic, full information, episodic(or sequential)^ This is game theory

Department of Computer Science — University of San Francisco – p.3/

??

Expected Utility In episodic, stochastic worlds, we can use expectedutility to select actions. An agent will know that an action can lead to one of aset^ S^ of states. The agent has a utility for each of these states. The agent also has a probability that these states will bereached. The^ expected utility

of an action is: ∑P^ (s)U^ s∈S^ (s) The principle of maximum expected utility says that anagent should choose the action that maximizesexpected utility.

Department of Computer Science — University of San Francisco – p.4/

??

Example Let’s say there are two levers.^ Lever 1 costs $1 to pull. With

p^ = 0.^4 , you win $2. With^ p^ = 0.^6

you win nothing. Lever 2 costs $2 to pull. With

p^ = 0.^1 you win $10. with^ p^ = 0.^9 you lose $1 (on top of the charge to pull). Should you a) pull lever 1 b) pull lever 2 c) pull neither?

Department of Computer Science — University of San Fra

Example EU(lever 1) = 0.4 * 1 + 0.6 * -1 = -0.2 EU(lever 2) = 0.1 * 8 + 0.9 * -3 = 5.3 EU(neither) = 0 Lever 2 gives the maximum EU. TV digression - this is the choice contestants are facedwith on “Deal or No Deal.” The banker offers them aprice slightly above the expected utility, and yet mostcontestants don’t take it. Why?

Department of Computer Science — University of San Francisco – p.6/

??

Example: Vegas The typical roulette wheel has 38 numbers. (1-36, plus 0and 00). 1-36 are either red or black. The payoff for betting on a single number is 35:1^ In other words, if the number you picked comes up,you win $35. Otherwise, you lose $1. What is the expected utility of betting on a singlenumber?

Department of Computer Science — University of San Francisco – p.7/

??

Example: Vegas The typical roulette wheel has 38 numbers. (1-36, plus 0and 00). 1-36 are either red or black. The payoff for betting on a single number is 35:1^ In other words, if the number you picked comes up,you win $35. Otherwise, you lose $1. What is the expected utility of betting on a singlenumber? 137 ∗^ 35 +^ ∗ − 38 38

1 =^ −^0.^052

Department of Computer Science — University of San Fra

Example: Vegas The typical roulette wheel has 38 numbers. (1-36, plus 0and 00). 1-36 are either red or black. The payoff for betting on a single number is 35:1^ In other words, if the number you picked comes up,you win $35. Otherwise, you lose $1. What if you decide to “spread the risk” and bet on twonumbers?

Department of Computer Science — University of San Francisco – p.9/

??

Example: Vegas The typical roulette wheel has 38 numbers. (1-36, plus 0and 00). 1-36 are either red or black. The payoff for betting on a single number is 35:1^ In other words, if the number you picked comes up,you win $35. Otherwise, you lose $1. What if you decide to “spread the risk” and bet on twonumbers? 236 ∗^ 34 +^ ∗ − 38 38

2 =^ −^0.^105

Department of Computer Science — University of San Francisco – p.10/

??

Example: Vegas The typical roulette wheel has 38 numbers. (1-36, plus 0and 00). 1-36 are either red or black. The payoff for betting on color is 1:1^ In other words, if you bet ’red’ and a red numbercomes up, you win $1. Otherwise, you lose $1. What is the expected utility of betting on ’red’?

Department of Computer Science — University of San Fran

Example Suppose the agent can perform a survey on a block thatwill indicate whether that block contains oil. How much should the agent pay to perform that survey? P^ (oil) = 1/n.

P^ (¬oil) = (n

−^ 1)/n If oil found, buy for

C/n. Profit =

C^ −^ C/n^ = (

n^ −^ 1)C/n

If oil not found, buy a different block. Probability of picking the oil block is now:

1 /(n^ −^ 1)

Expected Profit:

C/(n^ −^ 1)^ −

C/n^ =^ C/(n ∗^ (n^ −^ 1)).

So, the expected profit, given the information is:^ (n−1)C^1 n−+^ n^ n^

1 CC=^ n n(n−1)^ n So the company is willing to pay up to

C/n^ (the value of

the plot) for the test. This is the

value of that information

Department of Computer Science — University of San Francisco – p.18/

??

Value of Perfect Information Let’s formalize this. We find the best action

α^ in general with: EU^ (α) =^ max

∑a∈actions^ i∈ U^ (i)Poutcomes (i|a)

Let’s say we acquire some new information

E.

Then we find the best action with: EU^ (α|E) =^ max

∑a∈actions^ i∈outcomes U^ (i)P^ (i|a, E

The value of

E^ is the difference between these two.

Department of Computer Science — University of San Francisco – p.19/

??

Value of Perfect Information However, before we do the test, we don’t know what

E

will be. We must average over all possible values of

E.

∑ V P I(E) = (

P^ (E j∈valuesE =^ j)EU^ (α|E

=^ j))^ −^ EU^ (

α)

In words, consider the possibility of each observation,along with the usefulness of that observation, tocompute the expected information gain from this test. In general, information will be valuable to the extent thatit changes the agent’s decision.

Department of Computer Science — University of San Fran

Example Imagine that you are on a game show and are given achoice of three possible doors to open. If you open door number 1, you will win $10. If you open door number 2, you have a 50% change ofwinning nothing, and a 50% chance of winning $25. If you open door number 3, you have a 20% of winning$20, and an 80% chance of winning $10. Which door should you choose?

Department of Computer Science — University of San Francisco – p.21/

??

Example EU(door1) = 10 EU(door2) = 0.5 * 0 + 0.5 * 25 = 12.5 EU(door3) = 0.2 * 20 + 0.8 + 10 = 12 Door 2 is best.

Department of Computer Science — University of San Francisco – p.22/

??

Example Now, suppose that the host offers to tell you honestlywhat you’ll get if you open door number 2. How muchwould you pay for this information? Note: you can change your mind about which door toopen after the host gives you this information.

Department of Computer Science — University of San Fran

Example There are two cases: either door 2 pays 0 or it pays 25. If it pays 25, we should choose it. This happens 50% ofthe time. If it pays 0, we should choose door3, which pays 12.This happens 50% of the time. So, our utility will be: 0.5 * 25 + 0.5 * 12 = 18.5 Our EU before we asked was 12.5, so the information isworth 6.

Department of Computer Science — University of San Francisco – p.24/

??

Dealing with multiple agents Value of information shows how an agent can rationally‘look ahead’ in a partially observable world. Looking ahead is also valuable in multi-agentenvironments.^ Anticipate your opponent’s moves, or his reaction toyour moves, or his reaction to your reaction to hisreaction ...

Department of Computer Science — University of San Francisco – p.25/

??

Multi-agent Environments Competitive environments^ Chess, checkers, go, ...^ Auctions, online markets Cooperative Environments^ Agents on a soccer team^ Rovers surveying Mars And in-between cases^ Two agents making deliveries

Department of Computer Science — University of San Fran

Game Theory Game Theory

is the branch of mathematics/economics that deals with interactions between multiple agents. Prescribes methods for determining optimal behavior. Distinctions:^ Games of perfect information: Agents have access toall knowledge about the world.^ We’d call this a fully observable environment.^ Board games without randomness,paper-scissors-rock^ Games of imperfect information: An agent mustmake inferences about the world or its opponent.^ We call this a partially observable environment.^ Games of chance, some auctions, most real-worldinteractions

Department of Computer Science — University of San Francisco – p.27/

??

Game Theory Game theory assumes:^ Perfect rationality - agents will always do the rightthing.^ Unlimited computation - agents are always able todetermine the right thing to do. As we’ve seen, these assumptions may not make sensein some cases. However, we’ll still use some ideas from game theory tohelp decide what to do. So how does an agent determine what do do in amultiagent environment?

Department of Computer Science — University of San Francisco – p.28/

??

Optimal Strategies We’ll start with the simplest sort of game.^ Two players^ Perfect information^ Zero-sum (one wins, one loses) - this is also called^ perfectly competitive We can define this game as a search problem.

Department of Computer Science — University of San Fran

Dealing with multiple stages To deal with games where many actions are taken,begin at the leaves and compute their payoff. The minimax value of a node is the payoff (from thatplayer’s perspective) assuming both players playoptimally from that point on. Computed recursively. Begin with terminal nodes.- are known. Minimax-value (node) =^ max(children) if it’s the max player’s turn^ min(children) if it’s the min player’s turn.

Department of Computer Science — University of San Francisco – p.36/

??

Example MAX

A B^

C^

D 3 12 8

2 4 6

14 5 2 3

2

2 (^3) a^ a 1 3 a^2 b^ b^13^ b^2

c^ c^13^ c^2

d^ d^13^ d^2

MIN^ Terminal utilities are given.^ Recurse up to the ’Min’ layer (or

ply ) Min player will choose actions

b,^ c,^ d.^113 Recurse again to ’Max’ layer.^ Max player will choose action

a.^1 Department of Computer Science — University of San Francisco – p.37/

??

Minimax search Perform a depth-first traversal of the search tree. Once the values for a node’s children have beencomputed, the value for that node can then becomputed. Retain only the best action sequence so far. This will find the optimal strategy Problem:^ Totally impractical for large games. Serves as a basis fore more practical approaches.

Department of Computer Science — University of San Fran

Alpha-beta pruning Recall that^ pruning

is the elimination of branches in the search tree without expansion.^ You can rule out the possibility that the solution isdown one branch. Consider the previous example again, remembering thatnon-terminal node values are generated via depth-firstsearch.

Department of Computer Science — University of San Francisco – p.39/

??

Alpha-beta pruning MAX A B^ C^

D 3 12 8 2 4 6 (^3) a^ a 1 3 a^23 2 2 b 1 b 3 c 1^ c^3 d^1^ d^3 b 2 c^2^ d^2 14 5 MIN

After traversing the left branch, we know thatnode B has a value of 3^ The Min player will pick 3 over 12 and 8^ More generally, the min player will pick thelowest value. As soon as we find a 2 down the center Branch,we can prune the other children.^ Since Min would pick the smallest valuedown this branch, C can have a value of

at most^ 2. Node B already has a value of 3, so Maxwould prefer this. Still must traverse the third branch.^ Department of Computer Science — University of San Francisco – p.40/

??

Alpha-beta pruning Intuition behind alpha-beta: Consider a node n - if the player considering n can makea better move at n

or one of its parents

, then n will never

be reached. Call Alpha the best (max) value at a choice point Call beta the lowest (min) value at a choice point.

Department of Computer Science — University of San Fran

Alpha-beta pruning Alpha-beta is very sensitive to the order in which nodesare enqueued. What if nodes B and C were swapped in our previousexample? Heuristics can be used to reorder the tree and searchpromising branches first. Problem: Alpha-beta still needs to descend to a terminalnode before states can be evaluated.

Department of Computer Science — University of San Francisco – p.42/

??

Evaluation Functions For large problems (like chess) you need to be able toestimate the value of non-terminal states. Construct a heuristic known as an

evaluation function that estimates the terminal utility of that state. How to build such a function?^ Should order states according to the utility of theirterminals.^ Should be fast.^ Should be strongly correlated with actual chances ofwinning.

Department of Computer Science — University of San Francisco – p.43/

??

Evaluation Functions Evaluation functions introduce uncertainty. You’d like to have your function “guess correctly” most ofthe time. Place states in categories or classes; states in acategory win X% of the time.^ This is a^ classification

problem. Alternatively, construct a domain-specific value for astate.^ In chess, give pieces point values, assign weights tosquares controlled.^ How to get these numbers?^ Ask an expert^ Run minimax offline on different boardconfigurations.

Department of Computer Science — University of San Fran

Cutting off search Evaluating non-terminal nodes is fine, but we still needto anticipate future moves. When can we cut off search and have a good idea of abranch’s value? Approach 1: Use a fixed depth of lookahead. Approach 2: Use iterative deepening until our time tomake a decision runs out. Both of these approaches are vulnerable to the

horizon

problem^ Things look good at this state, but will go horriblywrong next turn.

Department of Computer Science — University of San Francisco – p.45/

??

Quiescence We want to apply our evaluation function only to searchpaths that are

quiescent Aren’t changing wildly. Don’t stop in the middle of a sequence of captures,for example. If our estimate of the state is changing drastically as weexpand, we need to search further down that branch toget an accurate estimate. We still may not avoid the horizon problem There may be a move that is ultimately unavoidable, butcan be prolonged indefinitely.^ Search must be able to distinguish between delayingand avoiding an outcome.

Department of Computer Science — University of San Francisco – p.46/

??

Performance improvements May choose to focus search more deeply down movesthat are clearly better than other. Can also store visited states^ Avoid repeated paths to the same state^ Avoid symmetric states High-performance game-playing systems will typicallyhave a large dictionary of pre-computed endgames. Once a game reaches this state, optimal moves areread from a hashtable.

Department of Computer Science — University of San Fran

AI and games Minimax and gametree search is great for solvingsequential-move games. This works well for chess, checkers, etc, but is not veryrelevant to Halo. What are the AI problems for modern gaming?

Department of Computer Science — University of San Francisco – p.54/

??

AI and games Until recently, “AI” behavior in games was typically prettyprimitive.^ Emphasis was on graphical rendering^ Very few cycles left for AI.^ Assumption was that “suspension of disbelief” wouldbe enough. NPC behavior typically governed by simple rules or finitestate machines. Now, graphics cards are powerful enough to provide anopportunity to incorporate AI into the game itself.

Department of Computer Science — University of San Francisco – p.55/

??

AI needs in gaming Modern gaming could use:^ Adaptive behavior^ Rich, human-like interaction (NPCs with their ownmotivations/goals)^ A “middle ground” between scripted stories andcompletely open-ended worlds.^ Intelligent group/unit behavior.^ Better AI opponents.

Department of Computer Science — University of San Fran

Promising games for adding AI Quake II/Half-life - allows you to write a DLL thatgoverns agent behavior Descent 3 - also allows a DLL Age of Kings - allows you to edit opponent’s strategicrules Civilization IV - has a Python SDK for editing unit and AIbehaviors

Department of Computer Science — University of San Francisco – p.57/

??