Minimax Based Kalaha AI

Similar documents
AI Approaches to Ultimate Tic-Tac-Toe

game tree complete all possible moves

Five-In-Row with Local Evaluation and Beam Search

CSC 380 Final Presentation. Connect 4 David Alligood, Scott Swiger, Jo Van Voorhis

Algorithms for Data Structures: Search for Games. Phillip Smith 27/11/13

Adversary Search. Ref: Chapter 5

SOLVING KALAH ABSTRACT

Game-playing AIs: Games and Adversarial Search FINAL SET (w/ pruning study examples) AIMA

Adversarial Search 1

Learning to Play like an Othello Master CS 229 Project Report. Shir Aharon, Amanda Chang, Kent Koyanagi

2048: An Autonomous Solver

mywbut.com Two agent games : alpha beta pruning

Experiments on Alternatives to Minimax

For slightly more detailed instructions on how to play, visit:

Data Structures and Algorithms

CS188 Spring 2010 Section 3: Game Trees

Homework Assignment #2

Game Engineering CS F-24 Board / Strategy Games

Introduction to Artificial Intelligence CS 151 Programming Assignment 2 Mancala!! Due (in dropbox) Tuesday, September 23, 9:34am

Playing Othello Using Monte Carlo

Game Tree Search. CSC384: Introduction to Artificial Intelligence. Generalizing Search Problem. General Games. What makes something a game?

Lecture 14. Questions? Friday, February 10 CS 430 Artificial Intelligence - Lecture 14 1

ARTIFICIAL INTELLIGENCE (CS 370D)

CS221 Project Final Report Gomoku Game Agent

More Adversarial Search

Foundations of AI. 6. Adversarial Search. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard & Bernhard Nebel

Adversarial Search and Game- Playing C H A P T E R 6 C M P T : S P R I N G H A S S A N K H O S R A V I

Set 4: Game-Playing. ICS 271 Fall 2017 Kalev Kask

Foundations of Artificial Intelligence

CMPUT 396 Tic-Tac-Toe Game

Foundations of AI. 5. Board Games. Search Strategies for Games, Games with Chance, State of the Art. Wolfram Burgard and Luc De Raedt SA-1

Adversarial Reasoning: Sampling-Based Search with the UCT algorithm. Joint work with Raghuram Ramanujan and Ashish Sabharwal

Game-Playing & Adversarial Search

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / September 23, 2013

CS188 Spring 2014 Section 3: Games

Games and Adversarial Search II

Game Playing for a Variant of Mancala Board Game (Pallanguzhi)

CS 221 Othello Project Professor Koller 1. Perversi

CS 771 Artificial Intelligence. Adversarial Search

Computer Science and Software Engineering University of Wisconsin - Platteville. 4. Game Play. CS 3030 Lecture Notes Yan Shi UW-Platteville

Programming an Othello AI Michael An (man4), Evan Liang (liange)

CS 380: ARTIFICIAL INTELLIGENCE MONTE CARLO SEARCH. Santiago Ontañón

CS 229 Final Project: Using Reinforcement Learning to Play Othello

Programming Bao. Jeroen Donkers and Jos Uiterwijk 1. IKAT, Dept. of Computer Science, Universiteit Maastricht, Maastricht, The Netherlands.

Comparison of Monte Carlo Tree Search Methods in the Imperfect Information Card Game Cribbage

CS188 Spring 2010 Section 3: Game Trees

CS 188: Artificial Intelligence Spring Announcements

CS 188: Artificial Intelligence

Playing Games. Henry Z. Lo. June 23, We consider writing AI to play games with the following properties:

Module 3. Problem Solving using Search- (Two agent) Version 2 CSE IIT, Kharagpur

Theory and Practice of Artificial Intelligence

CS151 - Assignment 2 Mancala Due: Tuesday March 5 at the beginning of class

COMP3211 Project. Artificial Intelligence for Tron game. Group 7. Chiu Ka Wa ( ) Chun Wai Wong ( ) Ku Chun Kit ( )

UNIVERSITY of PENNSYLVANIA CIS 391/521: Fundamentals of AI Midterm 1, Spring 2010

16.410/413 Principles of Autonomy and Decision Making

Foundations of Artificial Intelligence

Game Playing AI. Dr. Baldassano Yu s Elite Education

CS885 Reinforcement Learning Lecture 13c: June 13, Adversarial Search [RusNor] Sec

Artificial Intelligence. Minimax and alpha-beta pruning

Foundations of AI. 6. Board Games. Search Strategies for Games, Games with Chance, State of the Art

CS510 \ Lecture Ariel Stolerman

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

MyPawns OppPawns MyKings OppKings MyThreatened OppThreatened MyWins OppWins Draws

Informatica Universiteit van Amsterdam. Performance optimization of Rush Hour board generation. Jelle van Dijk. June 8, Bachelor Informatica

CS 5522: Artificial Intelligence II

Foundations of Artificial Intelligence

Optimal Yahtzee performance in multi-player games

Last-Branch and Speculative Pruning Algorithms for Max"

Generalized Game Trees

CPS331 Lecture: Search in Games last revised 2/16/10

6.034 Quiz 2 20 October 2010

CS 4700: Foundations of Artificial Intelligence

Tetris: A Heuristic Study

CSE 332: Data Structures and Parallelism Games, Minimax, and Alpha-Beta Pruning. Playing Games. X s Turn. O s Turn. X s Turn.

Documentation and Discussion

2 person perfect information

Game-playing AIs: Games and Adversarial Search I AIMA

Universiteit Leiden Opleiding Informatica

Board Game AIs. With a Focus on Othello. Julian Panetta March 3, 2010

Artificial Intelligence

COMP219: COMP219: Artificial Intelligence Artificial Intelligence Dr. Annabel Latham Lecture 12: Game Playing Overview Games and Search

V. Adamchik Data Structures. Game Trees. Lecture 1. Apr. 05, Plan: 1. Introduction. 2. Game of NIM. 3. Minimax

CS 4700: Artificial Intelligence

The game of Reversi was invented around 1880 by two. Englishmen, Lewis Waterman and John W. Mollett. It later became

Game Playing State-of-the-Art

Midterm Examination. CSCI 561: Artificial Intelligence

CMSC 671 Project Report- Google AI Challenge: Planet Wars

Games (adversarial search problems)

Opponent Models and Knowledge Symmetry in Game-Tree Search

Announcements. CS 188: Artificial Intelligence Spring Game Playing State-of-the-Art. Overview. Game Playing. GamesCrafters

Adversarial Search. CS 486/686: Introduction to Artificial Intelligence

CS188: Artificial Intelligence, Fall 2011 Written 2: Games and MDP s

Contents. Foundations of Artificial Intelligence. Problems. Why Board Games?

CSC384: Introduction to Artificial Intelligence. Game Tree Search

Game Playing State-of-the-Art. CS 188: Artificial Intelligence. Behavior from Computation. Video of Demo Mystery Pacman. Adversarial Search

Recently, a winning opening for the game of Dakon was found by hand. This

CS 188: Artificial Intelligence

Introduction to AI Techniques

Undergraduate Research Opportunity Programme in Science. The Game of Kalah

CS440/ECE448 Lecture 9: Minimax Search. Slides by Svetlana Lazebnik 9/2016 Modified by Mark Hasegawa-Johnson 9/2017

Transcription:

2013-06-11 BTH-Blekinge Institute of Technology Thesis handed in as a part of the examination in DV1446 Bachelors thesis in Computer Science. Minimax Based Kalaha AI Marcus Östergren Göransson Abstract To construct an algorithm which does well in a board game, one must take into account the time spent on each move and the ability to evaluate the state of the board. There are multiple ways to handle these issues, but only a few are covered in this analysis. AIs using the algorithms minimax, minimax with alpha-beta pruning and minimax with knowledge-based alpha-beta pruning are being compared when playing Kalaha with a 30 second time limit per move. Each algorithm is in addition paired up with two different methods of evaluating the games state. The first one only compares the amount of counters in each players store, while the second, knowledge-based method, extends this with an evaluation of the counters in play. A tournament was held between the AIs where each match-up played twelve games against each other. The regular minimax algorithm is appearing to be inferior to the improved variations. The knowledge-based alpha-beta pruning is unexpectedly unsuccessful in outperforming the regular alpha-beta pruning and a discussion covers possible errors with the implementation and possible improvements. The knowledge-based evaluation method is appearing to be slightly more successful than the simple variant, but a discussion questions the real usefulness of it when paired with more advanced search algorithms than the ones covered in this study. Marcus Östergren Göransson Åby Ramdala 37302 m.o.g@live.se Supervisor: Johan Hagelbäck ISSN-nummer: 1

