/UnbeatableTicTacToe

A tic-tac-toe game that never loses using the Mini-max Algorithm.

Primary LanguageJavaScriptMIT LicenseMIT

Unbeatable TicTacToe Game

This is a simple tic-tac-toe game that uses the mini-max algorithm as an AI player against the human player so it never loses.

Minimax Algorithm

In real life, a human would think of all the possible consequences for each move. This is where the minimax algorithm comes handy. The algorithm evaluates the moves that lead to a terminal state based on the players’ turn. It will choose the move with maximum score when it is the AI’s turn and choose the move with the minimum score when it is the human player’s turn. Using this strategy, Minimax avoids losing to the human player.

Demo

Play it on CodePen

Demo

Inspiration

This implementation of the Mini-Max Algorithm based on the following tutorial: FreeCodeCamp