Skip to content

Sukrit-Prakash/Tic-Tac-Toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe with Minimax Bot Description This is a simple Tic Tac Toe game where a user can play against a computer (bot) using the Minimax Algorithm. The bot uses the Minimax algorithm to make optimal moves by recursively simulating possible game outcomes and selecting the best move.

The game allows a user to play as either 'X' or 'O' against the bot. The bot plays with 'O', and the user plays with 'X'. The game will automatically detect if there is a win, draw, or if the game is ongoing. If the user wishes to reset the game, they can use the reset button.

Features User vs. Computer: The user can play against the computer, where the computer follows the Minimax strategy to make optimal decisions. Minimax Algorithm: The computer evaluates all possible moves using the Minimax algorithm to ensure the best decision. Game Status: Displays win, loss, or draw status at the end of the game. Reset Functionality: After each game, users can reset the board and start a new game. How to Play Click on any of the empty cells to make your move (as 'X'). The bot will then make its move (as 'O'), and the game board will update. The game continues until either: The user or the bot wins. The game ends in a draw. You can reset the board and start a new game by clicking the Reset button. Technologies Used HTML: For the structure of the game board and UI. CSS: For styling the game layout. JavaScript: To handle the game logic, including the Minimax algorithm and interactions. DOM Manipulation: For handling user interactions and updating the game board in real-time. Algorithm: Minimax The Minimax algorithm simulates all possible moves for both the user and the computer. The computer tries to maximize its score (win), while the user attempts to minimize the computer's score. The algorithm assigns scores to each terminal game state:

+10 for a win by the bot. -10 for a win by the user. 0 for a draw. The algorithm recursively evaluates all possible moves and chooses the optimal one. Project Setup Clone or download this repository to your local machine. Open the index.html file in your browser to start the game. bash Copy code git clone https://github.com/yourusername/tic-tac-toe-minimax.git File Structure bash Copy code /tic-tac-toe-minimax │ ├── index.html # The main HTML file containing the structure of the game ├── style.css # The stylesheet for styling the game interface ├── script.js # The JavaScript file containing the game logic and Minimax algorithm └── README.md # This README file How to Use Open index.html in your browser to play the game. Click on the cells of the board to make your move as 'X'. The computer will play as 'O' and choose the best move using the Minimax algorithm. The game will end when either player wins, or there’s a draw. Press the Reset button to start a new game. Game Rules The game is played on a 3x3 grid. Player 'X' and 'O' take turns to place their marks in an empty cell. A player wins if they have three of their marks in a row, column, or diagonal. The game ends in a draw if all cells are filled and there is no winner. Future Improvements Enhance AI Difficulty: Currently, the Minimax algorithm is used to make optimal moves. However, adding a difficulty setting could make the bot play less optimally to create a challenge for the user. Mobile Responsiveness: Make the game more responsive and optimized for mobile devices. User Authentication: Allow players to save their progress or scores by adding a user authentication system. Contributors Your Name (your GitHub handle) - Initial work on the project. License This project is licensed under the MIT License - see the LICENSE file for details.

Example Screenshot You can include a screenshot of your game to show users what the interface looks like.

Contact For any questions or suggestions, feel free to reach out:

Email: [email protected] GitHub: https://github.com/yourusername

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published