1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! Various board types.
//!
//! ## Board Representation
//!
//! There are three chess board representations provided. They each 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 × [`Role`] bitboards and 2 × [`Color`] bitboards. This
//!       results in (2 + 6) × 8 = 64 bytes used to represent all pieces.
//!
//!       This is how [`MultiBoard`] works.
//!
//!     - Using 12 × [`Piece`](../piece/enum.Piece.html) 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.
//!
//! ### [`MultiBoard`]
//!
//! **Mapping:** [`Color`]/[`Piece`]/[`Role`] to [`Bitboard`]
//!
//! **Advantages:**
//!
//! - Lookup—_very fast_ square retrieval:
//!
//!   ```
//!   # use hexe_core::board::MultiBoard;
//!   # use hexe_core::prelude::*;
//!   let board = MultiBoard::STANDARD;
//!
//!   let king = board.first(Piece::WhiteKing).unwrap();
//!   println!("White king found at {}", king);
//!
//!   for sq in board.bitboard(Color::White) {
//!       println!("A white piece at {}", sq);
//!   }
//!   ```
//!
//! **Disadvantages:**
//!
//! - Checking—slow to find the piece at a square
//!
//! ### [`PieceMap`]
//!
//! **Mapping:** [`Piece`] 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
//!
//! [`Bitboard`]: bitboard/struct.Bitboard.html
//! [`MultiBoard`]: multi_board/struct.MultiBoard.html
//! [`PieceMap`]: piece_map/struct.PieceMap.html
//!
//! [`Color`]: ../color/enum.Color.html
//! [`Piece`]: ../piece/enum.Piece.html
//! [`Role`]: ../piece/enum.Role.html
//! [`Square`]: ../square/enum.Square.html

pub mod bitboard;
pub mod multi_board;
pub mod piece_map;

#[doc(inline)] pub use self::bitboard::Bitboard;
#[doc(inline)] pub use self::multi_board::MultiBoard;
#[doc(inline)] pub use self::piece_map::PieceMap;