Skip to content

This project implements an unbeatable Tic-Tac-Toe AI using the Minimax algorithm with Alpha-Beta pruning. The AI strategically analyzes the game board, explores possible moves, and selects the optimal choice to ensure a win or a draw.

Notifications You must be signed in to change notification settings

row-huh/ticTacToeAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Tic-Tac-Toe AI Project

This project implements a Tic-Tac-Toe game with an AI opponent using the minimax algorithm. The AI opponent is designed to play optimally and never lose.

Features

Minimax Algorithm: The AI uses the minimax algorithm to choose the best possible move. User-Friendly Interface: Simple command-line interface for playing the game. Two Player Mode: Option to play against another human player.

Requirements

Python 3.x Terminal or Command Prompt

Installation

Clone the repository: git clone https://github.com/row-huh/ticTacToeAI.git Navigate to the project directory:

cd tic-tac-toe-ai

Run the game:

python tic_tac_toe.py

Make sure you have pygame installed!

How to Play

The game board is a 3x3 grid. Players take turns placing their marker ('X' or 'O') on an empty spot. The first player to get three of their markers in a row (horizontally, vertically, or diagonally) wins. If the board is full and no player has three in a row, the game is a draw. AI Algorithm: Minimax The minimax algorithm is a decision rule used for two-player games. In this project, the algorithm is used to determine the best move for the AI by evaluating all possible future moves and choosing the one that maximizes its chances of winning or minimizing its chances of losing

Example

You can choose to play as an X or O player

image

The agent plays against you and makes sure that it wins or atleast it doesn't lose!

image

About

This project implements an unbeatable Tic-Tac-Toe AI using the Minimax algorithm with Alpha-Beta pruning. The AI strategically analyzes the game board, explores possible moves, and selects the optimal choice to ensure a win or a draw.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages