A Comparative Study of Game Tree Searching Methods

A Comparative Study of Game Tree Searching Methods

(IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 5, No. 5, 2014 A Comparative Study of Game Tree Searching Methods Ahmed A. Elnaggar Mostafa Abdel Aziem Computer Science Department College of Computing and IT Modern Academy in Maadi AAST Cairo, Egypt Cairo, Egypt Mahmoud Gadallah Hesham El-Deeb Computer Science Department Computer Science Faculty Modern Academy in Maadi MTI University Cairo, Egypt Cairo, Egypt Abstract—In this paper, a comprehensive survey on gaming algorithm was stopped before any player won, lose or the game tree searching methods that can use to find the best move in two ended with a draw. The developers usually do that because in players zero-sum computer games was introduced. The purpose more complex games, there is no practical algorithm that can of this paper is to discuss, compares and analyzes various search in the entire tree in a reasonable amount of time even if sequential and parallel algorithms of gaming tree, including some it uses the power of parallel processing. An example for this is enhancement for them. Furthermore, a number of open research the checkers and chess game where they need to evaluate about areas and suggestions of future work in this field are mentioned. 1020 and 1040 nodes respectively. WD is used as an estimation of the number of nodes needs to be visited, where W represents Keywords—game tree search; searching; evaluation; parallel; the average number of legal moves for each node, and D distributed; GPU represents the game length. Two solutions for this problem are I. INTRODUCTION to use a fixed depth "D" or to use a specific time to stop generating the tree. Game playing; where a human play versus a computer have a long history. In the earlier game playing programs, the There are many categorization methods for sequential game computer couldn't win a human because of the weakness of the tree. However, the most common categorization is based on game tree algorithms for finding the best next-move or the depth-first and breadth-first, which was used in this paper. limitation of computer computation and memory space. The Depth-first search "DFS" [9] means the algorithm will start advances in this field and the field of computer architecture from the root and explores as long as the depth limitation didn't finally allowed computers to win humans in most complex meet along each branch before backtracking. Breadth-first games, including chess. Many algorithms have already been search "BFS" [10] begins from the root and inspects all the invented to find the best next-move for the computer, including children of the root node before it inspects all the children of sequential algorithms such as MiniMax [1], NegaMax [2], each root children's node. The parallel algorithms are hard to Negascout [3], SSS* [4] and B* [5] as well as parallel categorize as depth or breadth first since some parallel algorithms such as Parallel Alpha-Beta algorithm [6]. These algorithms work as follows: each core or each processor Parallel algorithms are now modified to run not only on CPUs, inspects a child of the root using DFS or BFS. In the first case, but also on GPUs [7] to provide a faster solution. the distribution of the root’s children uses a BFS algorithm, but each core or processor uses a DFS. In this case, it is called a Almost all game playing programs use game trees to find hybrid-system. the next-best move. An example of a game tree for Tic-Tac- Toe game [8] is shown in Fig. 1 The figure shows the To make it clear for the reader, the paper was organized as following: follows: Each node represents a game state. Section [II], presents a discussion for sequential game tree algorithms categorized into depth-first & breadth-first The root represents the current game state. algorithms. Section [III], presents a discussion for parallel All the branches for a given node represent all the legal game tree algorithms from the programming point of view and moves for that node. from the hardware point of view. Section, [IV], provides an analysis for depth algorithms and breadth algorithms based on The node that doesn't have any successor called a leaf. algorithm complexity for both time and memory. Section [V], concludes the paper with some future work that can enhance Evaluation function is used to determine whatever a leaf the current algorithms. represents a win, lose, draw or just a score, in case the 68 | P a g e www.ijacsa.thesai.org (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 5, No. 5, 2014 II. SEQUENTIAL GAME TREE ALGORITHMS maximization function rather than using both maximization and As mentioned in the previous section, sequential algorithms minimization functions. This can be done by negating the value were categorized into depth-first search [9] and breadth-first that is returned from the children from the opponent's point of search [10]. Furthermore, the depth-first search algorithms view rather than searching for the minimum score. This is categorized again into brute-force search and selective search possible because of the following mathematical relation: [11]. The brute-force search is looking at every variation to a Max (a, b) == -Min (-a, -b) (1) given depth while the selective search is looking at important branches only. Section [A], presents a discussion for the brute- MinMax (GamePosition game) { force search in depth-first search. Section [B], presents a return MaxMove (game); discussion for the selective search in depth-first search. Section } [C], presents a discussion for the breadth-first search. MaxMove (GamePosition game) { if (GameEnded(game)) { return EvalGameState(game); } else { best_move < - {}; moves <- GenerateMoves(game); ForEach moves { move <- MinMove(ApplyMove(game)); if (Value(move) > Value(best_move)) { best_move < - move; } } return best_move; Fig. 1. Game tree for Tic-Tac-Toe game using MiniMax algorithm. } } A. Brute-Force algorithms in Depth-First Search The most famous algorithms in brute-force search are MinMove (GamePosition game) { MiniMax [1], NegaMax [2], Alpha-Beta [12], NegaScout [3], best_move <- {}; and Principle-Variation [13]. Following is a description of each moves <- GenerateMoves(game); of these algorithms. ForEach moves { move <- MaxMove(ApplyMove(game)); MiniMax [1] algorithm is a game tree algorithm that is if (Value(move) > Value(best_move)) { divided into two logically stages, the first one for the first best_move < - move; player which is the computer and the second one for the second } player which is the human. The algorithm tries to find the best } legal move for the computer even if the human plays the best move for him. Which means, it maximizes the computer score when it chooses the computer move, while minimizing that return best_move; } score by choosing the best legal move for the human when it chooses the human move. Fig. 2. MiniMax Algorithm Pseduo Code In Fig. 1 there is a simulation of MiniMax search for Tic- Tac-Toe game [8]. Every node has a value calculated by the In Fig. 3 there is a pseudo code for NegaMax algorithm. evaluation function. For a given path, the value of the leaf Clearly, (1) was used to simplify the MiniMax algorithm. nodes passed back to its parent. An example for that the value Alpha-Beta [12] algorithm is a smart modification that can of any O's move will always choose the minimum value for the be applied to MiniMax or NegaMax algorithms. Kunth and computer, while the value for any X's move will always choose Moore proved that many branches could be pruned away of the the maximum value for the computer. game tree which reduces the time needed to finish the tree, and In Fig. 2 a pseudo code for the MiniMax algorithm [1] is it will give the same result as MiniMax or NegaMax. The main presented. The program first calls the function MiniMax which idea of the algorithm is cutting the uninteresting branches in the starts the chain of calls for MaxMove and MinMove. Each time game tree. The following examples illustrating the idea: MaxMove function or MinMove function is called it Max (8, Min (5, X)) and Min (3, Max (7, Y)) automatically calls the other function until the game ended, or The result is always 8 in the first example and 3 in the second it reached the desired depth. example, no matter the values of X or Y. This means the algorithm can cut the node X or Y with its branches. The NegaMax [2] algorithm is an identical algorithm for Alpha-Beta algorithm uses two variables (alpha & beta) to MiniMax with only one slight difference. It uses only the detect these cases, so any value less than alpha or larger than 69 | P a g e www.ijacsa.thesai.org (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 5, No. 5, 2014 beta will automatically cutoff without affecting the result of the improve the Alpha-Beta algorithm which discussed search tree. below. The enhanced version of the NegaMax algorithm from Fig. // Search game tree to given depth, and return evaluation of 3 with Alpha-Beta property is shown in Fig. 4. // root node. // Search game tree to given depth, and return evaluation of int AlphaBeta(gamePosition, depth, alpha, beta) // root node. { int NegaMax(gamePosition, depth) if (depth=0 || game is over) { // evaluate leaf gamePositionition from if (depth=0 || game is over) // current player’s standpoint // evaluate leaf gamePositionition from return Eval (gamePosition); // current player’s standpoint // present return value return Eval (gamePosition); score = - INFINITY; // generate successor

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us