Skip to content

ramdevji/MiniMax-Algorithm-Implementation-for-a-simple-GUI-Tic-Tac-Toe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MiniMax-Algorithm-Implementation-for-a-simple-GUI-Tic-Tac-Toe-Game

Used the pygame library of python for : 1.Drawing the Board and Displaying it. 2.Getting the user events such as Mouse click and getting the position of the square the User cliked. 3.Setting back the Optimal move to the screen generated by MinMax algorithm.

Algorithm Description and Implementation: 1.MinMax is a simple decision making algorithm.At the leaves are the decisions and it is a recursive tree like algorithm. 2.It is widely used in gaming for predicting the next optimal move. 3.It's very simple and easy to understand. 4.There are two players Min and Max,Min always wants to move in such a way such that there are minimum chances for wining the game for Max Player and Max moves in such a way that there are Maximum chances for it or it chooses the optimal value in such a way such that Min gets low score among the all other values.

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

About

Used the pygame library of python for :

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages