Skip to content

Latest commit

 

History

History
87 lines (45 loc) · 3.22 KB

README.md

File metadata and controls

87 lines (45 loc) · 3.22 KB

Tic Tac Toe

Tic Tac Toe is a Flutter apllication which is made using BackTracking MinMax algorithm.

MinMax algorithm:

  1. Finding the Best Move :

We shall be introducing a new function called findBestMove(). This function evaluates all the available moves using minimax() and then returns the best move the maximizer can make. The pseudocode is as follows :

function findBestMove(board): bestMove = NULL for each move in board : if current move is better than bestMove bestMove = current move return bestMove

  1. Minimax :

To check whether or not the current move is better than the best move we take the help of minimax() function which will consider all the possible ways the game can go and returns the best value for that move, assuming the opponent also plays optimally The code for the maximizer and minimizer in the minimax() function is similar to findBestMove() , the only difference is, instead of returning a move, it will return a value. Here is the pseudocode :

function minimax(board, depth, isMaximizingPlayer):

if current board state is a terminal state :
    return value of the board

if isMaximizingPlayer :
    bestVal = -INFINITY 
    for each move in board :
        value = minimax(board, depth+1, false)
        bestVal = max( bestVal, value) 
    return bestVal

else :
    bestVal = +INFINITY 
    for each move in board :
        value = minimax(board, depth+1, true)
        bestVal = min( bestVal, value) 
    return bestVal

Application ScreenShots

Splash Screen

Screenshot_2021-05-27-23-54-28-472_com android chrome

Home Page

Screenshot_2021-05-27-23-54-33-176_com android chrome

Game Play

Screenshot_2021-05-27-23-54-45-109_com android chrome Screenshot_2021-05-27-23-54-53-518_com android chrome Screenshot_2021-05-27-23-54-57-093_com android chrome Screenshot_2021-05-27-23-55-14-871_com android chrome

Winner Show

Screenshot_2021-05-27-23-56-38-979_com android chrome Screenshot_2021-05-27-23-55-59-683_com android chrome Screenshot_2021-05-27-23-58-02-442_com android chrome Screenshot_2021-05-27-23-58-22-736_com android chrome

Thank You