General Heuristic for Tic-Tac-Toe-Like Games

Similar documents
Gamesman: A Graphical Game Analysis System

Introduction Solvability Rules Computer Solution Implementation. Connect Four. March 9, Connect Four

Laboratory work in AI: First steps in Poker Playing Agents and Opponent Modeling

Augmented Reality Tic-Tac-Toe

3. How many winning lines are there in 5x5 Tic-Tac-Toe? 4. How many winning lines are there in n x n Tic-Tac-Toe?

Sowing Games JEFF ERICKSON

Near Optimal Solutions

Roulette Wheel Selection Game Player

One pile, two pile, three piles

Chess Algorithms Theory and Practice. Rune Djurhuus Chess Grandmaster / October 3, 2012

THE APPLICATION OF ARTIFICIAL INTELLIGENCE TO SOLVE A PHYSICAL PUZZLE. Dana Cremer

Algebra 2 C Chapter 12 Probability and Statistics

Monte-Carlo Methods. Timo Nolle

Board Games. With Monkey Friends. 15 Multiplication Board Games to practice multiplication up to 10 x 10

UM Online Practice Programming Contest September 20, 2011

Integrating Cue Reading and Decision-Making into Skill Development

Acknowledgements I would like to thank both Dr. Carsten Furhmann, and Dr. Daniel Richardson for providing me with wonderful supervision throughout my

The Taxman Game. Robert K. Moniot September 5, 2003

Scenario: Optimization of Conference Schedule.

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

15-251: Great Theoretical Ideas in Computer Science Anupam Gupta Notes on Combinatorial Games (draft!!) January 29, 2012

Rules for TAK Created December 30, 2014 Update Sept 9, 2015

CS MidTerm Exam 4/1/2004 Name: KEY. Page Max Score Total 139

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Current California Math Standards Balanced Equations

Basics of Dimensional Modeling

Generalized Widening

10. Machine Learning in Games

A Non-Linear Schema Theorem for Genetic Algorithms

20-30 minutes, can be used within a longer activity

Analyzing the Procurement Process in a Simplified Version of the TAC SCM Game

The art of linking the elements.

Kindergarten Math Content 1

The Physics and Math of Ping-pong and How It Affects Game Play. By: Connor Thompson & Andrew Johnson

Ary, a general game playing program

Hierarchical Judgement Composition: Revisiting the Structural Credit Assignment Problem

Math Games For Skills and Concepts

MAKING MATH MORE FUN BRINGS YOU FUN MATH GAME PRINTABLES FOR HOME OR SCHOOL

Lab 11. Simulations. The Concept

Math 728 Lesson Plan

Maximizing Precision of Hit Predictions in Baseball

ECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2015

Volume of Pyramids and Cones

Checking for Dimensional Correctness in Physics Equations

The test uses age norms (national) and grade norms (national) to calculate scores and compare students of the same age or grade.

Ch. 13.2: Mathematical Expectation

Golf League Formats and How to Run Them

Random Map Generator v1.0 User s Guide

THE WHE TO PLAY. Teacher s Guide Getting Started. Shereen Khan & Fayad Ali Trinidad and Tobago

From Last Time: Remove (Delete) Operation

FIRST EXPERIMENTAL RESULTS OF PROBCUT APPLIED TO CHESS

Artificial Intelligence Beating Human Opponents in Poker

Problem of the Month: Fair Games

D C. itself as the board. You are now one of those B wizards...

Introducing Students to the Game of Science. David P. Maloney and Mark F. Masters. Physics Department. Indiana University Purdue University Fort Wayne

Doubles Strategy by Robert Bj Jacobucci

CHAPTER 1 ARROW BALLISTICS FROM SINGLE SHOT TO COURSE REQUIREMENTS

Unit 5 Length. Year 4. Five daily lessons. Autumn term Unit Objectives. Link Objectives

Brain-in-a-bag: creating an artificial brain

Genetic Algorithms and Sudoku

CS Master Level Courses and Areas COURSE DESCRIPTIONS. CSCI 521 Real-Time Systems. CSCI 522 High Performance Computing

Full and Complete Binary Trees

Sequential lmove Games. Using Backward Induction (Rollback) to Find Equilibrium

Optimal Binary Search Trees Meet Object Oriented Programming

Data Preprocessing. Week 2

Factorizations: Searching for Factor Strings

Game Playing in the Real World. Next time: Knowledge Representation Reading: Chapter

Load Balancing and Switch Scheduling

Heaps & Priority Queues in the C++ STL 2-3 Trees

RACE TO CLEAR THE MAT

Probabilistic Strategies: Solutions

Algorithms and Data Structures

The positive minimum degree game on sparse graphs

Course Outline Department of Computing Science Faculty of Science. COMP Applied Artificial Intelligence (3,1,0) Fall 2015

Factoring General Games using Propositional Automata

Boxed In! Annotated Teaching Guide

Union-Find Algorithms. network connectivity quick find quick union improvements applications

Structural Design Patterns Used in Data Structures Implementation

Example of the Glicko-2 system

Storage and Playback Getting Started Guide

Creating a NL Texas Hold em Bot

Martin J. Silverthorne. Triple Win. Roulette. A Powerful New Way to Win $4,000 a Day Playing Roulette! Silverthorne Publications, Inc.

Tasks to Move Students On

Notes on Complexity Theory Last updated: August, Lecture 1

Dynamic programming formulation

Regular Languages and Finite Automata

A Comparison of Dictionary Implementations

School of Computer Science

MAN VS. MACHINE. How IBM Built a Jeopardy! Champion x The Analytics Edge

The New Mexico Lottery

CALCULATIONS & STATISTICS

Binary Heap Algorithms

There are a number of superb online resources as well that provide excellent blackjack information as well. We recommend the following web sites:

Search methods motivation 1

Game Theory 1. Introduction

Texas Hold em. From highest to lowest, the possible five card hands in poker are ranked as follows:

Transcription:

General Heuristic for Tic-Tac-Toe-Like Games Martha Mercaldi, Katarzyna Wilamowska November, 24 Abstract: We define and explore a general class of twoplayer board games. Members of this class are defined by the dimensionality and size of the board, the allowable moves and the length of a a run required to win. We evaluate and compare three heuristics which can be applied to any member of this class. We have implemented a general game-playing framework, referred to as Connect-Toe which can simulate all games in this class and which can be used for further investigation. 3rd Dimension st Dimension Introduction We have defined a general class of games to study. This class contains two board games which have already been studied extensively, Tic-Tac-Toe [2] and Connect Four. esearchers have developed specialized heuristics to evaluate incomplete boards for both of these games [7]. We believe that a general heuristic could be developed and applied to all games in this more general class of board games. In games, where the search tree is potentially very large (both in depth and branching factor) a heuristic which can evaluate incomplete game states is useful. With such a heuristic a Minimax search algorith can be both targeted (to search directions that show the best potential first) and shortened (recursive search can return before reaching a leaf of the search tree). We define three very simple heuristics, ptimistic, essimistic and ndecided, described in Section 3 and evaluate and compare their efficacy on a broad class of board games. 2 Class of Board Games The class of games which we study for this project contains board games which are played by two players alternately dropping their own tokens into the board. When a token is dropped into some slot, it falls until it hits either another token or the bottom of the board. The first player to create a designated length string of his own tokens wins. The games in this class vary according to several attributes: dimensionality Dimensionality of the game board size Size of board in each dimension (greater than or equal to ) winning run length Length of run (in any direction) required to win 2nd Dimension Figure : Classic Tic Tac Toe as a class member. open faces An open face is a face through which pieces can be dropped into the board. nce inserted a piece will fall either to the bottom of the board, or until it is blocked by another piece already in the board. For example, in Connect Four, the grid is 7x6x with only one 7x face,, open. In Tic-Tac-Toe the grid is 3x3x with one 3x3 face, 2, open. See Figures and 2 for illustrations. The shaded board faces are the open faces. Each face id is a signed integer. The magnitude indicates the dimension along which a piece will fall, and the sign indicates the direction, upwards or downwards. This attribute restricts the allowable moves. We first focus our heuristic comparison on Tic Tac Toe and Connect Four. Because this class of games is defined by so many attributes, it makes sense to first study them one at a time, instead of taking them all on at once. After first looking at the special cases of Tic Tac Toe 5 and Connect Four 6, we focus our heuristic comparison on varying three dimensional board sizes 7. For the purposes of this paper, we have combined these two variants into testing the results from varying sizes of cubes. In Section 8 other potentially interesting and relevatory studies are discussed.

3rd Dimension TicTacToe: Heuristics for A st Dimension A's Winning ercentage.9.8.7.6.5.4.3.2. 2 3 4 5 6 7 8 9 2nd Dimension Figure 3: layer A s winning percentage at Tic Tac Toe broken down by heuristic. 3 Heuristics Figure 2: Connect Four as a class member. The heuristics used in this study were designed to be simple. When presented with a complete board, determined by either the board being full, or a win for one of the players, all of the heuristics returned a + for a win, for a draw and - for a loss. The variation between ptimistic, essimistic and ndecided heuristics developed from the game having to resolve the value of an unfinished/undecidable board resulting from a depth control added to decrease search time. ptimistic, when faced with an undecidable board, would choose to mark it as a possible winning move, +. essimistic would choose a loss, -, and ndecided would choose a draw,. 4 Methodology For this study we implemented a general representation of all board games in our class. With this is a general Minimax search algorithm which can use each of the three heuristics. ur framework also supports a random game player, which makes all of its moves at random. For each game configuration we evaluate we simulated games. A bigger sample set would have been ideal, but time concerns restricted us to just runs of each game. 5 Special Case: Tic Tac Toe First we examine the case of Tic Tac Toe. As we seek to evaluate the efficacy of our three simple heuristics, we look at how they perform as the search depth varies. We expect to see interesting trends since the search depth determines how early the heuristic is applied. The farther from the leaves the heuristic is applied the more of the search it influences. Figure 3 shows how the winning percentages of each heuristic are effected by search depth. We see that relatively large (though inconsistent) differences between the heuristics with small search depths dimish as the search deepens. We explain this trend in the following way. When a board is empty, every possible game outcome is possible. As moves are made and the board fills, the set of possible outcomes shrinks. If the heuristic is applied when this set is small, it has less opportunity to affeect the game outcome. The early part of this graph is difficult to decipher. There are not any clear trends. This could be due to our relatively small sample size, and that with more experiments the variation would settle and a more clear trend would emerge. It is also possible that looking at the data in more detail might reveal more. In Figure 4 we show the winning percentage for each of the heuristics when playing against each type of opponent. The opponent is a andom opponent. Most noticable in this data is the sweet spot that the essimistic heuristic seems to have with searches 3 deep. However, we hesitate to trust the results. As shown in Figure 5 as the search deepens more and more games reach draws. Because the winning percentage is calculated as the number of games player A wins divided by the number of games either player won, the sample set is increasingly small. Starting with an already small sample set, the shrinking due to elimination of increasing numbers of draws only exacerbates the problem. 6 Special Case: Connect Four Let us now examine our second special case, Connect Four. There the game player has a larger grid to contend with (6x7)

Tic Tac Toe: Decided Games 35 A's Winning ercentage.9.8.7.6.5.4.3.2. ptimistic Heuristic for A Number of Decided Games (not draws) 3 25 2 5 5 2 3 4 5 6 7 8 9 Figure 5: Number of Tic Tac Toe games that do not end in draws, by search depth. 2 3 4 5 6 7 8 9 essimistic Heuristic for A Connect Four: Heuristics for A.9 A's Winning ercentage.8.7.6.5.4.3.2. A's Winning ercentage.9.8.7.6.5.4.3.2. 2 3 4 5 6 7 8 9 ndecided Heuristic for A 2 3 4 5 6 A's Winning ercentage.9.8.7.6.5.4.3.2. 2 3 4 5 6 7 8 9 Figure 6: layer A s Connect Four winning percentage broken down by heuristic yet there are fewer legal moves (seven compared to nine for Tic Tac Toe). The experiments from 5 were repeated for the Connect Four. Just as before, we expected to see interesting trends dependent on the search depth. Figure 6 shows how the winning percentages of each heuristic is effected by search depth. Figure 4: Breakdown of winning percentage at Tic Tac Toe for each strategy, by opponent. Where with Tic Tac Toe we had little evidence for one heuristic outperforming the others, in the Connect Four case, we are able to find a more likely winner. The best performance is given by ndecided with an average 74% winning percentage, followed by ptimistic with an average of 6% and essimistic at 58%. As further support, we can see in Figure 7 that ndecided tends to have at least 5% fewer losses than any other heuristic.

Growing cubes: Heuristics for A.9 A's Winning ercentage.9.8.7.6.5.4.3.2. ptimistic Heuristic for A A's Winning ercentage.8.7.6.5.4.3.2. 2 3 4 5 6 Cube Edge Size 2 3 4 5 6 essimistic Heuristic for A Figure 8: layer A s winning percentage at Cubic Tic Tac Toe broken down by heuristic, for increasing cube sizes. A's Winning ercentage A's Winning ercentage.9.8.7.6.5.4.3.2..9.8.7.6.5.4.3.2. 2 3 4 5 6 ndecided Heuristic for A 2 3 4 5 6 Figure 7: Breakdown of winning percentage for Connect Four for each strategy 7 Increasing Cube Sizes As another test of our heuristics abilities, we experimented with 3D sized cubes while varying the size of the cube and matching the winning run length to the size of a cube side. We expect to see the diference of the cube size not to cause any change in performance of our heuristics. Although the search tree is much larger for each increasing size of cube, due to the increasing size of run length necessary to win, the problem is basically the same. As such, this experiment, in part checks whether our heuristics are scalable. Figure 8 shows how the winning precentages of each heuristic are effected by cube size. We see first of all the inconsistency that all heuristics have a % winning ratio when applied to cubes of size 2x2x2. Such a result is expected, due to the size 2 3D cube being a generic case, since no matter what the opponent s next move may be, any next move that our player makes, forces an instant win for our player. As we examine the sizes of cubes greater than 2, the hypothesis of scalability is realized. With slight variation, most likely a result of using a small sample, the winning percentage of any of our heuristics remains constant through the increases in cube size. We can observe that ptimistic has not performed nearly as well as either essimistic or ndecided. Additionally, we have further proof of ndecided outperforming the other two of our heuristics. Notice that the variation of ndecidable is less than 2%, Figure 9. Let us now examine Figure 8. ndecided outperforms the other heuristics by losing the least percentage of games to its opponents, including itself, with essimistic as a close second. ptimistic plays poorly and barely outperforms random play.

A's Winning ercentage ptimistic Heuristic for A.9.8.7.6.5.4.3.2. 2 3 4 5 6 Cube Size essimistic Heuristic for A 8 Future Work There are many future studies that could be done in this vein. The framework we have implmenented is extremely general, and in this work we have evaluated only a small sliver of the class of games it is capable of representing. As mentioned in Section 2 the class is highly multidimensional. That is to say game members can vary along many dimensions: board dimensionality, board size, the length of a winning run, the number and orientation of open faces. The basic heuristics we describe in this work could be evaluated along one or more of these dimensions. We also believe that a more intelligent heuristic could be developed to more precisely evaluate an incomplete board state. Because the rules of the game are fairly regular, a player could find existing runs and depending on how long they are and if it is possible to extend them to winning length, make a more precise valuation of an incomplete board. 9 Conclusion A's Winning ercentage.9.8.7.6.5.4.3.2. 2 3 4 5 6 Cube Size ndecided Heuristic for A The Connect-Toe program designed to facilitate our experiments on the Tic-Tac-Toe and Connect Four class games has been built to play all games designed in Section 2. We examined how three simple heuristics perform against one another and against random play. With limited feedback, due to time constraints, we were able to discern that the ndecided heuristic tended to outperform the other heuristics. ur framework will support more thourough exploration both of the designated class of board games and the space of possible heuristics. eferences A's Winning ercentage.9.8.7.6.5.4.3.2. 2 3 4 5 6 Cube Size Figure 9: Breakdown of winning percentage at Cubic Tic Tac Toe for each strategy, by opponent, for increasing cube sizes. [] Thuente, David J., and hys rice Jones. Beyond minimaxing for games with draws. roceedings of the 9th annual conference on Computer Science, April 99: 55-557. [2] Carroll, Maureen T., Steven T. Dougherty. Tic- Tac-Toe on a Finite lane. 5 ct 24 < http://academic.scranton.edu/faculty/carrollm/tictac.pdf >. [3] Dyer, C.. Game laying (Chapter 6). CS 54 Lecture Notes. 22 ct 24. niversity of Wisconsin, Madison, Wisconsin < http://www.cs.wisc.edu/ dyer/cs54/notes/games.html >. [4] Minimax and Alpha-Beta Template. 22 ct 24 < http://www.cs.caltech.edu/ petrovic/games/archex/othellodir/node2.html >. [5] Mnk-games Wikipedia, the free encyclopedia 7 ct 24.

