A high-performance, hybrid 6x6 Othello (Reversi) engine built with a blisteringly fast C++ backend and a responsive, modern Python (Tkinter) Graphical User Interface.
This project demonstrates advanced game-tree search algorithms, bitwise board representations, and seamless cross-language communication.
- Bitboard Representation: The board is strictly represented using 64-bit integers (
uint64_t), allowing for lightning-fast move generation and state evaluation using bitwise operations. - Alpha-Beta Pruning & Iterative Deepening: Efficiently searches the game tree, prioritizing the most promising moves and strictly respecting dynamic time limits.
- Transposition Table (Zobrist Hashing): Caches previously evaluated board states to prevent redundant calculations, massively increasing search depth.
- Game-Phase Tapering: The evaluation heuristic dynamically shifts. It prioritizes mobility and frontier-disc minimization in the midgame, and switches to a pure mathematical solver in the endgame to guarantee forced wins.
- Real-time Evaluation Bar: Visually tracks the AI's internal evaluation score and maximum depth reached during its calculation phase.
- 20 Granular Difficulty Levels: Scales from beginner-friendly (shallow searches) to a "Master" level that utilizes infinite midgame search depths and perfectly solves the final 22 moves.
- Standalone Executable: Fully packaged using PyInstaller for one-click launching without needing a Python environment.
The project maintains a strict separation of concerns between the compiled engine and the frontend UI:
Othello/
├── assets/ # Icons and visual resources
├── engine_src/ # Pure C++ engine source code
│ ├── main.cpp
│ ├── OthelloAI.cpp
│ └── OthelloBoard.cpp
├── pages/ # Modular Tkinter UI frames
├── archive/ # Deprecated scripts and backups
├── board_ui.py # Main game board logic
├── engine_proxy.py # Subprocess bridge for C++ to Python communication
└── main.py # Application entry point
This project includes an automated PowerShell script that compiles the C++ engine and packages the Python GUI into a single standalone directory.
- MinGW / g++ (For compiling the C++ engine)
- Python 3.x
- PyInstaller (
pip install pyinstaller)
- Clone the repository:
git clone [https://github.com/YOUR_USERNAME/Othello.git](https://github.com/YOUR_USERNAME/Othello.git) cd Othello
2. Run the automated build script (Windows):
```powershell
.\build.ps1
- Play the game:
Navigate to the newly generated
dist/main/folder and runmain.exe.
The difficulty curve (Levels 1-20) controls two distinct parameters:
- Midgame Depth (
mid_depth): The maximum depth the AI will search while using its positional/mobility heuristics. - Endgame Depth (
end_depth): The exact number of empty cells remaining before the AI drops all heuristics and attempts to mathematically solve the rest of the game. This is strictly capped at22to ensure the engine never "times out" and falls victim to the horizon effect during pure disc-counting.
This project is open-source and available under the MIT License.