Download presentation
Presentation is loading. Please wait.
Published bySharyl Riley Modified over 8 years ago
1
CIS 350 – I Game Programming Instructor: Rolf Lakaemper
2
Classic AI: Search Trees
3
Overview Search Trees are the underlying techniques of round based games with a (very) limited number of moves per round, e.g. BOARDGAMES
4
Overview A search tree contains a certain game state (position) in a single node, the children contain the possible moves of the single active player. Let’s name player 1 ‘MAX’, player 2 ‘MIN’.
5
Search Trees MAX MIN MAX Min’s move Max’s move
6
Search Trees MAX MIN MAX Min’s move Max’s move The basic idea: compute (all) possible moves and evaluate the result (the leaves)
7
Search Trees 5732 MAX MIN MAX Min’s move Max’s move Now fill the tree bottom up, using the max. or min. values of the child nodes
8
Search Trees 52 5732 MAX MIN MAX Min’s move Max’s move Now fill the tree bottom up, using the max. or min. values of the child nodes A high value is good for MAX, so MIN would choose the min.-move !
9
Search Trees 5 52 5732 MAX MIN MAX Min’s move Max’s move Now fill the tree bottom up, using the max. or min. values of the child nodes A high value is good for MAX, so MAX would choose the max.-move !
10
Search Trees Problem: Lots of nodes to evaluate. Example: CHESS has an average branching factor of 35, so …
11
Search Trees Optimizing Tree Search Idea 1:Limit Depth The easiest idea, the worst playing skills.
12
Search Trees Optimizing Tree Search Idea 2:alpha-beta pruning A safe idea and a pure win !
13
Alpha beta pruning 5 573 MAX MIN MAX Min’s move Max’s move What happens at this point ?
14
Alpha beta pruning 5 573 MAX MIN MAX Min’s move Max’s move Since 3<5 and evaluation of the next nodes would only lead to values < 3, 3’s parent node would NEVER be chosen by MAX
15
Alpha beta pruning 5 573 MAX MIN MAX Min’s move Max’s move We can stop searching for this branch !
16
Alpha beta pruning Alpha values: the best values achievable for MAX, hence the max. value so far Beta values: the best values achievable for MIN, hence the min. value so far At MIN level: compare result V of node to alpha value. If V>alpha, pass value to parent node and BREAK At MAX level: compare result V of node to beta value. If V<beta, pass value to parent node and BREAK
17
Alpha beta pruning Alpha Beta pruning is a pure win, but it’s highly depending on the move ordering !
18
Improvements Further Improvements: Quiescent search ‘Don’t leave a mess strategy’ For evaluating the leaves at depth 0, instead of the evaluation function a special function is called that evaluates special moves (e.g. captures) only down to infinit depth Guarantees e.g. that the Queen will not be captured at move in depth 0
19
Improvements Iterative deepening: First try depth n=1 If time left, try depth n+1 Order moves of depth n when trying depth n+1 ! Since alpha beta is order sensitive, this can speed up the process Fills time and doesn’t need predefined depth parameter Drawback: creates same positions over and over, but…
20
Improvements Example for multiply generated moves: Assumption: worst case: no alpha bet pruning. Branching factor 10 IterationStepsTotal 11010 210+100110 310+100+10001110 410+100+1000+1000011110 510+…+100000111110 ======= 111110 position 123,450 positions 123,450 / 111,110 = 1.11 => only 11% additional pos. (worst case)
21
Improvements Improvement: Aspiration Windows Extension of iterative deepening Basic Idea: feed alpha beta values of previous search into current search Assumption: new values won’t differ too much Extend alpha beta by +/- window value
22
Improvements Improvement: Null Move Forward Pruning Idea: if the fighter can’t knock down the opponent with a free shot, the position should be pretty good ! Don’t evaluate player’s move, but opponent’s move again (free shot) If value is still good enough, don’t continue search Do this on a lower level than defined (D-2)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.