For Thursday No reading Homework: Chapter 3, exercise 23 Do this - - PowerPoint PPT Presentation

for thursday
SMART_READER_LITE
LIVE PREVIEW

For Thursday No reading Homework: Chapter 3, exercise 23 Do this - - PowerPoint PPT Presentation

For Thursday No reading Homework: Chapter 3, exercise 23 Do this twice, once with A* search (as specified) and once with greedy best first search Program 1 Any questions? Discussion Assignment Admissible Heuristic An


slide-1
SLIDE 1

For Thursday

  • No reading
  • Homework:

– Chapter 3, exercise 23 – Do this twice, once with A* search (as specified) and once with greedy best first search

slide-2
SLIDE 2

Program 1

  • Any questions?
slide-3
SLIDE 3

Discussion Assignment

slide-4
SLIDE 4

Admissible Heuristic

  • An admissible heuristic is one that never
  • verestimates the cost to reach the goal.
  • It is always less than or equal to the actual

cost.

  • If we have such a heuristic, we can prove

that best first search using f(n) is both complete and optimal.

  • A* Search
slide-5
SLIDE 5

Focus on Total Path Cost

  • Uniform cost search uses g(n) --the path

cost so far

  • Greedy search uses h(n) --the estimated

path cost to the goal

  • What we’d like to use instead is

f(n) = g(n) + h(n) to estimate the total path cost

slide-6
SLIDE 6

Heuristics Don’t Solve It All

  • NP-complete problems still have a worst-

case exponential time complexity

  • Good heuristic function can:

– Find a solution for an average problem efficiently – Find a reasonably good (but not optimal) solution efficiently

slide-7
SLIDE 7

8-Puzzle Heuristic Functions

  • Number of tiles out of place
  • Manhattan Distance
  • Which is better?
  • Effective branching factor
slide-8
SLIDE 8

Inventing Heuristics

  • Relax the problem
  • Cost of solving a subproblem
  • Learn weights for features of the problem
slide-9
SLIDE 9

Local Search

  • Works from the “current state”
  • No focus on path
  • Also useful for optimization problems
slide-10
SLIDE 10

Local Search

  • Advantages?
  • Disadvantages?
slide-11
SLIDE 11

Hill-Climbing

  • Also called gradient descent
  • Greedy local search
  • Move from current state to a state with a

better overall value

  • Issues:

– Local maxima – Ridges – Plateaux

slide-12
SLIDE 12

Variations on Hill Climbing

  • Stochastic hill climbing
  • First-choice hill climbing
  • Random-restart hill climbing
slide-13
SLIDE 13

Evaluation of Hill Climbing

slide-14
SLIDE 14

Simulated Annealing

  • Similar to hill climbing, but--

– We select a random successor – If that successor improves things, we take it – If not, we may take it, based on a probability – Probability gradually goes down

slide-15
SLIDE 15

Local Beam Search

  • Variant of hill-climbing where multiple

states and successors are maintained

slide-16
SLIDE 16

Genetic Algorithms

  • Have a population of k states (or individuals)
  • Have a fitness function that evaluates the

states

  • Create new individuals by randomly selecting

pairs and mating them using a randomly selected crossover point.

  • More fit individuals are selected with higher

probability.

  • Apply random mutation.
  • Keep top k individuals for next generation.
slide-17
SLIDE 17

Game Playing in AI

  • Long history
  • Games are well-defined problems usually

considered to require intelligence to play well

  • Introduces uncertainty (can’t know
  • pponent’s moves in advance)
slide-18
SLIDE 18

Games and Search

  • Search spaces can be very large:
  • Chess

– Branching factor: 35 – Depth: 50 moves per player – Search tree: 35100 nodes (~1040 legal positions)

  • Humans don’t seem to do much explicit

search

  • Good test domain for search methods and

pruning methods

slide-19
SLIDE 19

Game Playing Problem

  • Instance of general search problem
  • States where game has ended are terminal states
  • A utility function (or payoff function)

determines the value of the terminal states

  • In 2 player games, MAX tries to maximize the

payoff and MIN is tries to minimize the payoff

  • In the search tree, the first layer is a move by

MAX and the next a move by MIN, etc.

  • Each layer is called a ply
slide-20
SLIDE 20

Minimax Algorithm

  • Method for determining the optimal move
  • Generate the entire search tree
  • Compute the utility of each node moving

upward in the tree as follows:

– At each MAX node, pick the move with maximum utility – At each MIN node, pick the move with minimum utility (assume opponent plays

  • ptimally)

– At the root, the optimal move is determined

slide-21
SLIDE 21

Recursive Minimax Algorithm

function Minimax-Decision(game) returns an operator for each op in Operators[game] do Value[op] <- Mimimax-Value(Apply(op, game),game) end return the op with the highest Value[op] function Minimax-Value(state,game) returns a utility value if Terminal-Test[game](state) then return Utility[game](state) else if MAX is to move in state then return highest Minimax-Value of Successors(state) else return lowest Minimax-Value of Successors(state)

slide-22
SLIDE 22

Making Imperfect Decisions

  • Generating the complete game tree is

intractable for most games

  • Alternative:

– Cut off search – Apply some heuristic evaluation function to determine the quality of the nodes at the cutoff

slide-23
SLIDE 23

Evaluation Functions

  • Evaluation function needs to

– Agree with the utility function on terminal states – Be quick to evaluate – Accurately reflect chances of winning

  • Example: material value of chess pieces
  • Evaluation functions are usually weighted

linear functions

slide-24
SLIDE 24

Cutting Off Search

  • Search to uniform depth
  • Use iterative deepening to search as deep as

time allows (anytime algorithm)

  • Issues

– quiescence needed – horizon problem

slide-25
SLIDE 25

Alpha-Beta Pruning

  • Concept: Avoid looking at subtrees that

won’t affect the outcome

  • Once a subtree is known to be worse than

the current best option, don’t consider it further

slide-26
SLIDE 26

General Principle

  • If a node has value n, but the player

considering moving to that node has a better choice either at the node’s parent or at some higher node in the tree, that node will never be chosen.

  • Keep track of MAX’s best choice () and

MIN’s best choice () and prune any subtree as soon as it is known to be worse than the current  or  value

slide-27
SLIDE 27

function Max-Value (state, game, , ) returns the minimax value of state if Cutoff-Test(state) then return Eval(state) for each s in Successors(state) do  <- Max(, Min-Value(s , game, , )) if  >=  then return  end return  function Min-Value(state, game, , ) returns the minimax value of state if Cutoff-Test(state) then return Eval(state) for each s in Successors(state) do  <- Min(,Max-Value(s , game, , )) if  <=  then return  end return 

slide-28
SLIDE 28

Effectiveness

  • Depends on the order in which siblings are

considered

  • Optimal ordering would reduce nodes

considered from O(bd) to O(bd/2)--but that requires perfect knowledge

  • Simple ordering heuristics can help quite a

bit