SlideShare a Scribd company logo
1 of 24
tic- tac- toe in python
(using minimax algorithm)
PRESENTED BY:
ABDUS SUBHAN
1CR20EC003
AADITHYA D KUMAR
1CR20EC002
ABHISHEK KUMAR SINGH
1CR20EC006
Project Advisor :
PROF. JYOTI M.R.
Pre-requisites
 Python compiler
 Python programming
 Minimax Algorithm in Game Theory
strategy
1
 Optimal strategy for player X. In each grid, the shaded red X denotes the optimal move, and
the location of O's next move gives the next subgrid to examine. Note that only two sequences
of moves by O (both starting with center, top-right, left-mid) lead to a draw, with the remaining
sequences leading to wins from X.
A player can play perfect tic-tac-toe (win or draw) given they choose the first possible move
from the following list.
Win: If the player has two in a row, he or she can place a third to get three in a row.
Block: If the [opponent] has two in a row, the player must play the third himself or herself to
block them.
Fork: Creation of an opportunity where the player has two threats to win (two non-blocked lines
of 2).
strategy
1
 Blocking an opponent's fork:
Option 1: The player should create two in a row to force the opponent into defending, as
long as it doesn't result in them creating a fork. For example, if "X" has a corner, "O" has the
center, 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, the player should block
that fork.
Center: A player marks the center. (If it is the first move of the game, playing on a corner
gives "O" more opportunities to make a mistake and may therefore be the better choice;
however, it makes no difference between perfect players.)
Opposite corner: If the opponent is in the corner, the player plays the opposite corner.
introduction
1
 Because of the simplicity of tic-tac-toe, it is often used as a pedagogical
tool for teaching the concepts of good sportsmanship and the branch
of artificial intelligence that deals with the searching of game trees. It
is straightforward to write a computer program to play tic-tac-toe
perfectly or to enumerate the 765 essentially different positions (the
state space complexity) or the 26,830 possible games up to rotations
and reflections (the game tree complexity) on this space. If played
optimally by both players, the game always ends in a draw, making tic-
tac-toe a futile game.
The Minimax Algorithm
1
 Minimax Algorithm is a decision rule formulated for two player zero-
sum games (Tic-Tac-Toe, Chess, Go, etc.).
 This algorithm sees a few steps ahead and puts itself in the shoes of its
opponent. It keeps playing and exploring subsequent possible states until
it reaches a terminal state resulting in a draw, a win, or a loss.
 Being in any of these possible terminal states has some utility for the AI
— such as being in a ‘Win’ state is good (utility is positive), being in a ‘Loss’
state is bad (utility is negative), and being in a draw in neither good nor
bad (utility is neutral).
algorithm
 In our execution of the Minimax algorithm for solving Tic-Tac-Toe, it
works by visualizing all future possible states of the board and
constructs it in the form of a tree. When the current board state is given
to the algorithm (the root of the tree), it splits into ’n’ branches (where
n denotes the number of moves that can be chosen by the AI/number
of empty cells where the AI can be placed). If any of these new states is
a terminal state, no further splits are performed for this state and it is
assigned a score the following way:
 Score = +1 (if AI wins) Score = -1 (if AI loses) Score= 0 (If a draw happens)
6
Architecture
3
9/28/2023
Pre-Requisite Before Coding
9/28/2023
Board
Display board
Play game
Check win:
1)Row win
2)Column win
3)Diagonal win
Check tie
Flip player
CODE
9/28/2023
9/28/2023
9/28/2023
9/28/2023
9/28/2023
9/28/2023
OUTPUT 1 (Row win)
9/28/2023
OUTPUT 2 (Column win)
9/28/2023
OUTPUT 3 (Diagonal win)
9/28/2023
OUTPUT 4 (Invalid inputs)
9/28/2023
APplications
1
Various game shows have been based on Tic-Tac-Toe and its variants:
On Hollywood Squares, nine celebrities filled the cells of the tic-tac-toe grid; players
put symbols on the board by correctly agreeing or disagreeing with a celebrity's
answer to a question. Variations of the show include Storybook Squares and Hip Hop
Squares.
In Tic-Tac-Dough, players put symbols up on the board by answering questions in
various categories, which shuffle after each player's turn.
In Beat the Teacher, contestants answer questions to win a turn to influence a tic-tac-
toe grid.
limitations
 The game cannot be played by more than one players.
 It is not a high level game.
 It doesn’t contain levels.
7
References
 https://youtu.be/BHh654_7Cmw
 Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI – Finding optimal
move)- Geeks for Geeks
https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3-
tic-tac-toe-ai-finding-optimal-move/
 Tic Tac Toe AI with MiniMax using Python | Part 1: Programming Tic Tac Toe-
