Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aashrafh/unbeatabletictactoe

A tic-tac-toe game that never loses using the Mini-max Algorithm.
https://github.com/aashrafh/unbeatabletictactoe

ai ai-games css games html javascript minimax minimax-algorithm tic-tac-toe tictactoe tictactoe-game

Last synced: 21 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](https://codepen.io/aashrafh/full/ZdRMYV)

![Demo](https://s3.gifyu.com/images/InteractiveDictionarydfa13c2407c324a9.md.gif)

## Inspiration
This implementation of the Mini-Max Algorithm based on the following tutorial: [FreeCodeCamp](https://www.freecodecamp.org/news/how-to-make-your-tic-tac-toe-game-unbeatable-by-using-the-minimax-algorithm-9d690bad4b37/)