1 / 15

CPSC 335

CPSC 335. Search Strategies. Search strategies. Tries – for word searchers, spell checking, spelling corrections Digital Search Trees – for searching for frequent keys (in text, databases, applications) Min-max search – for optimal move search in games

tracy
Download Presentation

CPSC 335

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CPSC 335 Search Strategies

  2. Search strategies • Tries – for word searchers, spell checking, spelling corrections • Digital Search Trees – for searching for frequent keys (in text, databases, applications) • Min-max search – for optimal move search in games • Alpha-beta pruning – improvement of min-max search • Branch-and-bound – algorithmic technique to limit the search

  3. Min-Max search • In chess, both players know where the pieces are, they alternate moves, and they are free to make any legal move.  The object of the game is to checkmate the other player, to avoid being checkmated, or to achieve a draw if that's the best thing given the circumstances. • A chess program selects moves via use of a search function.  A search function is a function that is passed information about the game, and tries to find the best move for side that the program is playing.

  4. Min-Max search • Min-max search is used on a B-tree like structure representing the space of all possible moves. Initial state of every game is a large B-tree, then a tree-search finds the move that would be selected if both sides were to play the best possible moves. 

  5. The algorithm • Let's say that at the root position (the position on the board now), it's White's turn to move.  The Max function is called, and all of White's legal moves are generated.  In each resulting position, the "Min" function is called.  The "Min" function scores the position and returns a value.  Since it is White to move, and White wants a more positive score if possible, the move with the largest score is selected as best, and the value of this move is returned. • The "Min" function works in reverse.  The "Min" function is called when it's Black's turn to move, and black wants a more negative score, so the move with the most negative score is selected. • These functions are dual recursive, meaning that they call each other until the desired search depth is reached.  When the functions "bottom out", they return the result of the "Evaluate" function.

  6. Alpha-beta pruning • Alpha - Beta Pruning • a technique that improves upon the minimax algorithm by ignoring branches on the game tree that do not contribute further to the outcome.

  7. Idea • The basic idea behind this modification to the minimax search algorithm is the following. During the process of searching for the next move, not every move (i.e. every node in the search tree) needs to considered in order to reach a correct decision. • In other words, if the move being considered results in a worse outcome than our current best possible choice, then the first move that the opposition could make which is less then our best move will be the last move that we need to look at.

  8. Example

  9. Pseudo-code • function Max-Value(state, game, œ, ß) returns the mimimax value of state • inputs: • state, current state in the gamegame, game descriptionœ, the best score for MAX along the path to stateß, the best score for MIN along the path to state • if CUTOFF-TEST(state) then return EVAL(state)for eachsin SUCCESSORS(state) do • œ <-- MAX(œ,MIN-VALUE(s,game,œ,ß)) if œ >= ß then return ß • endreturn œ • function Min-Value(state, game, œ, ß) returns the mimimax value of state • if CUTOFF-TEST(state) then return EVAL(state)for eachsin SUCCESSORS(state) do • ß <-- MIN(ß,MAX-VALUE(s,game,œ,ß)) if ß <= œ then return œ • endreturn ß

  10. Algorithm performance • With the previously listed assumptions taken into account the following gains\improvements can be calculated. • With Alpha-Beta Pruning the number of nodes on average that need to be examined is O(bd/2) as opposed to the Minimax algorithm which must examine 0(bd) nodes to find the best move. In the worst case Alpha-Beta will have to examine all nodes just as the original Minimax algorithm does. But assuming a best case result this means that the effective branching factor is b(1/2) instead of b. • For a chess game, which normally has a branching factor of 35, the branching factorwill be reduced to 6! It means that a chess program running Alpha - Beta could look ahead twice as far in the same amount of time, improving the skill level of our chess program from a novice to an expert level player.

  11. Branch-and-bound • Definition: An algorithmic technique to find the optimal solution by keeping the best solution found so far. If a partial solution cannot improve on the best, it is abandoned.

  12. Branch-and-bound • For instance, suppose we want to find the shortest route from Zarahemla to Manti, and at some time the shortest route found until that time is 387 kilometers. Suppose we are to next consider routes through Cumeni. If the shortest distance from Zarahemla to Cumeni is 350 km and Cumeni is 46 km from Manti in a straight line, there is no reason to explore possible roads from Cumeni: they will be at least 396 km (350 + 46), which is worse than the shortest known route. So we need not explore paths from Cumeni.

  13. Branch-and-bound • The method can be implemented as a backtracking algorithm, which is a modified depth-first search, or using a priority queue ordering partial solutions by lower bounds.

  14. Applications • Chess • Checkers • Tic-tac-toe • Other games

  15. Evolution …

More Related