https://github.com/bungogood/bkgm
Rust crate for Backgammon, providing move generation, position parsing, and support for Backgammon and Hypergammon, including a perfect hash for bearoff and hypergammon databases.
https://github.com/bungogood/bkgm
backgammon rust rust-library
Last synced: about 2 months ago
JSON representation
Rust crate for Backgammon, providing move generation, position parsing, and support for Backgammon and Hypergammon, including a perfect hash for bearoff and hypergammon databases.
- Host: GitHub
- URL: https://github.com/bungogood/bkgm
- Owner: bungogood
- License: mit
- Created: 2023-09-19T13:13:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T10:42:40.000Z (about 1 year ago)
- Last Synced: 2025-11-22T09:03:16.210Z (5 months ago)
- Topics: backgammon, rust, rust-library
- Language: Rust
- Homepage: https://crates.io/crates/bkgm
- Size: 118 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bkgm
[](../../actions/workflows/build.yaml)
Bkgm is a versatile Rust crate designed to facilitate Backgammon-related operations, such as move generation, position parsing, conversion between standards, and the implementation of the [perfect hash](https://api.semanticscholar.org/CorpusID:60574812) for bearoff and hypergammon databases. It supports both traditional Backgammon and 3-checker Hypergammon and provides the foundation for building Backgammon engines or APIs.
## Example Position
Here's a visual representation of the starting position in Backgammon:
```plaintext
Position ID: 4HPwATDgc/ABMA
┌13─14─15─16─17─18─┬───┬19─20─21─22─23─24─┬───┐
│ X O │ │ O X │ │
│ X O │ │ O X │ │
│ X O │ │ O │ │
│ X │ │ O │ │
│ X │ │ O │ │
│ │BAR│ │OFF│
│ O │ │ X │ │
│ O │ │ X │ │
│ O X │ │ X │ │
│ O X │ │ X O │ │
│ O X │ │ X O │ │
└12─11─10──9──8──7─┴───┴─6──5──4──3──2──1─┴───┘
```
## Features
- Support for the Gnubg position id format.
- Ability to generate possible positions.
- Macros to create Backgammon and Hypergammon positions.
- State trait implemented for both Backgammon and Hypergammon.
## TODO
- Move generation (next possible position generation is already implemented).
- Move parsing (e.g., 24/23*/22*/21\*).
- Improve test coverage.
- Add a game trait, enabling Mat files.
- Addition of optional rules
- Improve macros to work with bar and off
## References
- Bkgm [Documentation](https://docs.rs/bkgm/latest/bkgm)
- Backgammon [Wikipedia](https://en.wikipedia.org/wiki/Backgammon)
- [Wildbg](https://github.com/carsten-wenderdel/wildbg) by [Carsten Wenderdel](https://github.com/carsten-wenderdel/wildbg)
- [Enumerating Backgammon Positions: The Perfect Hash (1997)](https://api.semanticscholar.org/CorpusID:60574812) by A. T. Benjamin and A. M. Ross