Introducing LazyChess: Chess Engine Library in Rust ♟️
Hello Rustaceans
After months of development, I’m happy to share LazyChess, a fast and memory-efficient chess engine library written in Rust. My goal was to create a chess engine that fully supports the FIDE ruleset and works well in performance-critical applications. The library implements everything from castling, en passant, pawn promotion, to advanced features like FEN/PGN serialization, opening detection, and UCI engine communication also Human Move Clasifications Analysis
Features:
- Full FIDE Rules: Implements castling, en passant, pawn promotion, and all draw conditions (including threefold repetition, insufficient material, etc.).
- FEN/PGN Support: Easily serialize chess positions and games with FEN and PGN.
- UCI Compatibility: Communicate with UCI-compatible engines like Stockfish for advanced game analysis.
- Opening Detection: Built-in ECO table for detecting openings, and support for custom opening books.
- Move History: Track full game history with undo/redo support.
- Move Analysis: Evaluate moves and classify them based on engine evaluation.
- Draw Detection: Handle special cases like the 50-move rule and insufficient material.
Installation:
I have published two versions to crates.io, you can install via cargo:
cargo add lazychess
Heres a simple example showing how you can use LazyChess to play a few moves and display the board:
use lazychess::Game;
fn main() {
let mut game = Game::new();
let moves = ["e2e4", "e7e5", "g1f3", "b8c6", "f1b5"];
for mv in &moves {
game.do_move(mv).expect("move should be legal");
}
println!("{}", game.display_board());
println!("Opening : {:?}", game.opening_name());
println!("Status : {}", game.get_game_status_str());
println!("FEN : {}", game.get_fen());
println!("PGN : {}", game.get_pgn());
}
Feedback:
LazyChess is still in its early development stages, so any feedback or suggestions are highly appreciated! If you encounter bugs or have ideas for new features, feel free to visit the issues page or contribute directly.
Repository: https://github.com/OhMyDitzzy/LazyChess