backgammon

Crates.iobackgammon
lib.rsbackgammon
version0.6.0
sourcesrc
created_at2017-12-03 22:56:35.386916
updated_at2023-08-13 10:47:14.349455
descriptionThe Rust Backgammon library
homepage
repositoryhttps://github.com/carlostrub/backgammon
max_upload_size
id41623
size45,799
Carlo Strub (carlostrub)

documentation

https://docs.rs/backgammon

README

Maintenance

backgammon

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 rules on the doubling cube are supported:

  • Beaver
  • Raccoon
  • Murphy
  • Jacoby
  • Crawford
  • Holland

Examples

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

use backgammon::r#match::Match;

let mut m = Match::new();

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

use backgammon::r#match::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::r#match::Match;
use backgammon::rules::{MatchRules, GameRules};

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

Play a game by calling:

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

let mut g = Game::new();

// set rules
g = g.with_beaver().with_raccoon().with_murphy(3).with_jacoby().with_holland();

// roll dices
let g = g.roll();

Design Philosophy

This library is designed to offer completely stateless game functions. This means that it should be easy to implement wrappers using this library in combination with some databases to store the game state.

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.

You can also find me on:

IRC: #backgammon @ libera.chat (via webchat)

License: BSD-2-Clause

Commit count: 133

cargo fmt