/Tic-Tac-Toe

An unbeatable tic-tac-toe game that uses vanilla JavaScript, HTML, and CSS.

Primary LanguageJavaScript

Tic-Tac-Toe

An unbeatable tic-tac-toe game that uses vanilla JavaScript, HTML, and CSS. This application utilizes that minimax algorithm, which is responsible for implementing the "unbeatable" component. The minimax algorithm is able to evaluate the oponent's potential moves several steps ahead. The computer continues playing until it reaches a terminal state resulting in a tie, a win, or a loss. Once in a terminal state, the AI will assign an arbitrary positive score (+10) for a win, a negative score (-10) for a loss, or a neutral score (0) for a tie.

Concurrently, 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, the minimax algorithm avoids losing to the human player.

Screenshots:

screen shot 2018-09-01 at 12 22 44 pm screen shot 2018-09-01 at 12 23 08 pm screen shot 2018-09-01 at 12 23 21 pm screen shot 2018-09-01 at 12 23 33 pm screen shot 2018-09-01 at 12 23 49 pm