Artificial Intelligence- TicTacToe game

7,375 views 12 slides Apr 23, 2019
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

Tic-Tac-Toe game using MINIMAX algorithm


Slide Content

ARTIFICIAL INTELLIGENCE TIC-TAC-TOE Game Name : Manika kumari Roll no . : MT/CS/10006/18 Guided by : Dr.Sanchita Paul

Introduction TIC-TAC-TOE Game Two player game – X and O X and O, who take turns mark the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game .

Initial State Initially all 1 to 9 places of 3x3 grid are empty 1 4 5 3 6 7 8 9 2

Goal State PLAYER X WIN 3 X’s in a column , row or diagonal PLAYER O WIN 3 O’s in a column , row or diagonal DRAW X O O X X O X O O O X X X X O O X O X O

Winning Conditions X X X X X X X X X X X X X X X X X X X X X X X X

State Space Tree 9 possibilities X X X X X X X X O O O O 8 possibilities X O X O X O X O X O X X X X X

MINIMAX Approach Minimax is a recursive algorithm which is used to choose an optimal move for a player assuming that the other player is also playing optimally. Initial state : Initial position of the board/grid . Successor function : I defines what the legal moves from any position Terminal state : I position of the board when the game gets over. Utility function : I function which assigns a numeric value for the outcome of a game . For instance, in tic-tac-toe, the outcome is either a win, a loss, or a draw, and these can be represented by the values +1, -1, or 0, respectively .

A Minimax algorithm can be best defined as a recursive function that does the following things: return a value if a terminal state is found (+1, 0, -1) go through available spots on the board call the minimax function on each available spot (recursion) evaluate returning values from function calls and return the best value

Python Implementation of TIC-TAC-TOE