Determining the Cost Function In Tic-Tac-Toe puzzle game by Using Branch and Bound Algorithm

Similar documents
Chess Puzzle Mate in N-Moves Solver with Branch and Bound Algorithm

Winning the Trick as Defender in Contract Bridge Card Game Using Greedy Algorithm

Visual Novel Storyline Represented in Graph

Graph Application in The Strategy of Solving 2048 Tile Game

Greedy Algorithm for Weiß Schwarz(PSP)

Application of Greedy Algorithm in Brigandine : The Legend of Forsena

The Role of Combinatorics in Hearthstone

Implementation of Greedy Algorithm for Designing Simple AI of Turn-Based Tactical Game with Tile System

Cryptography s Application in Numbers Station

The Mathematics of Playing Tic Tac Toe

Application of Tree in Finding Inherited Genetical Diseases Using Genogram

Applications of Karnaugh Map and Logic Gates in Minecraft Redstone Circuits

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

EXPLORING TIC-TAC-TOE VARIANTS

Grade 7 & 8 Math Circles. Mathematical Games

ARTIFICIAL INTELLIGENCE (CS 370D)

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

LEARNING ABOUT MATH FOR GR 1 TO 2. Conestoga Public School OCTOBER 13, presented by Kathy Kubota-Zarivnij

3 0 S E C O N D Q U I C K S T A R T To start playing right away, read this page.

CMPUT 396 Tic-Tac-Toe Game

Game, Set, and Match Carl W. Lee September 2016

Unit 12: Artificial Intelligence CS 101, Fall 2018

THE APPLICATION OF DEPTH FIRST SEARCH AND BACKTRACKING IN SOLVING MASTERMIND GAME

PROBLEMS & INVESTIGATIONS. Introducing Add to 15 & 15-Tac-Toe

Chess Handbook: Course One

1, 2,, 10. Example game. Pieces and Board: This game is played on a 1 by 10 board. The initial position is an empty board.

2 person perfect information

game tree complete all possible moves

Adversary Search. Ref: Chapter 5

Game-playing AIs: Games and Adversarial Search I AIMA

CS 1571 Introduction to AI Lecture 12. Adversarial search. CS 1571 Intro to AI. Announcements

CS 2710 Foundations of AI. Lecture 9. Adversarial search. CS 2710 Foundations of AI. Game search

Games (adversarial search problems)

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

Artificial Intelligence Search III

A Quoridor-playing Agent

Games of Skill ANSWERS Lesson 1 of 9, work in pairs

Basic Introduction to Breakthrough

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

Using Artificial intelligent to solve the game of 2048

Tic-tac-toe. Lars-Henrik Eriksson. Functional Programming 1. Original presentation by Tjark Weber. Lars-Henrik Eriksson (UU) Tic-tac-toe 1 / 23

Game Playing AI. Dr. Baldassano Yu s Elite Education

COMP9414: Artificial Intelligence Problem Solving and Search

1 Modified Othello. Assignment 2. Total marks: 100. Out: February 10 Due: March 5 at 14:30

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

2359 (i.e. 11:59:00 pm) on 4/16/18 via Blackboard

Five-In-Row with Local Evaluation and Beam Search

AI Approaches to Ultimate Tic-Tac-Toe

Adversarial Search Aka Games

5 Games For Building Logic

Problem F. Chessboard Coloring

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

Adversarial Search and Game Playing. Russell and Norvig: Chapter 5

Minimax Trees: Utility Evaluation, Tree Evaluation, Pruning

Tic-Tac-Toe and machine learning. David Holmstedt Davho G43

Assignment 2 (Part 1 of 2), University of Toronto, CSC384 - Intro to AI, Winter

Introduction to Spring 2009 Artificial Intelligence Final Exam

Ar#ficial)Intelligence!!

YourTurnMyTurn.com: Go-moku rules. Sjoerd Hemminga (sjoerdje) Copyright 2019 YourTurnMyTurn.com

Adversarial Search (Game Playing)

CSE 573 Problem Set 1. Answers on 10/17/08

UNIT 13A AI: Games & Search Strategies. Announcements

Lecture 33: How can computation Win games against you? Chess: Mechanical Turk

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

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

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

An End Game in West Valley City, Utah (at the Harman Chess Club)

A Simple Pawn End Game

INSTRUCTIONS. Cardinal Industries Inc. LIC, NY Made in China.

A1 Problem Statement Unit Pricing

