diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-08-31 11:35:22 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-08-31 11:35:22 +0300 |
commit | e08dd1256b8a6d8197e56867b43b47a92aadd1a7 (patch) | |
tree | fc2ea24b6ca61974f952bdef11bcf3947ac281d3 /src/board | |
parent | 4fab0d63413987974f5eb6fee59d2caf9494f789 (diff) | |
download | chessnost-e08dd1256b8a6d8197e56867b43b47a92aadd1a7.tar.gz |
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)
Diffstat (limited to 'src/board')
-rw-r--r-- | src/board/move_generation.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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<Move> { - 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<Move> { + 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 { |