chess_move_gen/mv_list/
mod.rs

1use crate::bb::BB;
2use crate::castle::Castle;
3use crate::square::Square;
4
5mod mv_counter;
6mod mv_vec;
7mod piece_square_table;
8mod sorted_move_adder;
9
10pub use self::mv_counter::MoveCounter;
11pub use self::mv_vec::MoveVec;
12pub use self::piece_square_table::PieceSquareTable;
13#[allow(unused_imports)]
14pub use self::sorted_move_adder::{SortedMoveAdder, SortedMoveHeap, SortedMoveHeapItem};
15
16/// MoveAdder represents a way to collect moves from move generation functions
17/// Implementations:
18///   MoveCounter (count moves only)
19///   MoveVec (adds move to Vec)
20///   SortedMoveAdder (adds moves along with piece-square-scores to a sorted binary heap)
21pub trait MoveAdder {
22    fn add_captures(&mut self, from: Square, targets: BB);
23    fn add_non_captures(&mut self, from: Square, targets: BB);
24
25    /// Adds the castle to the move list
26    fn add_castle(&mut self, castle: Castle);
27
28    /// Adds pawn non-captures to the list. Targets is a bitboard of valid to-squares. Shift is the distance the pawn moved to get to the target square, mod 64. For example, for a white piece moving forward one row this is '8'. For a black piece moving forward one row this is 56 (-8 % 64).
29    fn add_pawn_pushes(&mut self, shift: usize, targets: BB);
30
31    /// Adds pawn captures to list. Targets and shift are same as for `add_pawn_pushes`. Do not use this for en-passant captures (use `add_pawn_ep_capture`)
32    fn add_pawn_captures(&mut self, shift: usize, targets: BB);
33
34    /// Adds pawn en-passant capture to list. From and to are the squares the moving pieces moves from and to, respectively
35    fn add_pawn_ep_capture(&mut self, from: Square, to: Square);
36}