Skip to content

An AI-powered Tic-Tac-Toe game ๐ŸŽฎ using the Minimax algorithm ๐Ÿค–. Play against an unbeatable AI that makes the best possible moves! โŒโญ•

Jyotshna25/AI-Powered-Tic-Tac-Toe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 

Repository files navigation

โŒโญ• AI-Powered Tic-Tac-Toe Game

A Python-based Tic-Tac-Toe game where you play against an unbeatable AI ๐Ÿค– using the Minimax Algorithm!

๐Ÿš€ Features

โœ… Classic 3x3 Tic-Tac-Toe Board ๐ŸŽฒ
โœ… AI Opponent with Minimax Algorithm ๐Ÿง 
โœ… User vs AI Gameplay โ€“ You play as 'X', AI plays as 'O' ๐ŸŽฎ
โœ… Handles Invalid Moves & Input Errors ๐Ÿšซ
โœ… Automatically Detects Winners & Draws ๐Ÿ†

๐Ÿ“Œ How It Works

  1. User starts by entering row & column numbers (0-2) โœ๏ธ
  2. AI calculates the best move using the Minimax algorithm ๐Ÿ”ข
  3. Game updates the board and displays results after each turn โšก
  4. Ends when there's a winner or no moves left ๐Ÿš€

๐Ÿ† Minimax Algorithm Explained

  • Recursively evaluates all possible game outcomes ๐Ÿค“
  • AI chooses moves that maximize its chance of winning ๐Ÿ…
  • Guaranteed Unbeatable โ€“ AI will always win or force a draw! ๐Ÿ’ช

๐Ÿ› ๏ธ Code Overview

# AI calculates the best move using Minimax
best_move(board)  

# User inputs a move
row, col = map(int, input("Enter row and column (0-2): ").split())  

# Game checks for a winner
winner = check_winner(board)  

๐ŸŽฏ Example Game

 X | O | X 
-----------
 O | X | O 
-----------
 O | X | X 

Result: It's a draw! ๐Ÿค

๐Ÿ“ข Future Enhancements

๐Ÿ”น Add a GUI version with Tkinter or Pygame ๐ŸŽจ
๐Ÿ”น Support for multiplayer mode (Player vs Player) ๐Ÿ‘ฅ
๐Ÿ”น Difficulty levels (Easy, Medium, Hard) โš™๏ธ


๐ŸŽฏ Get Started

๐Ÿ”น Clone the repository
๐Ÿ”น Run the Python script
๐Ÿ”น Play against the AI & try to win! ๐Ÿš€


๐Ÿ‘จโ€๐Ÿ’ป Developed as part of CodSoft Internship โ€“ Task 2 ๐ŸŽ“
Feel free to contribute & improve the game! ๐Ÿ’ก

About

An AI-powered Tic-Tac-Toe game ๐ŸŽฎ using the Minimax algorithm ๐Ÿค–. Play against an unbeatable AI that makes the best possible moves! โŒโญ•

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages