Expand description
§Backgammon: The Oldest Board Game in the World
This crate provides a pure, canonical implementation of the game Backgammon.
§Supported Doubling Cube Rules
The following doubling cube rules are supported:
- Beaver
- Raccoon
- Murphy
- Jacobi
- Crawford
- Holland
§Examples
§Creating a Match
To create a new backgammon match, load the prelude module and define a mutable match:
use backgammon::prelude::*;
let mut m = Match::new();
Depending on the style of tournament, it is possible to set any number of
rules:
use backgammon::prelude::*;
fn play_match() -> Result<(), Error> {
let mut m = Match::new();
m.set_points(13)?;
m.set_jacobi(true)?;
Ok(())
}§The first roll
In a physical game, both players roll with one die. Then, the higher roll defines the first player.
use backgammon::prelude::*;
fn play_match() -> Result<(), Error> {
let mut m = Match::new();
m.roll(Player::Nobody)?;
Ok(())
}§Playing an Example Game
To see this library in action, run the included example:
cargo run --example backgammon_tuiFor more examples, have a look at the examples directory.
§Design Philosophy
This library is designed to provide stateless Backgammon gameplay functionality. Because it does not track or store game states itself, you can easily implement wrappers that use this library along with an external database to manage and persist game states.
§Discussions and Support
Remember that the APIs are not stable yet. Any support is very welcome. Please open an Issue to discuss features or ask for help.
Modules§
- prelude
- Provides commonly used types and structures for ease of use in external modules. It is recommended to always use the prelude module for convenience.
- rules
- Implements the board, the dice, the cube, and all other Backgammon rules.
- stats
- Implements statistics.
Structs§
Enums§
- Error
- Stores all possible Backgammon game error types.
- Match
State - All the possible states of a match.