Skip to main content

Crate magpie

Crate magpie 

Source
Expand description

Magpie is a high-performance Othello library built with bitboards and zero dependencies.

All core types live in the othello module, which offers two abstraction levels:

  • Game — rule-checked, turn-aware game logic and state management. Enforces legal moves and tracks turns.
  • Board — lower-level, unchecked board operations for maximum performance. Useful when building engines.

Supporting types include Bitboard and Position for board representation, Stone for player identity, and BoardDisplay for rendering boards.

§Getting Started

use magpie::othello::{Game, Status, Stone};

let mut game = Game::new();
// Black moves first in Othello
assert_eq!(game.current_turn(), Stone::Black);

// Pick the first available move and play it
let pos = game.moves().hot_bits().next().unwrap();
game.play(pos)?;

println!("{}", game.display());

assert_eq!(game.current_turn(), Stone::White);
assert_eq!(game.status(), Status::Progressing);

More examples are available in the examples directory, including a playable game against a random AI (cargo run --example human_vs_ai).

Modules§

othello
Contains core structures and functions for playing Othello