A Telegram bot that lets you play Tic-Tac-Toe against an unbeatable AI using the MINIMAX algorithm.
- Features
- Technologies
- Installation
- Usage
- Project Structure
- Environment Variables
- Contributing
- License
- Interactive Tic-Tac-Toe game on Telegram
- Unbeatable AI powered by the MINIMAX algorithm
- Inline keyboard interface for easy play
- Commands:
/start– Start a new game/help– Show help and game rules/about– Information about the project and team
- Python 3.8+
- python-telegram-bot library
- MINIMAX algorithm for AI decision making
- dotenv for environment variable management
-
Clone the repository
git clone https://github.com/3bbaas/TelegramBot-XO-Game.git cd TelegramBot-XO-Game -
Create and activate a virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
- Copy
.env.exampleto.env - Set your Telegram bot token in the
.envfile:BOT_TOKEN=your_bot_token_here
- Copy
-
Run the bot
python main.py
Open Telegram, search for your bot by its username, and start a chat. Use the commands below to interact:
/start– Begins a new Tic-Tac-Toe session/help– Displays game rules and tips/about– Shows project information and team members
Tap on the inline buttons to place your move. Enjoy the game! 🎮
├── main.py # Bot entrypoint and Telegram handlers
├── tictactoe.py # Game logic & MINIMAX AI implementation
├── requirements.txt # Python dependencies (frozen via pip)
├── .env.example # Sample environment variables
├── .gitignore # Ignored files and folders
└── README.md # Project overview and setup instructions
BOT_TOKEN– Your Telegram bot token (from BotFather)
Refer to .env.example for guidance.
Contributions are welcome! Feel free to open issues or submit pull requests.
- Fork the repository
- Create a feature branch (
git checkout -b feature/YourFeature) - Commit your changes (
git commit -m "Add YourFeature") - Push to the branch (
git push origin feature/YourFeature) - Open a Pull Request
This project is MIT licensed. See the LICENSE file for details.
venv/
.idea/
__pycache__/
*.py[cod]
.env