Crate hexe_core [−] [src]
This crate defines the core building blocks for the Hexe chess engine.
Usage
This crate is available on crates.io and can be used by adding the
following to your project's Cargo.toml
:
[dependencies]
hexe_core = "0.0.3"
and this to your crate root:
extern crate hexe_core;
Board Representation
There are two primary chess board representations provided. Both have various advantages and disadvantages, which are outlined below:
Bitboard
Mapping: bit-to-square
Advantages:
-
Throughput—excellent for performing parallel operations on the board
-
Checking whether a file is empty
-
Generating moves for all pieces
-
Disadvantages:
-
Size—larger overall memory cost
-
A common compact way of representing all pieces with bitboards is to have 6 ×
PieceKind
bitboards and 2 ×Color
bitboards. This results in (2 + 6) × 8 = 64 bytes used to represent all pieces. -
Using 12 ×
Piece
bitboards is another representation of the entire chess board. This results in 12 × 8 = 96 bytes used to represent all pieces. -
Operations are often done using 64-bit (8 byte) integers
-
PieceMap
Mapping: byte-to-square
Advantages:
-
Latency—great for performing instantaneous operations on the board
- Finding whether a square is empty or otherwise what piece sits on it
-
Size—lower overall memory cost
- Operations usually done with a few bytes
Disadvantages:
-
Size—larger upfront memory cost
- Uses exactly 64 bytes for each square on the board and its piece
Modules
board |
Various board representations. |
castle |
Castling rights for two players of a chess game. |
color |
A color to represent pieces or board squares. |
fen |
Forsyth–Edwards Notation parsing. |
iter |
Iterators over types. |
misc |
Miscellaneous traits and types. |
piece |
A piece used to play chess. |
prelude |
The Hexe core prelude imports various primitives and traits that may be used often when interacting with this crate. |
square |
A chess board square and its components. |