Table of contents 1 Introduction 4 1.1 Background 4 1.1.1 Kalaha 4 1.1.2 AIs and Kalaha 5 1.1.2.1 Search algorithms 6 1.1.2.2 Utility functions 6 1.1.2.3 Solving Kalaha 6 1.2 Purpose and goal 7 1.2.1. Simple utility function 7 1.2.2 Knowledge-based utility function 7 1 1.2.3 Minimax 8 1.2.4 Minimax with alpha-beta pruning 9 1.2.5 Minimax with knowledge-based alpha-beta pruning 11 1.3 Research questions 13 1.4 Methodology 13 1.4.1 Kalaha programs 13 1.4.2 Measuring 15 1.4.3 Optimization 15 1.5 Thesis structure 15 2 Execution 16 2

2.1 Overview 16 2.2 Sustaining the validity of the results 17 3 Results 18 4 Discussion 21 4.1 Winning search algorithm 21 4.2 Winning utility function 21 4.3 Improvements 21 5 Conclusions 22 6 Future research 23 7 References 24 3

1 Introduction 1.1 Background 1.1.1 Kalaha Kalaha is a turn-based board game with a board made up of two stores and two rows of six holes, organized in a way that each hole on a players side are connected to each other and both of the stores, as can be seen in Figure 1. Figure 1. The Kalaha board. Each player controls only one store each and the pieces that end up here may not be used for the remainder of the game. Each hole starts filled with a specified number of pieces. The pieces may be referred to as seeds, pebbles, marbles, stones or even counters. These counters filling up each hole can vary in numbers, allowing a game with few counters to be suitable for beginners, or a game with more counters to be suitable for more advanced players. 4

The reason for the different game setups is that there are no official rules, which creates various house rules [1]. The complexity of Kalaha is increased with the amount of counters in play as a game generally takes a lot longer to finish depending on this amount. Three counters in each hole is recommended for a short game and young players, while six makes for a more interesting game[2]. The game starts by a player picking up the counters from a hole on his or her side (one hole out of six that are controlled by that player) and start sowing them in an anti-clockwise fashion. The sowing involves dropping the counters, in the current players hand, one after one in the adjacent holes and the store, always moving on to the following one. When the sowing approaches a store there are a couple of things to keep in mind: - The current player may only place counters in his or her own store, otherwise it must be passed. - If the last counter in the current players hand ends up in his or her store, that player is rewarded with another move. If the last counter does not end up in the current players store, the next turn is for the other player. If the last counter in the current players hand instead ends up in an empty hole on his or her side, this counter and all counters in the opposite hole (the hole on the same place, vertically or horizontally, but on the other players side) are automatically won and put in that players store. If all holes on a players side go empty of counters, the player with counters in his or her holes left wins them all automatically and they are put in that players store. The game is won by a player having more than half of the counters used in the game, in his or her store. A draw occurs if both players possess half of the counters each. 1.1.2 AIs and Kalaha Since a single move can have an effect on the amount of counters in all holes on the board, it may be difficult to predict the consequences of even a few moves ahead[3]. The many situations in Kalaha where counting and remembering game-states (an arbitrary position of the counters in a game) is needed tend to give AIs an opportunity to outperform a human player seeing as counting is a trivial matter for a computer and they have excellent memory. 5

1.1.2.1 Search algorithms Despite these advantages, the performance of an AI might be unreasonably slow when trying to compute the best move possible. To reduce the search time for the best move, the search space must be reduced. The search space is the structure of possible following game-states from any moment in the game, all linked to each other with only a move in between. This reduction of search space is achieved with a search algorithm. Each search algorithm uses it's own unique approach for dealing with the problem, with varying success. Reducing the search space can be difficult, but is necessary when dealing with a time limit for each move, such as the one set for each AI in this study. 1.1.2.2 Utility functions When any search algorithm operates it needs some sort of comparable value at every node (node is in this case a game-state). The utility functions used in the AIs have the important job to evaluate the desirability of each game-state. The values used in the this study to calculate a utility are listed below: - Counter in players' store: 4 - Hole with 13 counters: 4 - Hole with an exact number of counters to receive another move: 2 - Empty hole on current players side: 1 1.1.2.3 Solving Kalaha In Searching for Solutions in Games and Artificial Intelligence, solving a game is described as Stating that a game is solved usually indicates in common parlance that a property with regard to the outcome of the game has been determined. [4], which is somewhat abstract, but accurate. In a Kalaha context, one could interpret it as constructing an AI which never loses when being the starting player, no matter if the other player is an AI or a human. Kalaha(6, 5) (6 holes per side and 5 counters in each hole) has been solved for quite some time[5], while Kalaha(6, 6) was solved recently by a project centralized in Denmark[6], which supposedly was the first time. Solving the game is not a desired accomplishment with this study. 6

1.2 Purpose and goal The goal of this study is to increase the understanding of search algorithms and utility functions in the field of Kalaha AI. This will be achieved with a series of tests and facts to back it up. The three search algorithms in focus are minimax, minimax with alpha-beta pruning and minimax with a knowledge-based alpha-beta pruning. The solving of Kalaha(6, 5) uses a form of knowledge-based pruning[5] which is a reason to why it is an interesting contestant. The algorithms will be dealing with a time limit of 30 seconds on each move. The setup for the Kalaha board will be 6 holes per side with 6 counters in each. 1.2.1 Simple utility function The simple utility function only compares the amount of counters in each players store by subtracting one of the amounts from the other then multiplying this by 4. This is the most important comparison possible in the game since the player with the most counters in his store wins. The simple utility function does not predict the following moves of a game, only what has happened thus far is relevant. 1.2.2 Knowledge-based utility function The knowledge-based utility function is an attempt to improve the simple utility function. It uses the same exact formula as the simple utility function, but with some additional evaluations that alters the utility value even further. The first one being to check if there are any holes with the perfect amount of counters in to place the last one in a store. The second one being to check if there are any holes with 13 counters in them as it allows the current player to place the last counter in a guaranteed empty hole on the players side and therefore always win at least three counters. The third one being to check if the current player has any empty holes on their side as it allows for possible captures of the other players' counters. The knowledge-based utility function was implemented with many times more operations (lowlevel instructions for the CPU) than the simple one and took more than twice as long time to execute, according to a simple test where each function was run 100000 times each. The difference in execution times allowed for some very interesting comparisons to be made as the thinking time per AI is limited. Is the extra time invested in the evaluation worth it or would it be more beneficial to just search through more game-states instead? 7

1.2.3 Minimax Minimax is one of the most important data structures in board game AI. It is the core of almost every board game AI there is[7]. Minimax operates by setting up a tree structure with nodes consisting of game-states that branches out. In Kalaha(6, 6) each node can branch out into a maximum of 6 new nodes as a player has 6 moves to be choosing from, each one giving the board a new state. The nodes have a value associated with them that describes it closeness to being a winning move. This is depicted in Figure 2. Figure 2. Minimax Tree. Paulo Pinto, (2002), Available at: http://ai-depot.com/articles/wpcontent/uploads/2007/04/minimax-search.png [Accessed 2013]. Each leaf node (a node with no child nodes) are given a value before any of the more shallow nodes. The algorithm then proceeds by placing itself on the leftmost node of the first level (the value 3 on the min level) and chooses the path with the lowest value node of its child nodes as this level is minimizing the outcome. This process is then repeated for every node in level 1 of the tree and when each has a value, the algorithm places itself at the root node and chooses a path that maximizes its value as this level is max. The value being chosen here is 5. The alternating min and max are simulating the turn passing over to the other player. The first player tries to follow a path with high valued nodes while the second player tries to follow a low value, resulting in both players working against each other. Minimax is the most basic of all the algorithms compared in this study in it's complexity. Not only is minimax being used for one of the stand-alone AIs, but also as a base for each type of AI constructed. This is because minimax, while being able to find the best moves on it's own, can be improved in several ways to reduce it's search time. 8

