{"id":20146253,"url":"https://github.com/mohammadrezaamani/tictoctoe","last_synced_at":"2025-04-09T19:22:28.524Z","repository":{"id":151987280,"uuid":"373808368","full_name":"MohammadrezaAmani/TicTocToe","owner":"MohammadrezaAmani","description":" Tic-Tac-Toe game implemented in C++ with Minimax algorithm and Alpha-Beta Pruning!","archived":false,"fork":false,"pushed_at":"2023-12-12T09:45:30.000Z","size":63,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T21:11:50.990Z","etag":null,"topics":["alpha-beta-pruning","cpp","minimax-algorithm","tic-tac-toe","x-o"],"latest_commit_sha":null,"homepage":"","language":"C++","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/MohammadrezaAmani.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-06-04T10:39:40.000Z","updated_at":"2025-02-17T14:26:04.000Z","dependencies_parsed_at":"2024-11-13T22:22:31.907Z","dependency_job_id":"7d66ff75-6245-4057-baf6-d50eb215335f","html_url":"https://github.com/MohammadrezaAmani/TicTocToe","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohammadrezaAmani%2FTicTocToe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohammadrezaAmani%2FTicTocToe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohammadrezaAmani%2FTicTocToe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MohammadrezaAmani%2FTicTocToe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MohammadrezaAmani","download_url":"https://codeload.github.com/MohammadrezaAmani/TicTocToe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248095537,"owners_count":21046865,"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","cpp","minimax-algorithm","tic-tac-toe","x-o"],"created_at":"2024-11-13T22:20:45.628Z","updated_at":"2025-04-09T19:22:28.486Z","avatar_url":"https://github.com/MohammadrezaAmani.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tic-Tac-Toe with Minimax and Alpha-Beta Pruning\n\nWelcome to the Tic-Tac-Toe game implemented in C++ with Minimax algorithm and Alpha-Beta Pruning! This console-based game allows you to play against an AI opponent that uses the Minimax algorithm with Alpha-Beta Pruning to make optimal moves.\n\n## Table of Contents\n\n- [Tic-Tac-Toe with Minimax and Alpha-Beta Pruning](#tic-tac-toe-with-minimax-and-alpha-beta-pruning)\n  - [Table of Contents](#table-of-contents)\n  - [Introduction](#introduction)\n  - [Getting Started](#getting-started)\n    - [Prerequisites](#prerequisites)\n    - [Installation](#installation)\n  - [How to Play](#how-to-play)\n    - [Player Moves](#player-moves)\n    - [AI Moves](#ai-moves)\n  - [Game Features](#game-features)\n    - [Print Board](#print-board)\n    - [Check Win](#check-win)\n    - [Make Move](#make-move)\n    - [Minimax Algorithm](#minimax-algorithm)\n    - [Alpha-Beta Pruning](#alpha-beta-pruning)\n  - [Examples](#examples)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n## Introduction\n\nThis Tic-Tac-Toe game is implemented in C++ and features a simple console interface. The AI opponent is powered by the Minimax algorithm, a decision-making algorithm widely used in two-player games. The implementation also includes Alpha-Beta Pruning to optimize the search space and improve performance.\n\n## Getting Started\n\n### Prerequisites\n\nBefore running the game, ensure that you have a C++ compiler installed on your system.\n\n### Installation\n\n1. Clone the repository to your local machine:\n\n   ```bash\n   git clone https://github.com/MohammadrezaAmani/TicTocToe\n   ```\n\n2. Navigate to the project directory:\n\n   ```bash\n   cd TicTocToe\n   ```\n\n3. Compile the code using your C++ compiler:\n\n   ```bash\n   g++ -o tic_tac_toe main.cpp\n   ```\n\n4. Run the executable:\n\n   ```bash\n   ./tic_tac_toe\n   ```\n\n## How to Play\n\n### Player Moves\n\n- Enter your move by specifying the row and column (1-3) when prompted.\n\n### AI Moves\n\n- The AI opponent uses the Minimax algorithm to make optimal moves.\n- Watch out for strategic plays, as the AI aims to win or force a tie.\n\n## Game Features\n\n### Print Board\n\n- The `printBoard` function displays the current state of the Tic-Tac-Toe board.\n\n### Check Win\n\n- The `checkWin` function checks if a player has won the game.\n\n### Make Move\n\n- The `makeMove` function allows players to make a move on the board.\n\n### Minimax Algorithm\n\n- The `minimax` function implements the Minimax algorithm for decision-making.\n\n### Alpha-Beta Pruning\n\n- The Minimax algorithm is enhanced with Alpha-Beta Pruning for improved efficiency.\n\n## Examples\n\nHere's an example of how of using game:\n\n```cpp\nint main()\n{\n    TicTacToe game;\n    int currentPlayer = 1;\n\n    while (true)\n    {\n        game.printBoard();\n\n        if (currentPlayer == 1)\n        {\n            std::cout \u003c\u003c \"Player 1, enter your move (row and column): \";\n            int row, col;\n            std::cin \u003e\u003e row \u003e\u003e col;\n\n            if (game.makeMove(row - 1, col - 1, currentPlayer))\n            {\n                if (game.checkWin(currentPlayer))\n                {\n                    game.printBoard();\n                    std::cout \u003c\u003c \"Player 1 wins!\" \u003c\u003c std::endl;\n                    break;\n                }\n                else if (game.isBoardFull())\n                {\n                    game.printBoard();\n                    std::cout \u003c\u003c \"It's a tie!\" \u003c\u003c std::endl;\n                    break;\n                }\n            }\n            else\n            {\n                std::cout \u003c\u003c \"Invalid move. Try again.\" \u003c\u003c std::endl;\n                continue;\n            }\n        }\n        else\n        {\n            game.makeAIMove();\n\n            if (game.checkWin(2))\n            {\n                game.printBoard();\n                std::cout \u003c\u003c \"AI wins!\" \u003c\u003c std::endl;\n                break;\n            }\n            else if (game.isBoardFull())\n            {\n                game.printBoard();\n                std::cout \u003c\u003c \"It's a tie!\" \u003c\u003c std::endl;\n                break;\n            }\n        }\n\n        currentPlayer = (currentPlayer == 1) ? 2 : 1;\n    }\n\n    return 0;\n}\n\n```\n\nFollow the on-screen instructions to make your moves and enjoy the game!\n\n## Contributing\n\nContributions are welcome! If you have ideas for improvements or find any issues, please open an issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadrezaamani%2Ftictoctoe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammadrezaamani%2Ftictoctoe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadrezaamani%2Ftictoctoe/lists"}