rust_reversi_core
A Rust library for the game of Reversi (Othello) including game engine, AI players, and arena for playing games.
This is also the core implementation for rust_reversi.
See also the documentation.
Overview
This project provides:
- Complete Reversi game rule engine
 - Multiple AI player implementations
 - Arena for playing games (both local and network)
 - Alpha-beta search engine implementation
 
Features
Board Engine
- 8x8 Reversi board management
 - Legal move validation
 - Move execution and piece flipping
 - Pass detection
 - Win condition checking
 - Fast bitboard-based implementation
 
AI Players
Multiple AI strategies are implemented:
- Random Player - Makes random legal moves
 - Piece Evaluator - Evaluates based on piece count difference
 - Matrix Evaluator - Uses position weights for evaluation
 
You can also use your own Evaluator that implements the Evaluator trait.
Arena Features
- Local game support
 - Network play over TCP/IP
 - Automatic execution of multiple games between players
 - Statistics collection (win rates, piece counts)
 - Progress bar visualization
 
Search Engine
- Alpha-beta pruning implementation
 - Iterative deepening
 - Timeout control
 - Pluggable evaluation functions
 
Installation
Usage
Basic usage:
use Board;
// Create a new board
let mut board = new;
// Get legal moves
let legal_moves = board.get_legal_moves_vec;
// Make a move
board.do_move.unwrap;
Using AI players:
use ;
// Setup evaluator and search
let evaluator = new;
let search = new;
// Get best move
let best_move = search.get_move;
Arena Usage
Running local games:
use LocalArena;
let mut arena = new;
arena.play_n.unwrap;
let  = arena.get_stats;
Network games:
use ;
// Server
let mut server = new.unwrap;
server.start.unwrap;
// Client
let mut client = new;
client.connect.unwrap;
Project Structure
src/board.rs- Core game logic and board representationsrc/search/- Search algorithms and evaluation functionssrc/arena/- Local and network game coordinationtests/- Test cases and example players
Testing
Run the test suite:
The test suite includes both unit tests and integration tests with example AI players.
Benchmarking
The project includes benchmarks for core functionality using Criterion:
Available benchmarks:
- 
Board operations (
boardbenchmark)- Full game playthrough with random moves
 
 - 
Search algorithms (
searchbenchmark)- Alpha-beta search with various evaluators (depth 4):
- Piece count evaluator
 - Legal moves evaluator
 - Matrix-based evaluator
 - Custom evaluator example
 
 
 - Alpha-beta search with various evaluators (depth 4):
 
Each evaluator is tested with a small probability (ε=0.01) of making random moves to add variety.
License
MIT License
Author
neodymium6
Contributing
Contributions are welcome! Feel free to:
- Report bugs
 - Suggest features
 - Submit pull requests