Crate backgammon

Crate backgammon 

Source
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
  • Jacoby
  • Crawford
  • Holland

§Examples

Start a new backgammon match over the default number of points and with the default rules, as defined in Rules:

use backgammon::Match;

let mut m = Match::new();

Typically, you want to define the points for a match, hence:

use backgammon::Match;
use backgammon::rules::MatchRules;

let mut m = Match::new().
with_points(13);

Depending on the style of tournament you decide to play, it makes sense to select one or more rules too:

use backgammon::Match;
use backgammon::rules::{MatchRules, GameRules};

let mut m = Match::new();
m.with_points(13).unwrap();
m.with_jacoby().unwrap();

Play a game by calling:

use backgammon::Game;
use backgammon::rules::{Roll,GameRules};

let mut g = Game::new();

// roll dices
g.roll();

§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§

rules
Implements the board, the dices, the cube, and all other Backgammon rules.
stats
Implements statistics.

Structs§

Game
Represents a Backgammon game.
Match
Represents a Backgammon match.

Enums§

Error
Stores all possible Backgammon game error types.