YouTube
https://www.youtube.com/watch?v=JC1QsLOXp-I
 Tic Tac Toe AI with MiniMax using Python | Part 2: Minimax- YouTube
https://www.youtube.com/watch?v=2Tr8LkyU78c 7
Thank You
24

More Related Content

Similar to 0-miniproject sem 4 review 1(1)(2).pptx

AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmKiran Shahi
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac ToeSarthak Srivastava
 
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
 
Unit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).pptUnit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).pptganesh15478
 
Please follow the data 1) For Line 23 In the IF - Condition yo.pdf
Please follow the data 1) For Line 23 In the IF - Condition yo.pdfPlease follow the data 1) For Line 23 In the IF - Condition yo.pdf
Please follow the data 1) For Line 23 In the IF - Condition yo.pdfinfo382133
 
AI Strategies for Solving Poker Texas Hold'em
AI Strategies for Solving Poker Texas Hold'emAI Strategies for Solving Poker Texas Hold'em
AI Strategies for Solving Poker Texas Hold'emGiovanni Murru
 
C++ projct
C++ projctC++ projct
C++ projctJ M
 
International journal of engineering issues vol 2015 - no 2 - paper1
International journal of engineering issues   vol 2015 - no 2 - paper1International journal of engineering issues   vol 2015 - no 2 - paper1
International journal of engineering issues vol 2015 - no 2 - paper1sophiabelthome
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial SearchMegha Sharma
 
AI_Session 13 Adversarial Search .pptx
AI_Session 13 Adversarial Search .pptxAI_Session 13 Adversarial Search .pptx
AI_Session 13 Adversarial Search .pptxAsst.prof M.Gokilavani
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAMEMONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAMEijscai
 
Monte-Carlo Tree Search For The "Mr Jack" Board Game
Monte-Carlo Tree Search For The "Mr Jack" Board Game Monte-Carlo Tree Search For The "Mr Jack" Board Game
Monte-Carlo Tree Search For The "Mr Jack" Board Game IJSCAI Journal
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME ijscai
 
Monte carlo tree search for the
Monte carlo tree search for theMonte carlo tree search for the
Monte carlo tree search for theijscai
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME ijscai
 

Similar to 0-miniproject sem 4 review 1(1)(2).pptx (20)

python.pptx
python.pptxpython.pptx
python.pptx
 
AI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax AlgorithmAI based Tic Tac Toe game using Minimax Algorithm
AI based Tic Tac Toe game using Minimax Algorithm
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
 
quarto
quartoquarto
quarto
 
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
 
Unit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).pptUnit_I_Introduction(Part_III).ppt
Unit_I_Introduction(Part_III).ppt
 
Aipapercpt
AipapercptAipapercpt
Aipapercpt
 
Please follow the data 1) For Line 23 In the IF - Condition yo.pdf
Please follow the data 1) For Line 23 In the IF - Condition yo.pdfPlease follow the data 1) For Line 23 In the IF - Condition yo.pdf
Please follow the data 1) For Line 23 In the IF - Condition yo.pdf
 
AI Strategies for Solving Poker Texas Hold'em
AI Strategies for Solving Poker Texas Hold'emAI Strategies for Solving Poker Texas Hold'em
AI Strategies for Solving Poker Texas Hold'em
 
C++ projct
C++ projctC++ projct
C++ projct
 
Libratus
LibratusLibratus
Libratus
 
Tic Tac Toe ppt
Tic Tac Toe pptTic Tac Toe ppt
Tic Tac Toe ppt
 
International journal of engineering issues vol 2015 - no 2 - paper1
International journal of engineering issues   vol 2015 - no 2 - paper1International journal of engineering issues   vol 2015 - no 2 - paper1
International journal of engineering issues vol 2015 - no 2 - paper1
 
Adversarial Search
Adversarial SearchAdversarial Search
Adversarial Search
 
AI_Session 13 Adversarial Search .pptx
AI_Session 13 Adversarial Search .pptxAI_Session 13 Adversarial Search .pptx
AI_Session 13 Adversarial Search .pptx
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAMEMONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
 
Monte-Carlo Tree Search For The "Mr Jack" Board Game
Monte-Carlo Tree Search For The "Mr Jack" Board Game Monte-Carlo Tree Search For The "Mr Jack" Board Game
Monte-Carlo Tree Search For The "Mr Jack" Board Game
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
 
Monte carlo tree search for the
Monte carlo tree search for theMonte carlo tree search for the
Monte carlo tree search for the
 
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
MONTE-CARLO TREE SEARCH FOR THE “MR JACK” BOARD GAME
 

Recently uploaded

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesSHIVANANDaRV
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17Celine George
 

Recently uploaded (20)

Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 

