Expand description
§Rust Chess Library
This is a chess move generation library for rust. It is designed to be fast, so that it can be used in a chess engine or UI without performance issues.
§Example
This generates all the moves on the starting chess position, and checks that the number of moves is correct.
use chess::{Board, MoveGen};
let board = Board::default();
let movegen = MoveGen::new_legal(&board);
assert_eq!(movegen.len(), 20);Structs§
- A good old-fashioned bitboard You do have access to the actual value, but you are probably better off using the implemented operators to work with this object.
- A representation of a chess board. That’s why you’re here, right?
- Represents a chess position that has not been validated for legality.
- Store a cache of entries, each with an associated hash.
- Represent a ChessMove in memory
- For UI/UCI Servers, store a game object which allows you to determine draw by 3 fold repitition, draw offers, resignations, and moves.
- An incremental move generator
- Represent a square on the chess board
Enums§
- Contains all actions supported within the game
- What is the status of this game?
- What castle rights does a particular player have?
- Represent a color.
- Sometimes, bad stuff happens.
- Describe a file (column) on a chess board
- What was the result of this game?
- Represent a chess piece as a very simple enum
- Describe a rank (row) on a chess board
Constants§
- Enumerate all castle rights.
- List all colors
- Enumerate all files
- An array representing each piece type, in order of ascending value.
- Enumerate all ranks
- A list of every square on the chessboard.
- What are all the edge squares on the
BitBoard? - An empty bitboard. It is sometimes useful to use !EMPTY to get the universe of squares.
- How many different types of
CastleRightsare there? - How many colors are there?
- How many files are there?
- How many piece types are there?
- How many ways can I promote?
- How many ranks are there?
- How many squares are there?
- What pieces can I promote to?
Functions§
- Get a line between these two squares, not including the squares themselves.
- This is now a no-op. It does not need to be called anymore.
- Get a
BitBoardthat represents the squares on the 1 or 2 files next to this file. - Get the moves for a bishop on a particular square, given blockers blocking my movement.
- Get the rays for a bishop on a particular square.
- Get a
BitBoardthat represents all the squares on a particular file. - Get the king moves for a particular square.
- Get the knight moves for a particular square.
- Get the pawn capture move for a particular square, given the pawn’s color and the potential victims
- Get all the pawn moves for a particular square, given the pawn’s color and the potential blocking pieces and victims.
- Get the quiet pawn moves (non-captures) for a particular square, given the pawn’s color and the potential blocking pieces.
- Get a
BitBoardthat represents all the squares on a particular rank. - Get the moves for a rook on a particular square, given blockers blocking my movement.
- Get the rays for a rook on a particular square.
- Get a line (extending to infinity, which in chess is 8 squares), given two squares. This line does extend past the squares.