{"id":19665354,"url":"https://github.com/savinrazvan/tictactoe","last_synced_at":"2025-02-27T03:44:23.839Z","repository":{"id":250628633,"uuid":"834852128","full_name":"SavinRazvan/tictactoe","owner":"SavinRazvan","description":"An AI that plays Tic-Tac-Toe using the Minimax algorithm, ensuring it always wins or draws. Demonstrates optimal decision-making and game logic implementation.","archived":false,"fork":false,"pushed_at":"2024-07-28T23:38:31.000Z","size":117,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T02:32:51.812Z","etag":null,"topics":["ai","algorithmic-game-theory","board-games","educational-project","game-ai","game-development","minimax-algorithm","optimal-decision-making","pygame","python","tic-tac-toe","unbeatable-ai"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SavinRazvan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-28T15:01:15.000Z","updated_at":"2024-08-08T04:42:05.000Z","dependencies_parsed_at":"2024-07-29T01:21:15.269Z","dependency_job_id":null,"html_url":"https://github.com/SavinRazvan/tictactoe","commit_stats":null,"previous_names":["savinrazvan/tictactoe"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SavinRazvan%2Ftictactoe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SavinRazvan%2Ftictactoe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SavinRazvan%2Ftictactoe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SavinRazvan%2Ftictactoe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SavinRazvan","download_url":"https://codeload.github.com/SavinRazvan/tictactoe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240974642,"owners_count":19887329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","algorithmic-game-theory","board-games","educational-project","game-ai","game-development","minimax-algorithm","optimal-decision-making","pygame","python","tic-tac-toe","unbeatable-ai"],"created_at":"2024-11-11T16:22:22.177Z","updated_at":"2025-02-27T03:44:23.818Z","avatar_url":"https://github.com/SavinRazvan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tic-Tac-Toe AI Project\n\n## Project Description\nThis project involves the creation of an AI that plays Tic-Tac-Toe using the Minimax algorithm. The AI is designed to ensure that it either wins or draws every game, demonstrating optimal decision-making throughout the gameplay.\n\n## Objectives\n- **Implement Game Logic:** Develop functions to manage the game state, determine possible actions, and apply those actions.\n- **Optimal Decision Making:** Use the Minimax algorithm to compute the best possible move for the AI.\n- **End Game Conditions:** Implement checks to determine when the game has ended and the winner, if any.\n\n## Key Components\n1. **player(board):** Identifies the current player (X or O).\n2. **actions(board):** Lists all possible moves on the board.\n3. **result(board, action):** Returns the new board state after a move.\n4. **winner(board):** Determines if there's a winner.\n5. **terminal(board):** Checks if the game is over.\n6. **utility(board):** Assigns a value to the final board state (+1 for X win, -1 for O win, 0 for a tie).\n7. **minimax(board):** Computes the optimal move for the current player.\n\n## Installation and Usage\n1. **Setup:**\n   - Ensure you have Python installed.\n   - Download and unzip the project files.\n   - Install required dependencies: `pip3 install -r requirements.txt`.\n\n2. **Run the Game:**\n   - Start the game using the command: `python runner.py`.\n\n## How It Works\n- The game uses the Pygame library to provide a graphical interface.\n- Players can choose to play as X or O.\n- The AI calculates the best possible move using the Minimax algorithm, ensuring it plays optimally.\n- The game continues until there's a winner or a tie, with the AI always making the optimal move.\n\n## AI Implementation Details\n- **Minimax Algorithm:** The AI uses the Minimax algorithm to evaluate all possible moves and select the one that maximizes its chances of winning or minimizing its chances of losing.\n- **Game State Management:** Functions are implemented to manage the game state, check for winners, and determine possible actions.\n- **Optimal Play:** The AI ensures that it never loses by playing the optimal move at every turn.\n\n## Conclusion\nThis project demonstrates a robust implementation of an unbeatable Tic-Tac-Toe AI, showcasing key AI and algorithmic principles. The use of the Minimax algorithm ensures that the AI always plays optimally, providing a challenging opponent for any player.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavinrazvan%2Ftictactoe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsavinrazvan%2Ftictactoe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavinrazvan%2Ftictactoe/lists"}