SlideShare a Scribd company logo
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].
Ad

More Related Content

What's hot (20)

Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
manika kumari
 
Tic Tac Toe ppt
Tic Tac Toe pptTic Tac Toe ppt
Tic Tac Toe ppt
SanchitRastogi15
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
Ujjawal Poudel
 
Synopsis tic tac toe
Synopsis tic tac toeSynopsis tic tac toe
Synopsis tic tac toe
SYED HOZAIFA ALI
 
Tic Tac Toe
Tic Tac ToeTic Tac Toe
Tic Tac Toe
Varunjeet Singh Rekhi
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
Utkarsh Aggarwal
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
Krishna Agarwal
 
Tic tac toe simple ai game
Tic tac toe simple ai gameTic tac toe simple ai game
Tic tac toe simple ai game
Seevaratnam Kajandan
 
Tic tac toe game with graphics presentation
Tic  tac  toe game with graphics presentationTic  tac  toe game with graphics presentation
Tic tac toe game with graphics presentation
Prionto Abdullah
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AI
Manjeet Kamboj
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
pengqia chen
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
Dr. C.V. Suresh Babu
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
Dr. C.V. Suresh Babu
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
Saad Symbian
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Floyd Warshall Algorithm
Floyd Warshall AlgorithmFloyd Warshall Algorithm
Floyd Warshall Algorithm
InteX Research Lab
 
Conceptual dependency
Conceptual dependencyConceptual dependency
Conceptual dependency
Jismy .K.Jose
 
Adversarial search
Adversarial search Adversarial search
Adversarial search
Farah M. Altufaili
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
manika kumari
 
Tic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max AlgorithmTic Tac Toe using Mini Max Algorithm
Tic Tac Toe using Mini Max Algorithm
Ujjawal Poudel
 
Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
Utkarsh Aggarwal
 
Tic tac toe c++ programing
Tic tac toe c++ programingTic tac toe c++ programing
Tic tac toe c++ programing
Krishna Agarwal
 
Tic tac toe game with graphics presentation
Tic  tac  toe game with graphics presentationTic  tac  toe game with graphics presentation
Tic tac toe game with graphics presentation
Prionto Abdullah
 
BackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous
 
Monkey & banana problem in AI
Monkey & banana problem in AIMonkey & banana problem in AI
Monkey & banana problem in AI
Manjeet Kamboj
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
pengqia chen
 
Computer graphics lab report with code in cpp
Computer graphics lab report with code in cppComputer graphics lab report with code in cpp
Computer graphics lab report with code in cpp
Alamgir Hossain
 
Artificial Intelligence Searching Techniques
Artificial Intelligence Searching TechniquesArtificial Intelligence Searching Techniques
Artificial Intelligence Searching Techniques
Dr. C.V. Suresh Babu
 
Tic tac toe c++ project presentation
Tic tac toe c++ project presentationTic tac toe c++ project presentation
Tic tac toe c++ project presentation
Saad Symbian
 
daa-unit-3-greedy method
daa-unit-3-greedy methoddaa-unit-3-greedy method
daa-unit-3-greedy method
hodcsencet
 
Conceptual dependency
Conceptual dependencyConceptual dependency
Conceptual dependency
Jismy .K.Jose
 

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

Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
Sarthak Srivastava
 
Aipapercpt
AipapercptAipapercpt
Aipapercpt
Praveen Kumar
 
python.pptx
python.pptxpython.pptx
python.pptx
sreeshanthSingarapu
 
Introduction to Alphago Zero
Introduction to Alphago ZeroIntroduction to Alphago Zero
Introduction to Alphago Zero
Chia-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).pptx
AhishektttPhm
 
Games
GamesGames
Games
kalavathisugan
 
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
harmonylab
 
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-Toe
Scott 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.docx
abhi353063
 
AI Lesson 07
AI Lesson 07AI Lesson 07
AI Lesson 07
Assistant Professor
 
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
Guru Nanak Technical Institutions
 
