Skip to content

Samery00/Tic-Tac-Toe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe-Game using javascript

A TicTacToe game with minimax algorithm

Use

Start the game with "game.html"

Minimax algorithm

A description for the algorithm, assuming X is the "turn taking player," would look something like:

  • If the game is over, return the score from X's perspective.
  • Otherwise get a list of new game states for every possible move
  • Create a scores list
  • For each of these states add the minimax result of that state to the scores list
  • If it's X's turn, return the maximum score from the scores list
  • If it's O's turn, return the minimum score from the scores list

You'll notice that this algorithm is recursive, it flips back and forth between the players until a final score is found.

Illustration

Image of the first tree