https://github.com/jovialen/xadrez
A chess engine in Rust
https://github.com/jovialen/xadrez
chess chess-engine crate evaluation fen library move-generator rust
Last synced: over 1 year ago
JSON representation
A chess engine in Rust
- Host: GitHub
- URL: https://github.com/jovialen/xadrez
- Owner: jovialen
- License: apache-2.0
- Created: 2023-01-01T20:34:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-20T07:54:21.000Z (about 3 years ago)
- Last Synced: 2025-01-20T20:52:33.170Z (over 1 year ago)
- Topics: chess, chess-engine, crate, evaluation, fen, library, move-generator, rust
- Language: Rust
- Homepage:
- Size: 13.3 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Xadrez
[](https://github.com/jovialen/xadrez/actions/workflows/rust.yml)
A chess engine written in Rust.
## Usage
**Xadrez** uses Rusts built-in package manager [Cargo](https://doc.rust-lang.org/cargo/).
To use **Xadrez** in your projects, first include it as a dependency in your `Cargo.toml`.
```toml
[dependencies]
xadrez = { path = "path/to/xadrez" }
xadrez = { git = "https://github.com/jovialen/xadrez" }
```
```rust
use xadrez::prelude::*;
use xadrez::search::MoveSearcher;
use std::time::Duration;
fn main() {
let chessboard = Chessboard::default();
let moves: Vec = chessboard.moves();
let pieces: Vec<(Piece, Square)> = chessboard.pieces();
chessboard.make_move(moves[1]);
let fen = chessboard.to_string();
chessboard.set_position("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
chessboard.make_move(Move::from_str("e2e4"));
println!("{}", chessboard.evaluate());
let best_move = MoveSearcher::new(&chessbboard)
.max_depth(10)
.max_time(Duration::from_secs(5))
.search()
.expect("Failed to find move");
chessboard.make_move(best_move);
}
```
Use the `cargo doc` command to generate the full documentation.
## Tests
To run the full test suite, run [Cargos](https://doc.rust-lang.org/cargo/) test command.
```console
foo@bar:~$ cargo test
```
It is also recommended to use the `--release` flag as some of the tests take a long time to run.
## Benchmarks
**Xadrez** also has benchmarks which you can use to test the performance of the engine on your system.
```console
foo@bar:~$ cargo bench
```