Md Shahbaz Ahmad’s Post

View profile for Md Shahbaz Ahmad, graphic

Attended Amity University Patna

Task 2 #CodSoft TIC-TAC-TOE AI  Implement an AI agent that plays the classic game of Tic-Tac-Toe against a human player. You can use algorithms like Minimax with or without Alpha-Beta Pruning to make the AI player unbeatable. This project will help you understand game theory and basic search algorithms.  I’ve made an AI that plays Tic-Tac-Toe perfectly against a human. It uses a smart algorithm called Minimax with Alpha-Beta Pruning. This helps the AI always choose the best move, so it never loses. The project taught me about game strategy and how computers can make decisions. It was a fun way to learn how to build an unbeatable game player. Now, anyone can play Tic-Tac-Toe against the AI and see how it always finds the best moves. This project shows how simple algorithms can make games challenging and exciting. ### Explanation: 1. **TicTacToe Class**:   - Represents the game board and includes methods to print the board, check available moves, make a move, and determine the winner. 2. **Minimax Algorithm with Alpha-Beta Pruning**:   - The `minimax` function implements the Minimax algorithm with Alpha-Beta Pruning. It recursively evaluates all possible moves to determine the best move for the AI player ('X') or the human player ('O'). 3. **play_game Function**:   - Manages the game loop where the AI (AI player, 'X') and the human player ('O') take turns making moves until a winner is determined or the game ends in a draw. 4. **Game Execution**:   - The game starts with the `play_game` function, where the AI player uses the `minimax` algorithm to make its moves optimally. The human player inputs their moves via the console. ### How to Play: - Run the script, and follow the prompts in the console to input your moves (0-8). - The AI player ('X') will make its moves using the minimax algorithm with alpha-beta pruning to ensure optimal play. - The game will continue until there is a winner or the game ends in a draw. This implementation should provide a solid foundation for understanding how to apply the Minimax algorithm with Alpha-Beta Pruning in a simple game scenario like Tic-Tac-Toe. THANKS FOR THE OPPORTUNITY #CodSoft #Internship #ArtificialIntelligence #NewBeginnings 

Ankit kumar singh

web developer| artificial intelligence| Java| python| cybersecurity | product designer|Google cloud

5mo

Useful tips

Like
Reply

To view or add a comment, sign in

Explore topics