SlideShare a Scribd company logo
1 of 20
Tic Tac Toe Genius
Artificial Intelligence (CU6051)
Submitted by: Submitted to:
Arjun Gurung (14046958) Mr. Sukant Kumar Sahu
Kiran Shahi (14046931) Module Leader
Date: 19th January, 2017
Aims And Objectives:
1. Introduction of the topic.
2. Current Scenario
3. System Functionality
4. Algorithm
5. Pseudocode
6. Future Enhancement
7. Reference
Introduction
Tic Tac Toe, very popular and easy to play.
Two players game.
3x3 grid most commonly used.
A paper and pen based game.
Why Tic Tac Toe
Rules for tic tac toe game is simple enough that we don't need an
elaborate analysis of game configurations.
Despite being a simple game, the basic AI principles shown here can be
applied to more complicated games such as checkers, Go and even
chess.
Present Scenario
• Many versions of tic tac toe like 3x3, 4x4 and even 9x9.
• Can be made on various platforms like Python, Java, C and even
JavaScript Canvas.
• Not so complex architecture.
Program Flow of Tic Tac Toe Genius
Start
Check
winning
point
Check
corner
space
Check
winning
move
for User
Check
Center
Check
diagona
l for (X)
Check
Side
Check
diagona
l for (0)
Take
move
Take move
Take move
Take move
Take move
Ask
User
to
take
move
System
wins
User
wins
Game is
draw
End
NO Yes
Yes
Yes
Yes
Yes
NO
NO
Yes
Yes
NO
NO
NO
NO
Functionality
• How to play Tic-Tac-Toe game?
• Some guiding steps to play the game are:
• The game is played between two players
• Both players choose their respective symbols to mark
• Player 1 starts the turn by placing his/her symbol on any of the nine squares
• Then player 2 marks the turn by placing his/her symbol on the empty squares
• Both players make their turns alternately
• If any player gets the three respective symbols in a horizontal, vertical or
diagonal row wins the game
Functionality
Winning Combinations in game:
In a tic-tac-toe game there are 8 possibilities to win the game. The
possibilities are getting the three combinations horizontally, three
combinations vertically or two combinations diagonally as shown in the
figure below. Hence, the easiest way to find the way to determine the
winner of the game is to check for these eight combinations as the
game goes on.
Functionality
Winning Combinations in game:
Game Strategies
• Win: If you have two in a row, play the third to get three in a row.
• Block: If the opponent has two in a row, play the third to block them.
• Fork: Create an opportunity where you can win in two ways.
• Block Opponent's Fork:
• Option 1: Create two in a row to force the opponent into defending, as long as it doesn't
result in them creating a fork or winning. For example, if "X" has a corner, "O" has the
centre, and "X" has the opposite corner as well, "O" must not play a corner in order to
win. (Playing a corner in this scenario creates a fork for "X" to win.)
• Option 2: If there is a configuration where the opponent can fork, block that fork.
• Centre: Play the centre.
• Opposite Corner: If the opponent is in the corner, play the opposite corner.
• Empty Corner: Play an empty corner.
• Empty Side: Play an empty side.
Algorithm Chosen
Mini-Max Algorithm
• Best suited for game with 2 player.
• To find a path from the starting position to a goal position.
• Calculate all possible game states by examining all opposing moves.
• Determine the next move against best play [opponent].
Game tree of Tic Tac Toe
Algorithm
• Step 1: START
• Step 2: Check winning move for system (X). If there is such move, take it and
go to Step 7. Else go to Step 3.
• Step 3: Check wining move for user (O). It there is such move, then block the
player and go to Step 7. Else go to Step 4.
• Step 4: If there are corner spaces (i.e. 1, 3, 7, 9), take it and go to Step 7.
Else go to Step 5.
• Step 5: If there is center position, take it and go to step 7. Else go to Step 6.
• Step 6: If there are side positions (i.e. 2,4,6,8), take it and go to Step 7. Else
go to step 8. (Since there are no spaces left to move.)
• Step 7: Ask user to take a move and go to step 2.
Algorithm
• Step 8: Check system move (X) is in a vertical/horizontal/diagonal form.
If it is there the system will win. And go to step 11. Else go to step 9.
• Step 9: Check user’s move (O) is in a vertical/horizontal/diagonal form. If
it is there the system will lose. And go to step 11. Else go to step 10.
• Step 10: Game is draw and go to step 11:
• Step 11: END
Pseudocode
Find the path
CALL minimax
DO
GET available move
IF available move is
winning move
SET move to
available move
READ move
from User
ELSE IF available move is
winning move for User
SET move to
available move
READ move from
User
ELSE IF available move is
corner spaces
SET move to
available move
READ move from
User
ELSE IF available move is
centre space
SET move to available
move
READ move from User
ELSE IF available move is side
space
SET move to available
space
READ move from User
ELSE
CALL Check Result
END IF
END DO
Pseudocode
CheckScore
CALL checkScore
DO
IF System wins
Return 1
ElSE IF User wins
Return -1
ELSE
Return 0
END IF
END DO
CALL Check Result
DO
IF System move (X) is
diagonal
SET result win
CALL Check Score
ELSE IF User move (0) is
in diagonal
SET result lose
CALL Check Score
ELSE
SET result draw
CALL Check Score
END IF
END DO
Further Enhancement
• More number of winning strategies.
• Implementation of MINMAX algorithm into other games such as
checker, Go and even chess.
• Use of other Algorithms like Heuristic Search(BFS and DFS)
Conclusion
• An AI based game ‘Toc Tac Toe Genius’.
• Very popular and Entertaining.
• Not so complex use of Algorithm and Pseudocode.
• Number of possible winning combinations like horizontal, vertical and
Diagonal.
Any Questions?
References
• Tic-tac-toe AI - Java Game Programming Case Study. 2017. Tic-tac-toe AI - Java Game
Programming Case Study. [ONLINE] Available at:
https://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe_AI.html. [Accessed
10 January 2017].
• Jason Fox. 2017. Tic Tac Toe: Understanding The Minimax Algorithm. [ONLINE] Available at:
http://neverstopbuilding.com/minimax. [Accessed 11 January 2017].
• How to use Minimax's algorithm to make a Tic-Tac-Toe - Quora. 2017. How to use Minimax's
algorithm to make a Tic-Tac-Toe - Quora. [ONLINE] Available at: https://www.quora.com/How-do-I-
use-Minimaxs-algorithm-to-make-a-Tic-Tac-Toe. [Accessed 10 January 2017].
• The Ludologist. 2017. 255,168 ways of playing Tic Tac Toe – The Ludologist. [ONLINE] Available at:
https://www.jesperjuul.net/ludologist/255168-ways-of-playing-tic-tac-toe. [Accessed 6 January
2017].

More Related Content

What's hot

AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemMohammad Imam Hossain
 
Adversarial search
Adversarial searchAdversarial search
Adversarial searchNilu Desai
 
project on snake game in c language
project on snake game in c languageproject on snake game in c language
project on snake game in c languageAshutosh Kumar
 
Genetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceGenetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceSahil Kumar
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac ToeSarthak Srivastava
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligencelordmwesh
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligencesandeep54552
 
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...JayaramB11
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesSamiaAziz4
 
First Order Logic resolution
First Order Logic resolutionFirst Order Logic resolution
First Order Logic resolutionAmar Jukuntla
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AIManjeet Kamboj
 

What's hot (20)

AI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction ProblemAI 7 | Constraint Satisfaction Problem
AI 7 | Constraint Satisfaction Problem
 
Adversarial search
Adversarial searchAdversarial search
Adversarial search
 
project on snake game in c language
project on snake game in c languageproject on snake game in c language
project on snake game in c language
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
A* Search Algorithm
A* Search AlgorithmA* Search Algorithm
A* Search Algorithm
 
Genetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial IntelligenceGenetic Algorithms - Artificial Intelligence
Genetic Algorithms - Artificial Intelligence
 
AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)AI Lecture 3 (solving problems by searching)
AI Lecture 3 (solving problems by searching)
 
A* algorithm
A* algorithmA* algorithm
A* algorithm
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
 
Game Playing in Artificial Intelligence
Game Playing in Artificial IntelligenceGame Playing in Artificial Intelligence
Game Playing in Artificial Intelligence
 
Adversarial search
Adversarial search Adversarial search
Adversarial search
 
Hill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligenceHill climbing algorithm in artificial intelligence
Hill climbing algorithm in artificial intelligence
 
tic-tac-toe: Game playing
 tic-tac-toe: Game playing tic-tac-toe: Game playing
tic-tac-toe: Game playing
 
Backtracking
Backtracking  Backtracking
Backtracking
 
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...
Kevin Knight, Elaine Rich, B. Nair - Artificial Intelligence (2010, Tata McGr...
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
 
Min-Max algorithm
Min-Max algorithmMin-Max algorithm
Min-Max algorithm
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
First Order Logic resolution
First Order Logic resolutionFirst Order Logic resolution
First Order Logic resolution
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AI
 

Similar to AI based Tic Tac Toe game using Minimax Algorithm

Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ projectUtkarsh Aggarwal
 
Introduction to Alphago Zero
Introduction to Alphago ZeroIntroduction to Alphago Zero
Introduction to Alphago ZeroChia-Ching Lin
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptxAhishektttPhm
 
Study on Evaluation Function Design of Mahjong using Supervised Learning
Study on Evaluation Function Design of Mahjong using Supervised LearningStudy on Evaluation Function Design of Mahjong using Supervised Learning
Study on Evaluation Function Design of Mahjong using Supervised Learningharmonylab
 
Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Thinkful
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeScott Wlaschin
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxabhi353063
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAsst.prof M.Gokilavani
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programingKrishna Agarwal
 
Golf Tee Simulator 2010
Golf Tee Simulator 2010Golf Tee Simulator 2010
Golf Tee Simulator 2010ronmajor
 
Intelligent Heuristics for the Game Isolation
Intelligent Heuristics  for the Game IsolationIntelligent Heuristics  for the Game Isolation
Intelligent Heuristics for the Game IsolationKory Becker
 
Analyzing a Soccer Game with WSO2 CEP
Analyzing a Soccer Game with WSO2 CEPAnalyzing a Soccer Game with WSO2 CEP
Analyzing a Soccer Game with WSO2 CEPSrinath Perera
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxNayanChandak1
 
Snake game implementation in c
Snake game implementation in cSnake game implementation in c
Snake game implementation in cUpendra Sengar
 

Similar to AI based Tic Tac Toe game using Minimax Algorithm (20)

Aipapercpt
AipapercptAipapercpt
Aipapercpt
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Introduction to Alphago Zero
Introduction to Alphago ZeroIntroduction to Alphago Zero
Introduction to Alphago Zero
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx
 
Games
GamesGames
Games
 
Study on Evaluation Function Design of Mahjong using Supervised Learning
Study on Evaluation Function Design of Mahjong using Supervised LearningStudy on Evaluation Function Design of Mahjong using Supervised Learning
Study on Evaluation Function Design of Mahjong using Supervised Learning
 
Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)Build tic tac toe with javascript (3:28)
Build tic tac toe with javascript (3:28)
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
 
This is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docxThis is an individual project, to be completed on your own. It i.docx
This is an individual project, to be completed on your own. It i.docx
 
AI Lesson 07
AI Lesson 07AI Lesson 07
AI Lesson 07
 
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdfAI3391 Artificial Intelligence UNIT III Notes_merged.pdf
AI3391 Artificial Intelligence UNIT III Notes_merged.pdf
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
 
Golf Tee Simulator 2010
Golf Tee Simulator 2010Golf Tee Simulator 2010
Golf Tee Simulator 2010
 
Intelligent Heuristics for the Game Isolation
Intelligent Heuristics  for the Game IsolationIntelligent Heuristics  for the Game Isolation
Intelligent Heuristics for the Game Isolation
 
OthelloFinal.pptx
OthelloFinal.pptxOthelloFinal.pptx
OthelloFinal.pptx
 
Analyzing a Soccer Game with WSO2 CEP
Analyzing a Soccer Game with WSO2 CEPAnalyzing a Soccer Game with WSO2 CEP
Analyzing a Soccer Game with WSO2 CEP
 
AlphaGo and AlphaGo Zero
AlphaGo and AlphaGo ZeroAlphaGo and AlphaGo Zero
AlphaGo and AlphaGo Zero
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
 
Snake game implementation in c
Snake game implementation in cSnake game implementation in c
Snake game implementation in c
 

Recently uploaded

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Recently uploaded (20)

What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

AI based Tic Tac Toe game using Minimax Algorithm

  • 1. Tic Tac Toe Genius Artificial Intelligence (CU6051) Submitted by: Submitted to: Arjun Gurung (14046958) Mr. Sukant Kumar Sahu Kiran Shahi (14046931) Module Leader Date: 19th January, 2017
  • 2. Aims And Objectives: 1. Introduction of the topic. 2. Current Scenario 3. System Functionality 4. Algorithm 5. Pseudocode 6. Future Enhancement 7. Reference
  • 3. Introduction Tic Tac Toe, very popular and easy to play. Two players game. 3x3 grid most commonly used. A paper and pen based game.
  • 4. Why Tic Tac Toe Rules for tic tac toe game is simple enough that we don't need an elaborate analysis of game configurations. Despite being a simple game, the basic AI principles shown here can be applied to more complicated games such as checkers, Go and even chess.
  • 5. Present Scenario • Many versions of tic tac toe like 3x3, 4x4 and even 9x9. • Can be made on various platforms like Python, Java, C and even JavaScript Canvas. • Not so complex architecture.
  • 6. Program Flow of Tic Tac Toe Genius Start Check winning point Check corner space Check winning move for User Check Center Check diagona l for (X) Check Side Check diagona l for (0) Take move Take move Take move Take move Take move Ask User to take move System wins User wins Game is draw End NO Yes Yes Yes Yes Yes NO NO Yes Yes NO NO NO NO
  • 7. Functionality • How to play Tic-Tac-Toe game? • Some guiding steps to play the game are: • The game is played between two players • Both players choose their respective symbols to mark • Player 1 starts the turn by placing his/her symbol on any of the nine squares • Then player 2 marks the turn by placing his/her symbol on the empty squares • Both players make their turns alternately • If any player gets the three respective symbols in a horizontal, vertical or diagonal row wins the game
  • 8. Functionality Winning Combinations in game: In a tic-tac-toe game there are 8 possibilities to win the game. The possibilities are getting the three combinations horizontally, three combinations vertically or two combinations diagonally as shown in the figure below. Hence, the easiest way to find the way to determine the winner of the game is to check for these eight combinations as the game goes on.
  • 10. Game Strategies • Win: If you have two in a row, play the third to get three in a row. • Block: If the opponent has two in a row, play the third to block them. • Fork: Create an opportunity where you can win in two ways. • Block Opponent's Fork: • Option 1: Create two in a row to force the opponent into defending, as long as it doesn't result in them creating a fork or winning. For example, if "X" has a corner, "O" has the centre, and "X" has the opposite corner as well, "O" must not play a corner in order to win. (Playing a corner in this scenario creates a fork for "X" to win.) • Option 2: If there is a configuration where the opponent can fork, block that fork. • Centre: Play the centre. • Opposite Corner: If the opponent is in the corner, play the opposite corner. • Empty Corner: Play an empty corner. • Empty Side: Play an empty side.
  • 11. Algorithm Chosen Mini-Max Algorithm • Best suited for game with 2 player. • To find a path from the starting position to a goal position. • Calculate all possible game states by examining all opposing moves. • Determine the next move against best play [opponent].
  • 12. Game tree of Tic Tac Toe
  • 13. Algorithm • Step 1: START • Step 2: Check winning move for system (X). If there is such move, take it and go to Step 7. Else go to Step 3. • Step 3: Check wining move for user (O). It there is such move, then block the player and go to Step 7. Else go to Step 4. • Step 4: If there are corner spaces (i.e. 1, 3, 7, 9), take it and go to Step 7. Else go to Step 5. • Step 5: If there is center position, take it and go to step 7. Else go to Step 6. • Step 6: If there are side positions (i.e. 2,4,6,8), take it and go to Step 7. Else go to step 8. (Since there are no spaces left to move.) • Step 7: Ask user to take a move and go to step 2.
  • 14. Algorithm • Step 8: Check system move (X) is in a vertical/horizontal/diagonal form. If it is there the system will win. And go to step 11. Else go to step 9. • Step 9: Check user’s move (O) is in a vertical/horizontal/diagonal form. If it is there the system will lose. And go to step 11. Else go to step 10. • Step 10: Game is draw and go to step 11: • Step 11: END
  • 15. Pseudocode Find the path CALL minimax DO GET available move IF available move is winning move SET move to available move READ move from User ELSE IF available move is winning move for User SET move to available move READ move from User ELSE IF available move is corner spaces SET move to available move READ move from User ELSE IF available move is centre space SET move to available move READ move from User ELSE IF available move is side space SET move to available space READ move from User ELSE CALL Check Result END IF END DO
  • 16. Pseudocode CheckScore CALL checkScore DO IF System wins Return 1 ElSE IF User wins Return -1 ELSE Return 0 END IF END DO CALL Check Result DO IF System move (X) is diagonal SET result win CALL Check Score ELSE IF User move (0) is in diagonal SET result lose CALL Check Score ELSE SET result draw CALL Check Score END IF END DO
  • 17. Further Enhancement • More number of winning strategies. • Implementation of MINMAX algorithm into other games such as checker, Go and even chess. • Use of other Algorithms like Heuristic Search(BFS and DFS)
  • 18. Conclusion • An AI based game ‘Toc Tac Toe Genius’. • Very popular and Entertaining. • Not so complex use of Algorithm and Pseudocode. • Number of possible winning combinations like horizontal, vertical and Diagonal.
  • 20. References • Tic-tac-toe AI - Java Game Programming Case Study. 2017. Tic-tac-toe AI - Java Game Programming Case Study. [ONLINE] Available at: https://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe_AI.html. [Accessed 10 January 2017]. • Jason Fox. 2017. Tic Tac Toe: Understanding The Minimax Algorithm. [ONLINE] Available at: http://neverstopbuilding.com/minimax. [Accessed 11 January 2017]. • How to use Minimax's algorithm to make a Tic-Tac-Toe - Quora. 2017. How to use Minimax's algorithm to make a Tic-Tac-Toe - Quora. [ONLINE] Available at: https://www.quora.com/How-do-I- use-Minimaxs-algorithm-to-make-a-Tic-Tac-Toe. [Accessed 10 January 2017]. • The Ludologist. 2017. 255,168 ways of playing Tic Tac Toe – The Ludologist. [ONLINE] Available at: https://www.jesperjuul.net/ludologist/255168-ways-of-playing-tic-tac-toe. [Accessed 6 January 2017].