Othello/Reversi game coded in C++. Can play against an 'AI'.
- Since you're here, I assume you already know how to play... If not, here's a link.
- To play the game,
- Run the
mainbinary file and follow the prompts, or - Download the source code and run
maketo compile, then run themainbinary file.
- Run the
Disclaimer: If you are on Windows then you may need to compile the code yourself; the provided Makefile and binary executable was meant for Unix-based systems.
- Player vs Player
- Player vs AI
- AI vs AI
- Puzzle Mode
- Beautiful TUI — Unicode board with box-drawing borders, a filled
●for White and hollow○for Black, and valid moves highlighted in green. - AI time limit can be set to any positive integer (seconds), default = 5. In AI vs AI mode each side has its own time limit.
- In PvE mode the player can choose their disk color and consequently, who starts first.
- Undo (
U) — reverts your last move. In PvE mode, undoes back to the player's own last turn, skipping over the AI's move. - Resign (
R) — immediately concedes the game and awards the win to the opponent. - Game log export — at the end of every game, two files are saved to the
logs/folder:.log— raw move sequence on a single line.txt— human-readable log with move history, scores, result, and game settings
Puzzle Mode lets you load a custom board position and watch the AI play both sides from that state.
Setup:
- Choose a board input format:
- FEN-like string — rows separated by
/, usingB/b(Black),W/w(White), and digits1–8for empty cells. Example:8/8/8/3WB3/3BW3/8/8/8 - 64-character string — left-to-right, top-to-bottom using
B/b,W/w, and.for empty. Example:...........................WB......BW...........................
- FEN-like string — rows separated by
- Specify whose turn it is (
Bfor Black,Wfor White). - Set a time limit for the AI (shared by both sides).
The AI then plays out the game from the given position.
- Search: Iterative deepening (IDDFS) with a time limit.
- Algorithm: NegaScout (Principal Variation Search).
- Move ordering: Moves are tried in priority order (corners → edges → inner cells → X-squares) to improve pruning efficiency.
- Evaluation components:
- Material: positional weights per square
- Mobility: relative number of legal moves available
- Stability: discs that can never be flipped (corners, filled edges, enclosed interior)
- Frontier: discs adjacent to empty squares (fewer is better)
- Dynamic danger correction: static penalties for X/C-squares are lifted when the adjacent corner is already owned, since those squares are no longer a liability.