0-miniproject sem 4 review 1(1)(2).pptx

  • 1. tic- tac- toe in python (using minimax algorithm) PRESENTED BY: ABDUS SUBHAN 1CR20EC003 AADITHYA D KUMAR 1CR20EC002 ABHISHEK KUMAR SINGH 1CR20EC006 Project Advisor : PROF. JYOTI M.R.
  • 2. Pre-requisites  Python compiler  Python programming  Minimax Algorithm in Game Theory
  • 3. strategy 1  Optimal strategy for player X. In each grid, the shaded red X denotes the optimal move, and the location of O's next move gives the next subgrid to examine. Note that only two sequences of moves by O (both starting with center, top-right, left-mid) lead to a draw, with the remaining sequences leading to wins from X. A player can play perfect tic-tac-toe (win or draw) given they choose the first possible move from the following list. Win: If the player has two in a row, he or she can place a third to get three in a row. Block: If the [opponent] has two in a row, the player must play the third himself or herself to block them. Fork: Creation of an opportunity where the player has two threats to win (two non-blocked lines of 2).
  • 4. strategy 1  Blocking an opponent's fork: Option 1: The player should create two in a row to force the opponent into defending, as long as it doesn't result in them creating a fork. For example, if "X" has a corner, "O" has the center, 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, the player should block that fork. Center: A player marks the center. (If it is the first move of the game, playing on a corner gives "O" more opportunities to make a mistake and may therefore be the better choice; however, it makes no difference between perfect players.) Opposite corner: If the opponent is in the corner, the player plays the opposite corner.
  • 5. introduction 1  Because of the simplicity of tic-tac-toe, it is often used as a pedagogical tool for teaching the concepts of good sportsmanship and the branch of artificial intelligence that deals with the searching of game trees. It is straightforward to write a computer program to play tic-tac-toe perfectly or to enumerate the 765 essentially different positions (the state space complexity) or the 26,830 possible games up to rotations and reflections (the game tree complexity) on this space. If played optimally by both players, the game always ends in a draw, making tic- tac-toe a futile game.
  • 6. The Minimax Algorithm 1  Minimax Algorithm is a decision rule formulated for two player zero- sum games (Tic-Tac-Toe, Chess, Go, etc.).  This algorithm sees a few steps ahead and puts itself in the shoes of its opponent. It keeps playing and exploring subsequent possible states until it reaches a terminal state resulting in a draw, a win, or a loss.  Being in any of these possible terminal states has some utility for the AI — such as being in a ‘Win’ state is good (utility is positive), being in a ‘Loss’ state is bad (utility is negative), and being in a draw in neither good nor bad (utility is neutral).
  • 7. algorithm  In our execution of the Minimax algorithm for solving Tic-Tac-Toe, it works by visualizing all future possible states of the board and constructs it in the form of a tree. When the current board state is given to the algorithm (the root of the tree), it splits into ’n’ branches (where n denotes the number of moves that can be chosen by the AI/number of empty cells where the AI can be placed). If any of these new states is a terminal state, no further splits are performed for this state and it is assigned a score the following way:  Score = +1 (if AI wins) Score = -1 (if AI loses) Score= 0 (If a draw happens) 6
  • 10. Pre-Requisite Before Coding 9/28/2023 Board Display board Play game Check win: 1)Row win 2)Column win 3)Diagonal win Check tie Flip player
  • 17. OUTPUT 1 (Row win) 9/28/2023
  • 18. OUTPUT 2 (Column win) 9/28/2023
  • 19. OUTPUT 3 (Diagonal win) 9/28/2023
  • 20. OUTPUT 4 (Invalid inputs) 9/28/2023
  • 21. APplications 1 Various game shows have been based on Tic-Tac-Toe and its variants: On Hollywood Squares, nine celebrities filled the cells of the tic-tac-toe grid; players put symbols on the board by correctly agreeing or disagreeing with a celebrity's answer to a question. Variations of the show include Storybook Squares and Hip Hop Squares. In Tic-Tac-Dough, players put symbols up on the board by answering questions in various categories, which shuffle after each player's turn. In Beat the Teacher, contestants answer questions to win a turn to influence a tic-tac- toe grid.
  • 22. limitations  The game cannot be played by more than one players.  It is not a high level game.  It doesn’t contain levels. 7
  • 23. References  https://youtu.be/BHh654_7Cmw  Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI – Finding optimal move)- Geeks for Geeks https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3- tic-tac-toe-ai-finding-optimal-move/  Tic Tac Toe AI with MiniMax using Python | Part 1: Programming Tic Tac Toe- YouTube https://www.youtube.com/watch?v=JC1QsLOXp-I  Tic Tac Toe AI with MiniMax using Python | Part 2: Minimax- YouTube https://www.youtube.com/watch?v=2Tr8LkyU78c 7