Skip to main content

Crate ai_othello

Crate ai_othello 

Source
Expand description

§ai-othello

An Othello rules and search library with bitboards and complete pass handling.

You can play against it compiled to Wasm here: https://thegustafson.com/games/othello

§Self-play

The selfplay binary runs deterministic paired-color matches. Each opening is played twice with the engines swapping Black and White.

cargo run --release --bin selfplay -- \
  --a maximum --b expert --games 12 --opening-plies 8 --seed 1

The six built-in profiles are beginner, easy, medium, hard, expert, and maximum. They progressively increase ordinary search depth and introduce an empty-square threshold where the engine solves the rest of the game exactly. Use the --a-* and --b-* options shown by selfplay --help to override them. Library users can read the same settings with search_preset or SEARCH_PRESETS.

§Use it

Add the crate to your project:

[dependencies]
ai-othello = "0.1"
use ai_othello::{EvaluationProfile, Position, SearchConfig, search};

let position = Position::default();
let config = SearchConfig::fixed_depth(5, EvaluationProfile::Phase);
let result = search(position, config);

assert!(result.best_move.is_some());

The crate includes reversible moves, perft, phase-aware evaluation, alpha-beta search, exact endgame search, and a Cassio protocol adapter.

cargo test
cargo run
cargo run -- --cassio

Licensed under the MIT License.

Modules§

verification
Slow reference code used to verify the bitboard implementation.

Structs§

Candidate
CassioEngine
Line-oriented adapter for Cassio’s ENGINE-PROTOCOL.
Engine
One line-oriented engine session shared by the browser and native binary.
Evaluation
Traceable position evaluation from the current side’s perspective.
EvaluationWeights
MoveList
Fixed-capacity list large enough for every Othello move.
Position
Two disjoint bitboards and the side whose transition comes next.
Score
Search score with exact results kept outside the heuristic band.
SearchConfig
SearchPreset
A named search depth and exact-endgame threshold for interactive play.
SearchReport
Complete result of one search.
SearchStats
Square
One square, with a1 as the least-significant bit.
Undo

Enums§

EvaluationProfile
Cumulative evaluator stages used by the controlled browser experiment.
GameResult
Move
Othello pass is a real move because it changes the side to move.
MoveError
ScoreKind
Side

Constants§

SEARCH_PRESETS
The built-in strength ladder, ordered from least to most search work.

Functions§

evaluate
Evaluates position from its side-to-move perspective.
perft
Counts legal move sequences to exactly depth plies with the bitboard core.
search
Searches position to the configured depth.
search_preset
Finds a built-in strength preset by its lowercase name.
search_until
Search a fixed depth while polling a cooperative stop signal at node entry. A stopped partial result is discarded.