AI- to eat boiled egg and cheese Unit-II.pptx
AI- to eat boiled egg and cheese Unit-II.pptxAI- to eat boiled egg and cheese Unit-II.pptx
AI- to eat boiled egg and cheese Unit-II.pptx
PGARMYff
 
Golf Tee Simulator 2010
Golf Tee Simulator 2010Golf Tee Simulator 2010
Golf Tee Simulator 2010
ronmajor
 
Intelligent Heuristics for the Game Isolation
Intelligent Heuristics  for the Game IsolationIntelligent Heuristics  for the Game Isolation
Intelligent Heuristics for the Game Isolation
Kory Becker
 
OthelloFinal.pptx
OthelloFinal.pptxOthelloFinal.pptx
OthelloFinal.pptx
NikolaiBelokonenko
 
Min-Max algorithm
Min-Max algorithmMin-Max algorithm
Min-Max algorithm
Dr. C.V. Suresh Babu
 
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
Srinath Perera
 
AlphaGo and AlphaGo Zero
AlphaGo and AlphaGo ZeroAlphaGo and AlphaGo Zero
AlphaGo and AlphaGo Zero
☕ Keita Watanabe
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
NayanChandak1
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
Sarthak Srivastava
 
Introduction to Alphago Zero
Introduction to Alphago ZeroIntroduction to Alphago Zero
Introduction to Alphago Zero
Chia-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).pptx
AhishektttPhm
 
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
harmonylab
 
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-Toe
Scott 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.docx
abhi353063
 
AI- to eat boiled egg and cheese Unit-II.pptx
AI- to eat boiled egg and cheese Unit-II.pptxAI- to eat boiled egg and cheese Unit-II.pptx
AI- to eat boiled egg and cheese Unit-II.pptx
PGARMYff
 
Golf Tee Simulator 2010
Golf Tee Simulator 2010Golf Tee Simulator 2010
Golf Tee Simulator 2010
ronmajor
 
Intelligent Heuristics for the Game Isolation
Intelligent Heuristics  for the Game IsolationIntelligent Heuristics  for the Game Isolation
Intelligent Heuristics for the Game Isolation
Kory 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 CEP
Srinath Perera
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
NayanChandak1
 
Ad

Recently uploaded (20)

Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
Odoo ERP for Education Management to Streamline Your Education Process
Odoo ERP for Education Management to Streamline Your Education ProcessOdoo ERP for Education Management to Streamline Your Education Process
Odoo ERP for Education Management to Streamline Your Education Process
iVenture Team LLP
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Foundation Models for Time Series : A Survey
Foundation Models for Time Series : A SurveyFoundation Models for Time Series : A Survey
Foundation Models for Time Series : A Survey
jayanthkalyanam1
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
PRTG Network Monitor Crack Latest Version & Serial Key 2025 [100% Working]
saimabibi60507
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Innovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at allInnovative Approaches to Software Dev no good at all
Innovative Approaches to Software Dev no good at all
ayeshakanwal75
 
Odoo ERP for Education Management to Streamline Your Education Process
Odoo ERP for Education Management to Streamline Your Education ProcessOdoo ERP for Education Management to Streamline Your Education Process
Odoo ERP for Education Management to Streamline Your Education Process
iVenture Team LLP
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
How to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud PerformanceHow to Optimize Your AWS Environment for Improved Cloud Performance
How to Optimize Your AWS Environment for Improved Cloud Performance
ThousandEyes
 
Foundation Models for Time Series : A Survey
Foundation Models for Time Series : A SurveyFoundation Models for Time Series : A Survey
Foundation Models for Time Series : A Survey
jayanthkalyanam1
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Download YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full ActivatedDownload YouTube By Click 2025 Free Full Activated
Download YouTube By Click 2025 Free Full Activated
saniamalik72555
 
Ad

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].