They say nothing is impossible, but defeating a computer in a game of Tic-Tac-Toe is pretty close. This is a simple game of Tic-Tac-Toe that you can play against the computer. The computer uses a minimax algorithm to determine the best move.
I used the following technologies to build this game:
- React
- Tailwind CSS
- TypeScript
- Vite
Minimax is a decision rule used in artificial intelligence, decision theory, game theory, statistics and philosophy for minimizing the possible loss for a worst case (maximum loss) scenario. When dealing with gains, it is referred to as "maximin"—to maximize the minimum gain. Originally formulated for two-player zero-sum game theory, covering both the cases where players take alternate moves and those where they make simultaneous moves, it has also been extended to more complex games and to general decision-making in the presence of uncertainty.
The computer uses a minimax algorithm to determine the best move. The computer always compute all the possible moves and chose the best one. The best move is the one that leads to a win or a draw.
Some resources that might help you understand the minimax algorithm: