Fenex Chess Library
A fast and reliable chess engine in Rust with full rule implementation and FEN support.
Features
- ✅ Complete chess rules: castling, en passant, pawn promotion
- ✅ Legal move generation with check validation
- ✅ FEN parsing and serialization
- ✅ Coordinate system with algebraic notation support
- ✅ Comprehensive test suite
Quick Start
Add to your Cargo.toml:
[]
= "0.1.6"
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 (defaults to Queen)
board.apply_move.unwrap;
Testing
Run the test suite:
All chess rules are thoroughly tested including edge cases for special moves.
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Run
cargo fmtandcargo clippy - Submit a pull request