#bitboard #othello #reversi #board-game #game-engine

magpie

Reasonably efficient Othello library built with bitboards

14 releases (breaking)

0.11.0 Feb 15, 2023
0.10.0 Sep 15, 2022
0.9.1 Oct 25, 2021
0.9.0 Jan 21, 2021
0.2.0 Nov 18, 2020

#1 in #othello

26 downloads per month
Used in 2 crates

MIT license

67KB
975 lines

CI status Latest version

Magpie

Magpie is a simple Othello library written in Rust. Othello is a perfect information, zero-sum game for two players.

Magpie is built with bitboards which allows for extremely fast updates and queries. Two abstraction levels are available, the higher level Game and lower-level Board. The Game-struct guarantees that only legal moves will be made and that the board will be kept consistent. The drawback is that it is not as flexible as the alternative, or as performant. The Board-struct does not keep track of whose turn it is, whether a player passed their turn, or validates inputs, which makes it better suited for engines.

Magpie is built with bitboards which allows for extremely fast updates and queries. Two abstraction levels are available. The higher abstraction level guarantees that only legal moves will be made and that the board will be kept consistent. The drawback is that it is not as flexible or performant as the alternative. The lower abstraction level does not keep track of whose turn it is, whether a player passed their turn, or validates inputs, which makes it better suited for engines.

Table of Contents

Documentation

Documentation is hosted on docs.rs

Usage

Simply run:

cargo add magpie

Alternatively, add this to your Cargo.toml:

[dependencies]
magpie = "0.11"

Crate features

Serialization with Serde is not supported by default. If you want to opt into using magpie with Serde you can enable a feature flag. Simply change your magpie dependency to the following:

[dependencies]
magpie = {version = "0.11", features = ["serde"]}

Examples

Examples are found here.

Included as an example is a functional game which allows you to play Othello against a random AI. To start the game, run the following command:

cargo run --example human_vs_ai

Benchmarks

Benchmarks are found here

These benchmarks are here to guide improvements of the current algorithms as well as the implementation of new features.

Simply run cargo bench to run all benchmarks.

Dependencies

~180KB