{"id":18603970,"url":"https://github.com/farzeennimran/tic-tac-toe-using-alpha-beta-pruning-python-","last_synced_at":"2026-04-16T08:37:44.133Z","repository":{"id":233035830,"uuid":"785857836","full_name":"farzeennimran/Tic-Tac-Toe-using-Alpha-beta-pruning-Python-","owner":"farzeennimran","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-12T19:37:46.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-26T23:26:43.145Z","etag":null,"topics":["alpha-beta-pruning","artificial-intelligence","data-science","deep-learning","game","machine-learning-algorithms","python","tic-tac-toe-game"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/farzeennimran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-04-12T19:20:37.000Z","updated_at":"2024-06-12T19:46:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ba6fb6d-39d6-42b1-8c33-2955b1cccaad","html_url":"https://github.com/farzeennimran/Tic-Tac-Toe-using-Alpha-beta-pruning-Python-","commit_stats":null,"previous_names":["farzeennimran/tic-tac-toe-using-alpha-beta-pruning-python-"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FTic-Tac-Toe-using-Alpha-beta-pruning-Python-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FTic-Tac-Toe-using-Alpha-beta-pruning-Python-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FTic-Tac-Toe-using-Alpha-beta-pruning-Python-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/farzeennimran%2FTic-Tac-Toe-using-Alpha-beta-pruning-Python-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/farzeennimran","download_url":"https://codeload.github.com/farzeennimran/Tic-Tac-Toe-using-Alpha-beta-pruning-Python-/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239394682,"owners_count":19631122,"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":["alpha-beta-pruning","artificial-intelligence","data-science","deep-learning","game","machine-learning-algorithms","python","tic-tac-toe-game"],"created_at":"2024-11-07T02:16:06.225Z","updated_at":"2026-04-16T08:37:39.084Z","avatar_url":"https://github.com/farzeennimran.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tic-Tac-Toe using Alpha-Beta Pruning (Python)\n\n## Introduction\n\nWelcome to the **Tic-Tac-Toe using Alpha-Beta Pruning (Python)** repository! This project implements a Tic-Tac-Toe game where an AI opponent uses the Minimax algorithm enhanced with Alpha-Beta Pruning to play optimally. The AI ensures that the player is always challenged, making the game both enjoyable and educational.\n\n## What is Alpha-Beta Pruning?\n\nAlpha-Beta Pruning is an optimization technique for the Minimax algorithm, which is used in decision-making and game theory. It reduces the number of nodes evaluated by the Minimax algorithm in its search tree. By eliminating branches that cannot possibly influence the final decision, Alpha-Beta Pruning makes the algorithm more efficient, allowing it to handle more complex scenarios or to run faster in simpler ones.\n\n## How is Alpha-Beta Pruning Used in Tic-Tac-Toe?\n\nIn Tic-Tac-Toe, the Minimax algorithm explores all possible moves to determine the optimal strategy. Alpha-Beta Pruning enhances this process by cutting off branches in the search tree that won't affect the outcome, thus speeding up the decision-making process. This allows the AI to compute the best possible move within a reasonable time frame, ensuring a challenging opponent without long waits.\n\n## Explanation of the Code\n\n### 1) Initial Setup\n\nThe constants and initial state of the board are defined at the beginning\n\n### 2) Drawing the Board\n\nThe `draw_board` function prints the current state of the board\n\n### 3) Player Turn\n\nThe `player` function determines whose turn it is\n\n### 4) Possible Actions\n\nThe `actions` function lists all possible moves\n\n### 5) Resulting Board State\n\nThe `result` function returns the board state after a move\n\n### 6) Checking for a Winner\n\nHelper functions `get_horizontal_winner`, `get_vertical_winner`, and `get_diagonal_winner` check for winning lines. The `winner` function integrates these\n\n### 7) Terminal State and Utility\n\nThe `terminal` function checks if the game is over, and the `utility` function evaluates the board\n\n### 8) Minimax Algorithm with Alpha-Beta Pruning\n\nThe core logic for the AI is implemented in the `minimax`, `max_value`, and `min_value` functions\n\n### 9) Playing the Game\n\nThe `play_game` function manages the game loop, allowing a human player to compete against the AI\n\n## Conclusion\n\nThis repository demonstrates a practical application of the Minimax algorithm with Alpha-Beta Pruning in a classic game of Tic-Tac-Toe. The AI opponent ensures an engaging experience by playing optimally, showcasing the effectiveness of Alpha-Beta Pruning in reducing computation time while maintaining strategic depth. Feel free to explore the code, play the game, and learn more about game theory and AI decision-making processes.\n\nEnjoy playing Tic-Tac-Toe with an intelligent opponent!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzeennimran%2Ftic-tac-toe-using-alpha-beta-pruning-python-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffarzeennimran%2Ftic-tac-toe-using-alpha-beta-pruning-python-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffarzeennimran%2Ftic-tac-toe-using-alpha-beta-pruning-python-/lists"}