6 stable releases

new 2.2.1 Jan 10, 2025
2.1.0 Jan 3, 2025
2.0.0 Nov 14, 2024
1.0.1 Aug 24, 2024

#372 in Games

Download history 20/week @ 2024-09-18 21/week @ 2024-09-25 6/week @ 2024-10-02 123/week @ 2024-11-13 8/week @ 2024-11-20 1/week @ 2024-11-27 4/week @ 2024-12-04 3/week @ 2024-12-11 114/week @ 2025-01-01

118 downloads per month

MIT/Apache

180KB
3.5K SLoC

rchess

A Chess Library Written in Rust


rchess is a Rust-based library designed for applications that need to work with chess games or boards, such as UCI GUIs or online chess platforms.

If you encounter any bugs, have suggestions for improving code readability or performance, or would like to contribute, we encourage you to create a pull request. For significant API changes or feature requests, please open an issue on GitHub.


Getting Started

Documentation for rchess can be found here.

Installation

Add the following to your Cargo.toml:

[dependencies]
rchess = "2.2.0"

Usage Example

use rchess::ChessGame;

fn main() {
    // Create a new chess game.
    let mut game = ChessGame::new();
    
    // Get the legal moves for the current position.
    let moves = game.moves();
    
    // Make a move.
    game.make_move(moves[0]);
}

Features

By default, no features are enabled.

To use magic bitboards for sliding piece move generation, enable the magic-table feature. On my device, this feature speeds up the benches by around 18%.

Build times will be faster without the magic-table feature enabled.

Improving Build Time

To improve the slow build time when the magic-table is enabled, set your build override opt-level to 3.

[profile.dev.build-override]
opt-level = 3

[profile.test.build-override]
opt-level = 3

[profile.release.build-override]
opt-level = 3

Contributing

We welcome contributions! Please adhere to the following guidelines:

  • Bug Reports & Feature Requests: Open an issue on the GitHub Issues page.
  • Code Contributions: Fork the repository and create a pull request.

License

This project is dual-licensed under the MIT and APACHE 2.0 licenses.


Dependencies

~275–740KB
~17K SLoC