| Crates.io | rust_reversi_core |
| lib.rs | rust_reversi_core |
| version | 1.0.2 |
| created_at | 2025-01-12 05:57:02.829457+00 |
| updated_at | 2025-02-07 13:51:41.382964+00 |
| description | A Rust library for the game of Reversi including AI players and arena for playing games. |
| homepage | |
| repository | https://github.com/neodymium6/rust_reversi_core |
| max_upload_size | |
| id | 1512977 |
| size | 177,661 |
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.
This project provides:
Multiple AI strategies are implemented:
You can also use your own Evaluator that implements the Evaluator trait.
cargo add rust_reversi_core
Basic usage:
use rust_reversi_core::board::Board;
// Create a new board
let mut board = Board::new();
// Get legal moves
let legal_moves = board.get_legal_moves_vec();
// Make a move
board.do_move(legal_moves[0]).unwrap();
Using AI players:
use rust_reversi_core::search::{AlphaBetaSearch, MatrixEvaluator};
// Setup evaluator and search
let evaluator = MatrixEvaluator::new(matrix);
let search = AlphaBetaSearch::new(depth, Arc::new(evaluator));
// Get best move
let best_move = search.get_move(&board);
Running local games:
use rust_reversi_core::arena::LocalArena;
let mut arena = LocalArena::new(command1, command2, true);
arena.play_n(100).unwrap();
let (wins1, wins2, draws) = arena.get_stats();
Network games:
use rust_reversi_core::arena::{NetworkArenaServer, NetworkArenaClient};
// Server
let mut server = NetworkArenaServer::new(100, true).unwrap();
server.start("127.0.0.1".to_string(), 12345).unwrap();
// Client
let mut client = NetworkArenaClient::new(command);
client.connect("127.0.0.1".to_string(), 12345).unwrap();
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 playersRun the test suite:
cargo test
The test suite includes both unit tests and integration tests with example AI players.
The project includes benchmarks for core functionality using Criterion:
cargo bench
Available benchmarks:
Board operations (board benchmark)
Search algorithms (search benchmark)
Each evaluator is tested with a small probability (ε=0.01) of making random moves to add variety.
MIT License
neodymium6
Contributions are welcome! Feel free to: