Skip to content

Andrewzekid/TicTacToe-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TicTacToe-AI

TicTacToe AI made using MiniMax.

How MiniMax Works

a-move-tree-from-the-perspective-of-the-other-player-o

Minimax works by recursively considering the game's outcome after both you and your opponent plays the optimal moves.

  • Minimax assigns one player, say X to be the maximizing player, whose goal is to maximize the score they get. The other player is the minimizing player, say O, who wants to minimize their score.
  • For a given game, I define X wins as +10 points, O wins as -10 points, and a draw as 0 points. From O's perspective, it is ideal to choose moves that result in an outcome of a score as low as possible (preferring 0 points over +10 points) given optimal play on both sides.
  • See the image above. On the turn of the minimizing player O, all possible moves are first considered by O. X's responses to those moves are also considered, and O's responses to those are considered until we reach a state where the game is over.
  • As shown in the image, this process (of considering the opponents response to your response and then your response to that and so on) creates a tree-like structure. The different branches of this tree are parsed and we pick the move for O where, no matter what X does, results in the lowest possible score for O.

Demonstration

Desktop.2024.05.07.-.22.38.36.04.online-video-cutter.com.mp4

About

TicTacToe AI made using MiniMax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages