Fenex Chess Library
A fast and reliable chess engine in Rust with full rule implementation and FEN support.
Quick Start
Add to your Cargo.toml:
[]
= "0.1.10"
Basic Usage
use Board;
use Coordinates;
// Load position from FEN
let mut board = from_fen.unwrap;
// Make a move (e2 to e4)
board.apply_move.unwrap;
// Generate all legal moves
let moves = board.generate_legal_moves;
println!;
// Export back to FEN
println!;
Architecture
Coordinates
- 1-indexed system (a1 = Coordinates::new(1,1))
- Conversion to/from algebraic notation
Board
- 8x8 array representation
- FEN import/export
- Legal move validation
- Special moves (castling, en passant, promotion)
Pieces
- All standard chess pieces with proper movement rules
- Color and piece type tracking
Examples
Basic Game Setup
use Board;
use Coordinates;
// Start new game
let mut board = new;
// Or load from FEN
let mut board = from_fen.unwrap;
Making Moves
// Move piece from e2 to e4
let from = new;
let to = new;
board.apply_move.unwrap;
// Check if move is legal first
let legal_moves = board.generate_legal_moves;
if legal_moves.contains
Special Moves
// Castling (automatically moves rook)
board.apply_move.unwrap;
// En passant capture
board.apply_move.unwrap;
// Pawn promotion - multiple options available
// Default promotion (to Queen)
board.apply_move.unwrap;
// Specific promotion options
board.promote_to_queen.unwrap;
board.promote_to_rook.unwrap;
board.promote_to_bishop.unwrap;
board.promote_to_knight.unwrap;
// Or use apply_move_with_promotion for more control
board.apply_move_with_promotion.unwrap;
Testing
Run the test suite:
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Run
cargo fmtandcargo clippy - Submit a pull request