1.2.4 Minimax with alpha-beta pruning The AI using minimax with alpha-beta pruning extends the minimax AI with an algorithm which discards some of the excessive computations. This is done by discovering that a move is inferior, no matter the vast amount of following possible game-states. This significantly lowers the search time of minimax without losing the capability of always finding the best move[8]. Figure 3 illustrates a simplified implementation, in pseudo-code, of the alpha-beta pruning used in the project. for each hole of current player int utility = utilityfunction(); // Alpha-Beta Max if(_player == 1) if(utility > alpha) alpha = utility; // Alpha-Beta Min else if(utility < beta) beta = utility; if(beta <= alpha) // Prune break; // Breaks the for each hole loop Figure 3. Pseudocode for Minimax with alpha-beta pruning. 9

To illustrate how this works, assume a tree of game-states with utility values such as the one illustrated in Figure 4. Figure 4. Minimax tree with alpha-beta pruning. The value 9 on one of the deepest nodes in the tree is discovered which means that player 1 (max) one level above will at the very least choose this value 9. This in turn means that player 2 (min) another level above will never choose this branch as 9 is higher than the value 7 previously chosen from the other branch. This is discovered by the algorithm before evaluating the unexplored nodes noted by..., thus discarding several branches. Minimax with alpha-beta pruning has been used in previous AIs such as Deep Blue[9]. 10

1.2.5 Minimax with knowledge-based alpha-beta pruning The alpha-beta pruning was extended to pruning (discarding) whole branches of moves depending on if a (chosen) move in the branch has undesired utility. A move with undesired utility is a move which the utility function has deemed unwanted for the active player. The utility value difference limit between the two players, to indicate a bad move, varied by setting it to 60 minus the current depth in the tree, but limiting it to a minimum of 20. These values were only a rough estimate and was set so that the shallow nodes in the tree had more tolerance for bad moves than the deeper ones. This seemed natural as the branching of the tree is exponential. The purpose of this pruning is to save computation time for more promising moves. This algorithm is not based on any previous work and the name is a description of how the algorithm operates. A simplified version of the actual implementation can be seen in Figure 5 on the next page. 11

int initialutility = utilityfunction(); /* */ for each hole of current player int utility; int currentutility = utilityfunction(); if(currentdepth+1 <= searchdepth) int utilitydifference = initialutility currentutility; if(utilitydifference <= max(60-currentdepth, 20)) // Recursion on what encapsulates the for loop utility= minimaxknowledgebasedalphabeta(currentdepth+1); else utility = currentutility; // Alpha-Beta Max if(_player == 1) if(utility > alpha) alpha = utility; // Alpha-Beta Min else if(utility < beta) beta = utility; if(beta <= alpha) // Prune break; // Breaks the for each hole loop Figure 5. Pseudocode for Minimax with knowledge-based alpha-beta pruning. 12

The implementation of the algorithm starts by setting the utility value difference between the two players, to indicate how bad or good their position already is, prior to the new move (this is not displayed in the pseudo-code). When Minimax reaches a node in the tree where all child nodes have an unwanted utility, this algorithm will choose the best move possible and add the impact of this move to the total utility value difference. This new total will then be compared to the utility value difference limit, mentioned earlier, and the whole branch may be discarded if the nodes impact is too undesired. One of the downsides with this algorithm is that a discarded move, even though unwanted, may actually be worse than all the other moves possible in a given game-state and since all the bad moves are discarded, the search for the best move may end before the 30 second move limit has run out. This problem was solved by letting the regular alpha-beta pruning algorithm take over the search if the knowledge-based alpha-beta pruning finished too quickly. The most significant downside of the discarding of bad moves is that the bad move might actually force a bad move from the other player and possibly equalize the position. This will never be discovered by the algorithm. 1.3 Research questions To which extent does minimax with alpha-beta pruning and knowledge-based alpha-beta pruning improve the result compared to only minimax for six seed Kalaha with a 30 second move limit? To which extent does a knowledge-based utility function improve the result compared to a simple utility function? 1.4 Methodology 1.4.1 Kalaha programs A server-client based Kalaha application written in c++ was provided at the very beginning of the project and has been used exclusively for implementing the AIs. The graphical interface to the user is only text as the program runs within a windows console (command prompt). Together with the server executable, two clients must run simultaneously and connect to the server for a game to actually start, seeing as Kalaha is a two player game. The server is responsible for making sure that none of the clients tries to cheat. 13

The client initially had no game logic at all as it were meant to be played by humans. A part of the study was to implement game logic so that the AIs could simulate any move order desired. Each AI has been implemented directly into the Kalaha client, giving it functionality to run all of them. Choosing what type of AI a specific instance of the client (an execution of the program) will use was simply done by using command line arguments, interpreted by the client upon running it. The client is responsible for not exceeding the 30 second move limit. This was done by enforcing a time check each time a new node is about to be visited, letting about 500 operations take place in between, which gives a small margin of error. Figure 6 shows an instance of the client program using minimax with alpha-beta pruning and knowledge-based utility function when playing against another AI, running in another client instance. Figure 6. The Kalaha client. 14

1.4.2 Measuring To answer the research questions, accurate measurements under a controlled and fair environment had to be performed. An elimination competition where each losing AI was out of play simply wasn't enough. To analyze the improvements of minimax with alpha-beta pruning and minimax with knowledge-based alpha-beta pruning, they had to be run against the regular minimax repeatedly. Furthermore, the two different utility functions needed to be tested by combining them with each minimax variation for a total of six different AIs, increasing the size of the measurement procedure significantly. 1.4.3 Optimization To find a good move in the tree structure, an algorithm must traverse the tree depth-first which gives it a time complexity of the branching factor to the power of the maximal depth of the tree. This, however, assumes that the algorithm may search for as long as it wants. As a result of the time restrained moves in this study, each algorithm had to be able to stop searching instantly when out out of time, not allowing it to finalize the search. This meant that the most shallow nodes (gamestates) of the search trees had to be visited first, storing the current best move found and then proceeding to search one move further down the tree. However, as the search traverses depth first to save memory, the search must start over from the very beginning each time a new depth-limit has been reached. This technique is called iterative deepening depth-first search[10] (IDDFS). IDDFS can be faster than depth-first traversing in an unbalanced search tree if the solution is discovered in a shallow enough node, but the search used in this study does not recognize solutions (a solution would be a move which, no matter the continuation, guarantees victory for that player). While IDDFS was anticipated to be slower than depth-first in this study, it uses very little memory and allowed the algorithms to provide a good move even when interrupted by the time limit. In the case that the time limit is exceeded before finishing a new search depth, the new results are simply discarded, giving each hole on the board the same search depth achieved, making it fair to each hole. The iterative deepening optimization were, regardless of efficiency, not expected to influence the results of this study significantly as the impact is the same for each algorithm. 15

1.5 Thesis structure After the introduction, the execution of the study follows in the execution chapter. After that comes results which are a summarize of the testing of the AIs. The results are then analyzed in the discussion chapter which is followed by a summarize of it in the conclusions chapter. Future research is the last chapter in which missed opportunities and margins of error are being brought up. 2 Execution 2.1 Overview Two clients together with the server were all run on the same computer simultaneously. Twelve games per AI match-up were played where each game could end in one winning and the other losing or in a draw. In the rare case of a draw, neither AI got a win or lose increase, instead of recording the draw. Each AI was given a maximum time limit of 30 seconds for each move. This meant that when an AI had been trying to calculate the best move for too long, it had to stop the process and present it's best move found yet. This resulted in most games lasting for about 30 minutes each. Minimax would typically reach a search depth of 10 in the 30 seconds it was given. Minimax with alpha-beta pruning reached deeper with a search depth of 12. The search depth of Minimax with the knowledge-based alpha-beta pruning fluctuated far too much to be given a reliable value. Computer specifications: CPU: Intel Core i5, 4 cores @ 2.80GHz. RAM: 8,00 GB. OS: 64-bit Windows 7. 16

