#othello #reversi #bitboard

magpie

Reasonably efficient Othello library built with bitboards

11 releases (breaking)

0.9.0 Jan 21, 2021
0.7.0 Jan 16, 2021
0.4.0 Dec 26, 2020
0.2.0 Nov 18, 2020

#197 in Algorithms

Download history 24/week @ 2021-04-02 18/week @ 2021-04-09 32/week @ 2021-04-16 35/week @ 2021-04-23 15/week @ 2021-04-30 2/week @ 2021-05-07 18/week @ 2021-05-14 45/week @ 2021-05-21 6/week @ 2021-05-28 52/week @ 2021-06-04 30/week @ 2021-06-11 3/week @ 2021-06-18 6/week @ 2021-06-25 6/week @ 2021-07-02 6/week @ 2021-07-09 17/week @ 2021-07-16

132 downloads per month
Used in 2 crates

MIT license

51KB
535 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. Do note that Reversi is a very similar game but with slightly different rules, currently not implemented in this library. However, magpie is flexible enough that it is possible to play Reversi as well, if the user is willing to do some additional bookkeeping.

Magpie is intentionally minimalistic and delegates some basic functionality to the user. For example, keeping track of the next player to play is handled by the user. The library is responsible for both calculating legal moves and updating the state of the board when one is applied. It does this reasonably efficiently by using bitboards to store the state of the board.

The library is intended to be consumed behind another abstraction which may keep track of the next player to play or cache various calculations.

Table of Contents

Documentation

Documentation is hosted on docs.rs

Usage

Add this to your Cargo.toml:

[dependencies]
magpie = "0.9.0"

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.9.0", 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

Performance is important, although is should be noted that it is not the most prioritized feature. 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

~205KB