SortedMoveAdder

Struct SortedMoveAdder 

Source
pub struct SortedMoveAdder<'a> { /* private fields */ }
Expand description

SortedMoveAdder collects moves including the piece-square score for making the move Moves are sorted by an ‘ordering score’ and stored in a provided SortedMoveHeap

Non-captures are ordered by priotising destination squares that are further up the board relative to the mover, with a bonus for pawns near promotion, a handicap for non-pawn moves to rank 1, and a handicap for pawn moves to low ranks.

Captures are ordered by most-valuable-victim / least-valuable-aggresor with piece scores worth: Pawn: 0 King: 1 (can only be aggresor) Knight: 2 Bishop: 3 Rook: 4 Queen: 5

Move ordering priorities: -250: promotion to bishop -200: promotion to rook -145..-145: capture and promotion to bishop (exact score based on MVV-LVA) -105..-95: capture and promotion to rook (exact score based on MVV-LVA) 0: non-pawn to rank 1 1: - 2: pawn to rank 3 3: pawn to rank 4, non-pawn to rank 2 4: pawn to rank 5, non-pawn to rank 3 5: non-pawn to rank 4 6: non-pawn to rank 5 7: non-pawn to rank 6 8: non-pawn to rank 7 9: non-pawn to rank 8 10: pawn to rank 6 11: pawn to rank 7 20: castle 25: promotion to knight 50: promotion to queen 95..105: capture (exact score based on MVV-LVA) 120..130: capture and promotion to knight (exact score based on MVV-LVA) 145..155: capture and promotion to queen (exact score based on MVV-LVA)

Note: rook and bishop promotions are penalized because queen promotion is nearly always a better choice

Implementations§

Source§

impl<'a> SortedMoveAdder<'a>

Source

pub fn new( piece_square_table: &'a PieceSquareTable, piece_grid: &'a [Piece; 64], stm: Side, moves: &'a mut SortedMoveHeap, ) -> SortedMoveAdder<'a>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<'a> Debug for SortedMoveAdder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Display for SortedMoveAdder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> MoveAdder for SortedMoveAdder<'a>

Source§

fn add_captures(&mut self, from: Square, targets: BB)

Source§

fn add_non_captures(&mut self, from: Square, targets: BB)

Source§

fn add_castle(&mut self, castle: Castle)

Adds the castle to the move list
Source§

fn add_pawn_ep_capture(&mut self, from: Square, to: Square)

Adds pawn en-passant capture to list. From and to are the squares the moving pieces moves from and to, respectively
Source§

fn add_pawn_pushes(&mut self, shift: usize, targets: BB)

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).
Source§

fn add_pawn_captures(&mut self, shift: usize, targets: BB)

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)

Auto Trait Implementations§

§

impl<'a> Freeze for SortedMoveAdder<'a>

§

impl<'a> RefUnwindSafe for SortedMoveAdder<'a>

§

impl<'a> Send for SortedMoveAdder<'a>

§

impl<'a> Sync for SortedMoveAdder<'a>

§

impl<'a> Unpin for SortedMoveAdder<'a>

§

impl<'a> !UnwindSafe for SortedMoveAdder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V