From e08dd1256b8a6d8197e56867b43b47a92aadd1a7 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 31 Aug 2023 11:35:22 +0300 Subject: refactor!: implement staged move generation - Skip move generation on ttable hit - Perform selection sort *iteratively* when pulling items - Fix killers probed from incorrect ply (still not ideal) --- src/board/move_generation.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/board/move_generation.rs') diff --git a/src/board/move_generation.rs b/src/board/move_generation.rs index 0735309..5a3650a 100644 --- a/src/board/move_generation.rs +++ b/src/board/move_generation.rs @@ -1,20 +1,22 @@ +use smallvec::SmallVec; use crate::{moves::{Move, MoveKind}, board::{color::Color, piece::Piece, CastlingSide}, bitboard::BitboardFns, square::Square}; use super::Board; +pub type MoveList = SmallVec<[Move; 128]>; impl Board { - pub fn generate_pseudolegal_moves(&self) -> Vec { - let mut result = Vec::new(); + pub fn generate_pseudolegal_moves(&self) -> MoveList { + let mut result = MoveList::new(); result.append(&mut self.generate_moves_core(true)); result.append(&mut self.generate_moves_core(false)); result } - fn generate_moves_core(&self, tactical_only: bool) -> Vec { + pub fn generate_moves_core(&self, tactical_only: bool) -> MoveList { let color = self.color(); let player_pieces = self.pieces_by_color(color); - let mut moves = Vec::with_capacity(256); + let mut moves = MoveList::new(); let empty = self.empty(); let targets = if tactical_only { -- cgit v1.2.3