CS 440 / ECE 448 Introduction to Artificial Intelligence Spring 2010 Lecture #5

Generalized Amazons is PSPACE Complete

Announcements. Homework 1 solutions posted. Test in 2 weeks (27 th ) -Covers up to and including HW2 (informed search)

UNIT 13A AI: Games & Search Strategies

Legend. The Red Goal. The. Blue. Goal

mywbut.com Two agent games : alpha beta pruning

YourTurnMyTurn.com: chess rules. Jan Willem Schoonhoven Copyright 2018 YourTurnMyTurn.com

Huffman Coding For Digital Photography

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

Artificial Intelligence. Minimax and alpha-beta pruning

ADVERSARIAL SEARCH. Chapter 5

The first player to construct his or her obelisk is the winner, and if a player has no legal moves, he or she immediately loses the game.

Game, Set, and Match Carl W. Lee September 2016

Foundations of AI. 3. Solving Problems by Searching. Problem-Solving Agents, Formulating Problems, Search Strategies

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

Welcome to the Brain Games Chess Help File.

A Brief Introduction to Game Theory

Google DeepMind s AlphaGo vs. world Go champion Lee Sedol

Coin Cappers. Tic Tac Toe

Assignment 2, University of Toronto, CSC384 - Intro to AI, Winter

LITTLE BITES TIC TAC TOE Pair two of your favorite classics- Little Bites and Tic Tac Toe- for a game that is bound to bring back happy memories!

Let s Make. Math Fun. Volume 19 January/February Dice Challenges. Telling the Time. Printable Games. Mastering Multiplication.

The Galaxy. Christopher Gutierrez, Brenda Garcia, Katrina Nieh. August 18, 2012

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

CS 771 Artificial Intelligence. Adversarial Search

Rubik s Cube: the one-minute solution

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

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

NEVADA GOOD SAMS GAME RULES Revised September 2015

Transcription:

Determining the Cost Function In Tic-Tac-Toe puzzle game by Using Branch and Bound Algorithm Teofebano - 13512050 Program Studi Teknik Informatika Sekolah Teknik Elektro dan Informatika Institut Teknologi Bandung, Jl. Ganesha 10 Bandung 40132, Indonesia 13512050@std.stei.itb.ac.id Abstract Tic-Tac-Toe is a classic puzzle game that requires exactly two people to play it. The objective of this game to make a straight three symbols, can be horizontally, vertically, or diagonally, in a 3x3 tiles while the opponent will do the same. Branch and Bound algorithm will help to find the cost function of each move so the game later will produce a winner after 5 th turn without any following steps to finish all the left tiles. Index Terms Branch and Bound, Cost, Symbols, Tic- Tac-Toe I. INTRODUCTION Puzzle game, especially the games which involved two or more people in it, have a unique competition characteristic. Some games will make the players concentrate and focus in very long time, like chess, and the other will only be held in just a few minutes and make the winner outsmarts the opponents with a simple smart movement. Therefore this game will become addictive and make the players play it on and on consecutively because it just cost a small amount of time and really simple to be played with friends. One of these games is Tic-Tac-Toe. This puzzle game are originated in Roman Empire ages and modified several times along its journey [1]. The original version of Tic-Tac-Toe just permits the players to hold only three marks, and to make an alignment of the marks in the 3x3 tiles, they have to move it from one place to another place. In 1856, this game version becomes more futuristic, which means close enough to be called Tic-Tac-Toe nowadays. This version is still using the same board, 3x3 tiles, but the amount of marker is unlimited as long as the tiles aren t full of marks. The rule is also same as the original version, which is to make an alignment of the same symbols, can be horizontally, vertically, or diagonally, without get any obstructions from the opponent markers. The common symbols or markers are O (circle) or X (an alphabet X), and it has become a trademark around the world. Because its simplicity, this game is now worldwide known and played in spare time by many people. Figure 1. Tic-Tac-Toe Gameplay (source: http://dreamstime.com/tic_tac_toe Accessed in 16 Mei 2014; 08:30pm) II. TIC-TAC-TOE Tic Tac Toe is a simple game, but despite its simplicity there are a lot of calculations inside it. The position of the marks, especially the first mark is determining the flow of the game. The positions themselves, sometimes, can be referred into a state of the board, which also explaining where the game will be going into. Figure 2. The States of The Board (source: http://dreamstime.com/tic_tac_toe Accessed in 17 Mei 2014; 01:26 pm) By calculating the possibilities of the state in this game, we can find out that there are 138 unique positions. In these positions, the first player will have 91 out of 138 chances to win, and the second player will have only 44

out of 138 chances [2]. The remaining 3 positions are led the game into tied condition. These positions are unique and have ignored the rotations and reflective phenomenon in the board. In this game, there are plenty of strategies to defeat the opponent, outsmart them to make useless move, and also force them to close the match with draw condition. These strategies are [3] 1. Win If you have two marks in a row (regardless direction), you can place the third mark to complete the alignment 2. Block If the opponent have two marks in a row (regardless direction), you have to block it by putting your mark into the that third place so they cannot place the third mark 3. Fork Creating the opportunity where you have two uncovered two marks in a row (regardless position) so the opponent are forced to do useless block you not being forked easily 7. Empty Corner Maximize the use of the side sometime can bring a quick advantage in some games 8. Empty Side Maximize the use of the corner sometime can bring a quick advantage in some games These strategies are derived from the tree of states (in Figure 2), so the patterns that lead into a winning situation are condensed into these eight strategies. These strategies are played in certain assumption, such as the opponent will try to win the game and will not do any useless movement [4]. A. Tree (Graph theory) III. BASIC THEORY Tree in graph theory is a generally a graph that has specific characteristics, such as does not have direction and does not form a circuit. Typically, a tree is a simple graph because it cannot have ring in its edges or have weighted edges. Because these characteristics, a tree have many advantages, which are easy to be applied in daily life, especially to model certain problems, and easy to visualize it. The example of the graph is decision tree and state tree (in Figure 2). Figure 3. The Fork Condition Accessed in 17 Mei 2014; 01:29 pm) 4. Block-Fork Block the creation of the fork by guessing it from the beginning. The first method is to avoid placing mark in the corner while the opponent has two opposite corners and you hold the center position. The second method is to block the configuration of the fork itself 5. Center Take center position as fast as possible. Center position will lead into an easy fork while the opponent does some mistakes 6. Opposite Corner Take the opposite corner as fast as possible after the opponent take the other corner. This will help Figure 4. The Example of a Tree (source: http://adijohn.blogspot.com/ Accessed in 17 Mei 2014; 01:36 pm) The state tree is so helpful because it can show all the possibilities in a problem, especially if the problem branches from one node to another node where its leaf is a final state of the problem or usually the solution of the problem itself. By visualizing it with the tree, the problems become simpler and traceable. There are plenty of algorithms to simplify and raise the effectiveness of tree, such as depth-first search, breadthfirst search, branch and bound algorithm, and so on. These algorithms have unique characteristic to find solution inside a tree, and retrieve any useful information from it. Therefore, a tree can give some perspectives about a problem, whether from the way to find the solution or the way problems are mapped.

B. Branch and Bound Algorithm Branch and Bound (B&B) algorithm is an advanced breadth-first search (BFS), a search algorithm that help find the solution from the tree (also called cost-based tree) [6]. The difference between the branch and bound algorithm with the breadth-first search is in the system that controls the expansion of the node. In BFS, the nodes that will be expanded are using FIFO (First In, First Out) rule, which will lead to broad search before advance to the next depth level. In the B&B algorithm, every node has its own cost, a number that later will determine which node will be expanded after the other node. This algorithm will help the program saving times that usually used to search a node that will not lead to the solution. This algorithm can only be used in a problem where we have already known about the final state, or the condition that want to be searched in the tree, otherwise it will search the whole tree without any reason and any clear cost function for each node. Nonetheless, there are still plenty of problems that can be solved by using this algorithm, such as N-Queen Problem, Travelling Salesperson Problem, 15-Tiles Puzzle and so on. branch and bound itself is fulfilled, which is the end state known. The different in the use of branch and bound is not to find the solution, but to make a decision as fast as possible, whether the player is winning or losing. In this situation, a tic tac toe is a multiplayer game and the solution is varying based on the move taken by the players. Based on the explanation before, there are 138 possibilities how the game will end with three statuses, win, draw, or lose. So the objective of the use of branch and bound here is to declare the winner as fast as possible without to fill all the tiles on the board. Figure 6. The Dead-end Position Accessed in 17 Mei 2014; 01:49 pm) Figure 5. The 15-Tiles Puzzle (source: http://www.ams.org/news/math Accessed in 17 Mei 2014; 02:01 pm) In the B&B algorithm, the cost function is becoming fundamental because it determines how the tree will be expanded and how to reach conclusion in fastest way. The cost function itself is increasing the efficiency of searching time because not all the nodes are produced during the expansion IV. COST FUNCTION IN TIC TAC TOE The tic tac toe is also a puzzle that can be helped by using branch and bound algorithm. The characteristic of Figure 7. The Letting Condition Accessed in 17 Mei 2014; 01:50 pm)

Figure 8. The Statuses Tree

So the cost function is calculated with certain assumptions, the first is the we concentrate in how to make player one (O) win, the second assumption is the player one will always offensive tactic, which is creating chance in every move, and the last assumption is the opponent (X) knows how to play correctly. These assumptions are made to avoid useless move like placing in dead end position or letting the opponent wins easily. The first turn goes to first player. The figure above shows about all the statuses when first player taking middle position as the first move. From the beginning, we know that the first player cannot lose his/her control against the opponent. It means he/she cannot leave a turn without pressing the opponent to block the movement. Once the control of the game is switched, then no chance for the first player to win the game. This characteristic can be the first cost function for the branch and bound algorithm, if the opponent can make two aligned marks, regardless position, then the node will get cost equal to infinite and will not get expanded (the default cost for any branch is 0). The chance for the opponent to make an aligned two marks is still big enough because blocking non-smart fork can be a counter attack for the player who launches that fork. Figure 9. The control has switched to X (4 th turn) Accessed in 17 Mei 2014; 01:54 pm) From the figure we can also see that there is another cost function for the tic tac toe game. If in the 5 th turn the first player cannot get the fork, then the game will end tie or even worse, the first player got defeated by the opponent. This is because in the 5 th turn, there are only four tiles left and it is impossible to make fork from that condition, especially because the corner must have been taken in opposite direction. The cost functions that are listed above can also be used in other cases, regardless the first move of the first player. In the figure 8 above, it only shows all states if the first movement is center mark by the first player. If the first player places his/her mark in the corner or side tile, the cost rule still can be implemented to find the statuses tree. Figure 10. Unsuccessful Fork O (5 th turn) Accessed in 17 Mei 2014; 01:56 pm) In this paper, we just expand the tree from the centerfirst movement because that move is the one that produce many states (there is a lot of possibilities in this part), and some state cannot be reached from the other part, sidefirst move or corner-first move. This characteristic make center-first move as the main part to be analyzed and the result will be implemented into the other parts. Basically because many of the possibilities are covered in centerfirst move, the corner-first move or the side-first move will not produce any defiant result and still follow the cost function that is determined before. V. CONCLUSION There are two cost functions in tic tac toe puzzle game and used to determine the winner as fast as possible even the game does not end yet. These cost function are if the second player can strike back (counter attack), then that node s cost is set to infinite (no need to expand it anymore) and the game is declared to be tie. The second function is if in the 5 th turn the first player cannot go for fork, then the node s cost is also set to infinite and the game called as draw. VI. THANK YOU NOTE As the writer, Teofebano Kristo would like to say thank you to God because His bless and guidance to the writer so this paper can be done on time. The writer also wants to thank Mr Rinaldi Munir and Mrs Leylia Khodra for their patient and guidance to transfer the knowledge about the algorithm strategy. Also for parents that always pray for the best for the writer so this paper can be done well. And for all people around the writer that influence the process while making this paper, thanks you for all your supports.

REFERENCES [1] Zaslavsky, Claudia (1982). Tic Tac Toe: And Other Three- In-A Row Games from Ancient Egypt to the Modern Computer. [2] Steve Schaeffer (2002). Mathematical Recreations. [3] Kevin Crowley, Robert S. Siegler (1993). "Flexible Strategy Use in Young Children s Tic-Tac-Toe". Cognitive Science [4] Averbach, Bonnie; Chein, Orin (1980), Problem Solving Through Recreational Mathematics, Dover [5] http://www.coloring-page.net/game/kid-39/ Tic Tac Toe Games accessed on 17 May 2014. [6]http://www.cse.ohiotate.edu/~gurari/course/cis680/cis680Ch 20.html Branch and Bound Algorithm accessed on 17 May 2014. 04.29 pm PERNYATAAN Dengan ini saya menyatakan bahwa makalah yang saya tulis ini adalah tulisan saya sendiri, bukan saduran, atau terjemahan dari makalah orang lain, dan bukan plagiasi. Bandung, 17 Mei 2014 TTD Teofebano 13512050