Skip to content

Repository files navigation

Reversi AI Agent

Team project for a graduate Artificial Intelligence course. Placed 1st in both class tournaments.

Overview

A competitive Reversi (Othello) agent built for a head-to-head class tournament. Agents connect to a shared game server over a socket and play timed matches. We implemented and compared several decision strategies — from a greedy baseline through alpha-beta search and Monte-Carlo Tree Search to an AlphaZero-style deep reinforcement-learning player — and tuned the strongest configuration for competition.

Highlights

  • 1st place in both course tournaments.
  • Bitboard engine (bit_reversi.py). The board is encoded as two 64-bit integers (one per color), with move generation and piece-flipping implemented as bitwise operations and JIT-compiled with Numba. This made position evaluation dramatically faster, which let the alpha-beta search reach significantly greater depth within the per-move time limit — the main performance edge in the tournament.
  • Several interchangeable agents that all speak the same socket protocol to the game server, so strategies can be swapped and benchmarked against each other.

Agents

File Strategy
greedy_player.py One-ply greedy baseline (maximizes immediate flips).
pruning_player.py Minimax with alpha-beta pruning.
pruning_player_weighted.py Alpha-beta with positional/weighted board heuristics.
pruning_player_timed.py Alpha-beta with iterative deepening under a time budget.
bit_board_pruning_player.py, bit_board_pruning_player_v2.py Alpha-beta on top of the bitboard engine for deeper search.
mcts_player.py Monte-Carlo Tree Search (UCT).
deep_player.py AlphaZero-style policy/value network guiding MCTS, using a pretrained 8x8 Othello model.

Architecture

agent (*_player.py)  <-- socket -->  reversi_server.py  <-- socket -->  opponent agent

Each agent receives the current board and whose turn it is, computes a move within the time limit, and sends it back. multi_game_test.py runs many games head-to-head for evaluation.

Tech

Python · NumPy · Numba (JIT-compiled bitboard) · PyTorch (AlphaZero network) · sockets

Running

Start the game server, then connect agents to it (each in its own terminal):

python reversi_server.py
python bit_board_pruning_player_v2.py
python mcts_player.py

Credits & attribution

Team project for a graduate AI course; collaborators included HEZR0N, jdelarosaquiros, johne16, and Fernando Canseco (bitboard search optimization). The tournament game server (reversi_server.py, reversi_server_iterative.py) was provided by the course. The deep-RL component adapts alpha-zero-general by Surag Nair, used under the MIT License (retained in alpha_zero_general/LICENSE).

About

Competitive Reversi/Othello agent (MCTS, alpha-beta pruning, Numba bitboard engine, AlphaZero-style deep RL). 1st place in both class tournaments.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages