Crate owlchess

Source
Expand description

§Yet another Rust chess library

§🦉🦉🦉

Owlchess is a chess library written in Rust, with emphasis on both speed and safety. Primarily designed for various chess GUIs and tools, it’s also possible to use Owlchess to build a fast chess engine.

The code is mostly derived from my chess engine SoFCheck, but rewritten in Rust with regard to safety.

This crate supports core chess functionality:

  • generate moves
  • make moves
  • calculate game outcome
  • parse and format boards in FEN
  • parse and format moves in UCI and SAN

§Example

use owlchess::{Board, movegen::legal, Move};
use owlchess::{Coord, File, Rank};

// Create a board with initial position
let b = Board::initial();

// Generate all the legal moves
let moves = legal::gen_all(&b);
assert_eq!(moves.len(), 20);

// Parse move "e2e4" from UCI string
let mv = Move::from_uci("e2e4", &b).unwrap();
let e2 = Coord::from_parts(File::E, Rank::R2);
let e4 = Coord::from_parts(File::E, Rank::R4);
assert_eq!(mv.src(), e2);
assert_eq!(mv.dst(), e4);

// Create a new board with made move `mv`
let b = b.make_move(mv).unwrap();
assert_eq!(b.as_fen(), "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1");

Re-exports§

pub use board::Board;
pub use board::RawBoard;
pub use chain::MoveChain;
pub use movegen::MoveList;
pub use movegen::MovePush;
pub use moves::Make;
pub use moves::Move;
pub use moves::MoveKind;

Modules§

bitboard
Bitboard-related stuff
board
Board and related things
chain
Board that remembers previous moves
movegen
Move generation and related things
moves
Moves and related stuff
types
Core chess types

Structs§

Bitboard
Bitmask on chess board
CastlingRights
Flags specifying allowed castling sides for both white and black
Cell
Contents of square on a chess board
Coord
Coordinate of a square

Enums§

CastlingSide
Castling side (either queenside or kingside)
Color
Color of chess pieces (either white or black)
DrawReason
Reason for game finish with draw
File
File (i. e. a vertical line) on a chess board
GameStatus
Short status of the game (either running of finished)
Outcome
Outcome of the finished game
Piece
Kind of chess pieces (without regard to piece color)
Rank
Rank (i. e. a horizontal line) on a chess board
WinReason
Reason for game finish with win