Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Pleco
Pleco is a Chess Library inspired by Stockfish, written entirely in Rust.
This project aims to utilize the efficiency of Rust to create a Chess Library & AI with the speed of modern chess engines.
This project is split into two crates, pleco
(the library you are currently in), which contains the library functionality, and pleco_engine
, which contains the
UCI (Universal Chess Interface) compatible Engine & AI.
Planned & Implemented features
The Library aims to have the following features upon completion
- Bitboard Representation of Piece Locations:
- Ability for concurrent Board State access, for use by parallel searchers
- Full Move-generation Capabilities, including generation of pseudo-legal moves
- Statically computed lookup-tables (including Magic Bitboards)
- Zobrist Hashing
- PGN Parsing
Use
To use Pleco inside your own Rust projects, Pleco.rs is available as a library on crates.io. nightly
rust is required to use.
Basic Usage
Setting up a board position is extremely simple.
use ;
let board = default;
assert_eq!;
assert_eq!;
Creating a board from a Position
A Board
can be created with any valid chess position using a valid FEN (Forsyth-Edwards Notation) String.
Check out the Wikipedia article for more information on FEN Strings
and their format.
let board = new_from_fen;
Applying and Generating Moves
Moves are represented with a BitMove
structure. They must be generated by a Board
object directly, to be
considered a valid move. Using Board::generate_moves()
will generate all legal BitMove
s of the current
position for the current player.
use ;
let mut board = default; // create a board of the starting position
let moves = board.generate_moves; // generate all possible legal moves
board.apply_move;
assert_eq!;
We can ask the Board to apply a move to itself from a string. This string must follow the format of a standard UCI Move, in the format [src_sq][dst_sq][promo]. E.g., moving a piece from A1 to B3 would have a uci string of "a1b3", while promoting a pawn would look something like "e7e81". If the board is supplied a UCI move that is either incorrectly formatted or illegal, false shall be returned.
let mut board = default; // create a board of the starting position
let success = board.apply_uci_move; // apply a move where piece on e7 -> eq, promotes to queen
assert!; // Wrong, not a valid move for the starting position
Undoing Moves
We can revert to the previous chessboard state with a simple Board::undo_move()
let mut board = default;
board.apply_uci_move; // A very good starting move, might I say
assert_eq!;
board.undo_move;
assert_eq!;
Contributing
Any and all contributions are welcome! Open up a PR to contribute some improvements. Look at the Issues tab to see what needs some help.
License
Pleco is distributed under the terms of the MIT license. See LICENSE-MIT for details. Opening a pull requests is assumed to signal agreement with these licensing terms.