A Python project offering multiple interfaces to play Tic-Tac-Toe against AI opponents. Features terminal gameplay with two AI strategies (Minimax and MCTS) and computer vision integration for real-world board analysis.
- 🎮 Terminal Gameplay: Play classic Tic-Tac-Toe in your terminal against AI
- 🤖 Dual AI Engines: Choose between:
- Minimax with alpha-beta pruning (perfect play)
- Monte Carlo Tree Search (MCTS) opponent
- 📸 Computer Vision Integration: Process physical/drawn boards from images
- Automatic board state detection
- Optimal move visualization on input images
- 🖼️ Image Processing Pipeline:
- Grid detection with OpenCV
- Cell segmentation and symbol recognition
- 🧠 AI Decision Systems:
- Minimax (integrated with CV pipeline)
- MCTS (terminal-only implementation)
- ✍️ Visualization Tools:
- Move annotation on processed images
- Terminal-based board display
- Python 3.8+
- OpenCV 4.5+
- numpy 1.20+
git clone https://github.com/mzums/tic-tac-toe.git
cd tic-tac-toe
pip install -r requirements.txtpython <minimax_or_mcts>/main.pypython main.py path/to/image.jpgOptions:
--show-stepsto display processing stages
avaible in folder cv/test_images
usage:
python main.py cv/test_images/image1.jpg --show_steps
For best CV performance:
- High contrast between grid and background
- Uniform lighting
- Square board proportions
- Supported formats: JPG, JPEG, PNG, BMP
MIT License. See LICENSE for details.
- Fork repository
- Create feature branch (
git checkout -b feature/improvement) - Commit changes
- Push to branch
- Open Pull Request