2.2 Sustaining the validity of the results Each minimax algorithm will always by default calculate the same move to be the best in any specific game-state. This meant that playing two AIs against each other more than twice, for each AI to move first once, was pointless. To acquire more test results, it was decided to force each AIs opening move. This means that during the very first move, no algorithm was used to determine it and the opening move was instead passed to the program as a command line argument from the user. Each of the six holes on each side was used as an opening move once per match-up. Some of these opening moves may be considered undesirable, but it was disregarded as it was just as important to see how the AIs performed in a disadvantageous position. The conditions are also equal in that both of the players (AIs) will have to combat the same scenarios the same number of times. An alternative to the forced opening moves to achieve a diversity among games was to implement the algorithms with the functionality to choose randomly between moves that it found equally good. This idea was discontinued due to two reasons. The first one being that this functionality had greater impact on some of the algorithms than on others. The second reason was because the random moves would mean that the test results are subjected to indecisive moves. Yet another alternative is to use an opening book or a database to replace the first few moves of the game, but such a resource was not available for this study. 17

3 Results In Table 1 the results for minimax with simple utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax with alpha-beta pruning Minimax with alpha-beta pruning Minimax with knowledgebased alpha-beta pruning Simple 1 11 8 % Knowledge-based 0 12 0 % Simple 2 9 18 % Minimax with knowledgebased alpha-beta pruning Knowledge-based 2 10 17 % Table 1. Minimax with simple utility function In Table 2 the results for minimax with knowledge-based utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax with alpha-beta pruning Minimax with alpha-beta pruning Minimax with knowledgebased alpha-beta pruning Simple 1 11 8 % Knowledge-based 1 11 8 % Simple 2 9 18 % Minimax with knowledgebased alpha-beta pruning Knowledge-based 3 9 25 % Table 2. Minimax with knowledge-based utility function In Table 3 the results for minimax with alpha-beta pruning and simple utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax Simple 11 1 92 % Minimax Knowledge-based 11 1 92 % Table 3. Minimax with alpha-beta pruning and simple utility function 18

In Table 4 the results for minimax with alpha-beta pruning and knowledge-based utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax Simple 12 0 100 % Minimax Knowledge-based 11 1 92 % Table 4. Minimax with alpha-beta pruning and knowledge-based utility function In Table 5 the results for minimax with knowledge-based alpha-beta pruning and simple utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax Simple 9 2 82 % Minimax Knowledge-based 9 2 82 % Table 5. Minimax with knowledge-based alpha-beta pruning and simple utility function In Table 6 the results for minimax with knowledge-based alpha-beta pruning and knowledge-based utility function are shown. Opposing algorithm Opposing utility function Wins Losses Win (%) Minimax Simple 10 2 83 % Minimax Knowledge-based 9 3 75% Table 6. Minimax with knowledge-based alpha-beta pruning and knowledge-based utility function 19

In Table 7 all the wins and losses for each AI are summarized. Algorithm Utility function Wins Losses Win (%) Minimax Simple 5 42 11 % Minimax Knowledge-based 7 40 15 % Minimax with alpha-beta pruning Minimax with alpha-beta pruning Minimax with knowledgebased alpha-beta pruning Minimax with knowledgebased alpha-beta pruning Simple 22 2 92 % Knowledge-based 23 1 96 % Simple 18 4 82 % Knowledge-based 19 5 79 % Table 7. Summarized table 20

4 Discussion 4.1 Winning search algorithm Minimax with alpha-beta pruning was the most frequently winning algorithm, closely followed by the knowledge-based alpha-beta pruning. The regular minimax were completely ineffective against the others with the low win percentage of 11 and 15. In a Kalaha context the regular minimax appears inferior to the other contestants. 4.2 Winning utility function In almost every case, the knowledge-based utility function had greater success than the simple alternative. This is quite surprising in this time restrained context considering how much longer it takes to execute. Furthermore, the function is nowhere near perfect. The existing evaluations can be optimized and additional evaluations may be added. Each part of the utility functions is very tailormade to evaluate a game-state in Kalaha and thus the success rate is only valid in Kalaha. 4.3 Improvements The knowledge-based alpha-beta pruning acquired a lower win percentage than minimax with alpha-beta pruning. The drawbacks of the algorithm, mentioned earlier, outweighed the faster search time. There are two possible improvements to be made for this algorithm. The first one is to use a more accurate and faster utility function as this algorithm is very dependent upon the evaluation of each game-state and even more so than the other algorithms. The other improvement is to tweak the values which sets the limit of how desirable a game-state must be to be worth searching past, perhaps by cooperating with a database. To add these improvements successfully, some testing and evaluation would be required, but with them the knowledge-based alpha-beta pruning may acquire the ability to perform better than alpha-beta pruning. 21