[6] MTD(f): A Minimax Algorithm faster than NegaScout. Aske laat: MTD(f), a new chess algorithm. 5 ct 24 < http://www.cs.vu.nl/ aske/mtdf.html >. [7] ilgrim, obert A. TIC-TAC-TE: Introducing Expert Systems to Middle School Students. SIGCSE roceedings (995):34-344. [8] Topics: Minimax. CS6B, Spring 23.5 Apr 23. 7 ct 24 < http://www.cs.berkeley.edu/ kamil/sp3/minimax.pdf >.

Data Tables

Tic Tac Toe Search depth.458333333.85742857.62857429 2.78268696.567567568.9343478 3.46875.958333333.69565274 4.82686957.76475882.85 5.722222222.76475882.78268696 6.789473684.65384654.78333333 7.6527393.75.727272727 8.75882353.76475882.6875 Table : Source data for Figure 3. Search depth.2.42857429.8.42857429 2.75.7428574.5 3.444444444.25.875.42857429 4.333333333.85742857.8 5.4 6.5.5 7.7428574.5 8 #DIV/!.333333333.666666667 Table 2: Source data for ptimistic heuristic in Figure 4 Search depth.875.666666667.888888889 2.222222222.8.9.25 3.75 4.6.5.5 5.666666667.5.5 6.5.42857429.5 7.75.85742857.4 8.333333333.75 Table 3: Source data for essimistic heuristic in Figure 4 Search depth.3.666666667.625 2.5.8 3.7428574.75.2 4.666666667.833333333.666666667 5.666666667.5742857 6.5742857.75.875.6 7.666666667.5742857.333333333 8.5.333333333 Table 4: Source data for ndecided heuristic in Figure 4

Search depth Decided Games 94 2 83 3 79 4 6 5 58 6 69 7 65 8 5 Table 5: Source data for ndecided heuristic in Figure 4

Connect Four Search depth.35.65.675 2.88888.3.7243793 3.53623884.8.7352948 4.5362245.625.82857429 5.7352948.583333333.7352948 Table 6: Source data for Figure 6. Search depth.4.4.6 2.82352942.9.222222222 3.8..9. 4.375.2376923.7 5.5742857.875.9.555555556 Table 7: Source data for ptimistic heuristic in Figure 7 Search depth.2.8.6 2..3.6. 3.7.6 4.3.5.7 5.5.625.9.25 Table 8: Source data for essimistic heuristic in Figure 7 Search depth.7.6.8.6 2.333333333.8.9.75 3.9.6.333333333 4.888888889.85742857.9.666666667 5.5.625.75 Table 9: Source data for ndecided heuristic in Figure 7

Growing Cubes Search depth 2 3.425.75.775 4.425.75.76923769 5.35.85789474.757575758 Table : Source data for Figure 8. Search depth 2 3.7..9 4.7 5.7.7 Table : Source data for ptimistic heuristic in Figure 9 Search depth 2 3.9.7.4 4.6.4 5.7.5 Table 2: Source data for essimistic heuristic in Figure 9 Search depth 2 3.4.7 4.6.444444444 5.3.666666667 Table 3: Source data for ndecided heuristic in Figure 9