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

https://github.com/itzdineshx/cs50ai_tic_tac_toe_ai

A simple Tic Tac Toe Game with AI
https://github.com/itzdineshx/cs50ai_tic_tac_toe_ai

ai aplha-beta-pruning chatgpt claude-ai gen-ai minimax-algorithm pruning-algorithms tic-tac-toe tictactoe-game web-game website

Last synced: 8 days ago
JSON representation

A simple Tic Tac Toe Game with AI

Awesome Lists containing this project

README

        

# Tic Tac Toe with AI - CS50 AI Final Project (Week 0)

Welcome to my **Tic Tac Toe with AI** project! This is my first project for the **CS50 AI** course, where I developed a web-based Tic Tac Toe game with an AI opponent. The AI uses the **Minimax algorithm** to make decisions, ensuring an unbeatable challenge. This project helped me understand the application of search algorithms and decision-making models in game development.

![image](https://github.com/user-attachments/assets/634faf93-fc50-47d5-b0f2-cc9654ba1976)

## ๐ŸŽฎ Live Demo
Experience the game in action: [Tic Tac Toe with AI](https://itzdineshx.github.io/Cs50ai_tic_tac_toe_AI/)

## ๐Ÿ› ๏ธ Features
- **Single-player mode**: Play against the AI, which always makes the optimal move using the Minimax algorithm.
- **Intuitive Interface**: Clean and simple design for a smooth user experience.
- **Sound Effects**: Audio feedback for actions like resetting the game.
- **Unbeatable AI**: The AI leverages the Minimax algorithm to calculate the best possible move, ensuring you never win (unless youโ€™re perfect!).
- **Reset Button**: Easily restart the game with a simple click.

## ๐Ÿš€ How It Works
1. Players alternate turns placing 'X' and 'O' on the 3x3 grid.
2. The objective is to align three marks in a row, either horizontally, vertically, or diagonally.
3. The AI opponent evaluates all possible moves using the **Minimax algorithm**, ensuring the most optimal strategy is always chosen. This guarantees that the AI never loses.

### Minimax Algorithm
The **Minimax algorithm** is a backtracking algorithm used in decision-making and game theory. It assumes that the opponent is also playing optimally, so it evaluates all possible game moves and chooses the one with the best possible outcome. This project showcases how the algorithm can be applied to a classic game like Tic Tac Toe, ensuring that the AI is an unbeatable opponent.

![image](https://github.com/user-attachments/assets/37aaf5d5-cf1c-450f-8887-efc9e43dac28)

## ๐Ÿ–ฅ๏ธ Technologies Used
- **HTML5**: Provides the structure for the game and web page.
- **CSS3**: Styles the game interface, making it visually appealing and responsive.
- **JavaScript**: Powers the game logic and the AIโ€™s decision-making process.
- **Font Awesome**: Enhances the footer with social media icons for easy access.

## ๐Ÿ“‚ File Structure
```
๐Ÿ“ฆ Cs50ai_tic_tac_toe_AI
โ”œโ”€โ”€ index.html # Main HTML file containing the game structure
โ””โ”€โ”€ README.md # Project documentation
```

## ๐Ÿ“œ How to Run Locally
To run the game on your local machine, follow these steps:

1. **Clone the repository**:
```bash
git clone https://github.com/itzdineshx/Cs50ai_tic_tac_toe_AI.git
```
2. **Navigate to the project directory**:
```bash
cd Cs50ai_tic_tac_toe_AI
```
3. **Open the `index.html` file** in your web browser to start playing the game.

## ๐ŸŒŸ Highlights
- **Minimax Algorithm**: The core AI logic of the game, ensuring the AI always makes the optimal move.
- **User-friendly UI**: A responsive, interactive design for a smooth and enjoyable user experience.
- **Sound Effects**: Adds an immersive experience to the gameplay with background sounds.

## ๐Ÿ’ก Key Learning
- Implementing the **Minimax algorithm** was an exciting challenge that deepened my understanding of search algorithms and their applications in game AI.
- Gaining hands-on experience in using **JavaScript** for both game logic and AI development helped enhance my problem-solving skills.
- Creating a **responsive user interface** with HTML and CSS taught me how to design interactive, user-friendly web applications.

## ๐Ÿ… Challenges Faced
- **Optimizing AI Performance**: Ensuring that the Minimax algorithm runs efficiently for real-time gameplay was one of the major challenges. I had to implement performance enhancements like pruning techniques to handle decision trees more effectively.
- **Designing a Simple yet Effective UI**: Ensuring the game was visually appealing yet simple enough to allow users to enjoy the gameplay experience without distractions was a balancing act.

## ๐Ÿ“ฌ Contact
Feel free to reach out for feedback, suggestions, or collaboration:
- **LinkedIn**: [Dinesh](https://www.linkedin.com/in/dinesh-x/)
- **GitHub**: [itzdineshx](https://github.com/itzdineshx)

---

Thank you for checking out my first project in the CS50 AI course! ๐ŸŽ‰
I hope you enjoy playing Tic Tac Toe with the unbeatable AI!
```