The solving of Kalaha(6, 5) in the year 2000 used a step-size of three for the iterative deepening[5] instead of one as used in this study. This means that less duplication of the searches through the game-states occurred. Experimenting with the step-size would have been a good idea to include in this study. The mentioned solving of Kalaha also used an improved version of alpha-beta pruning called MTD(f)[5], which might be a more efficient algorithm than knowledge-based alpha-beta pruning. An equivalent of the simple utility function evaluated in this study was used in the solving to evaluate game-states[5]. This is very interesting seeing as the knowledge-based utility function evaluated in this study had greater success than the simple utility function. This means that the using of a simple utility function (evaluating a game-state by only comparing each players stored counters) is sufficient when pairing it with a more advanced search algorithm such as MTD(f). The solving of Kalaha(6, 5) uses end-game databases[5]. The solving of Kalaha(6, 6) appears to be using end-game databases, as well as an opening book (when playing against a browser-version of the AI it clearly states Downloading Opening Book and Downloading EndGame Database [6]). These resources are useful for simplifying some of the, otherwise, extremely time-consuming calculations. It is also very likely that some of the moves in the end-game database and opening book are very hard for a computer to find. The solving of Kalaha(6, 5) also uses search improvements such as move ordering, transposition tables, futility pruning and enhanced transposition cut-off[5], which are all absent in this study. 5 Conclusions A Kalaha AI using Minimax with alpha-beta pruning vastly outplays a Kalaha AI using only minimax to the point of almost never losing. To fully examine if the knowledge-based pruning algorithm can be a further improvement to alpha-beta pruning, it needs to be developed further. In the context of playing Kalaha with a 30 second move limit, the knowledge-based utility function proves to be useful when paired with minimax with alpha-beta pruning. However, when solving Kalaha, this algorithm may become superfluous (as opposed to an evaluation of the counters in each players store) when paired with a more advanced search algorithm than minimax with alpha-beta pruning. 22

6 Future research The knowledge-based alpha-beta pruning constructed in this study was not a successful improvement of alpha-beta pruning. Would the improvements suggested in this study make the algorithm perform better than alpha-beta pruning, as predicted? How do you create such a strong search algorithm that using a simple utility function is superior to using the knowledge-based utility function, such as the one used in the solving of Kalaha(6, 5) in the year 2000[5]? This would be beneficial to explore as an algorithm that solves the game of Kalaha may do well even with time limits. Even if the iterative deepening being used with minimax is very unlikely to have been affecting the outcome of this study, it would be interesting to see a solution that completely removes the duplicated searches of iterative deepening. Minimizing the cloned searches would result in a much faster search algorithm and would thus greatly benefit an AI playing Kalaha. Can this be accomplished? Alternatively, can another faster algorithm which doesn't use too much memory replace iterative depeening? 23

7 References [1] R. Gering, Kalah, Wikimanqala, 2003 [2] A. G. Bell, Kalah on Atlas, in Artificial Intelligence 3, Atlas Computer Laboratory, 1968 [3] J. Donkers, J. Uiterwijk, A. de Voogt, Mancala games, in Mathemathics and Artificial Intelligence, Maastricht University, 2001 [4] L. V. Allis, Searching for Solutions in Games and Artificial Intelligence, Rijksuniversiteit Limburg, Maastricht, The Netherlands, ISBN 90 9007488 0, 1994 [5] G. Irving, J. Donkers, J. Uiterwijk, Solving Kalah, Maastricht, The Netherlands, 2000 [6] A. Carstensen, Solving (6,6)-Kalaha, University of Southern Denmark, 2011 [7] Published by the people at or affiliated with AI Horizon, Minimax Game Trees, 2002 [8] Bruce E. Rosen, Minimax with Alpha Beta Pruning, in CS 161 Recitation Notes, UCLA Engineering, 2009 [9] Prof. P. Bhattacharya, Deep Blue - search algorithms, Department of Computer Science and Engineering, 2011 [10] E. Mayefsky, F. Anene, M. Sirota, ALGORITHMS ITERATIVE DEEPENING, in Intellectual Excitement of Computer Science, Stanford University, 2003 24