aboutsummaryrefslogtreecommitdiff
path: root/src/grossmeister/move_selector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grossmeister/move_selector.rs')
-rw-r--r--src/grossmeister/move_selector.rs34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/grossmeister/move_selector.rs b/src/grossmeister/move_selector.rs
index d26ffc0..a3671e4 100644
--- a/src/grossmeister/move_selector.rs
+++ b/src/grossmeister/move_selector.rs
@@ -72,7 +72,7 @@ impl MoveGenStage {
#[derive(Default, Debug, Clone)]
pub struct MoveSelector {
- all_moves: ScoredMoveList,
+ tactical_moves: ScoredMoveList,
stage_moves: ScoredMoveIter,
pub killer_moves: SmallVec<[Move; 4]>,
stage: MoveGenStage,
@@ -134,12 +134,11 @@ impl Grossmeister {
.collect()
}
- pub fn next_capture(&mut self) -> Option<Move> {
+ pub fn next_tactical(&mut self) -> Option<Move> {
if self.move_selector().stage_moves.moves.is_empty() {
- let moves = self.board.generate_pseudolegal_moves();
- self.move_selector().all_moves = self.score_moves(moves);
- let captures = self.move_selector().all_moves.iter().filter(|(m, _)| m.is_tactical()).copied().collect();
- self.init_stage(captures);
+ let moves = self.board.generate_moves_core(true);
+ let scored = self.score_moves(moves);
+ self.init_stage(scored);
}
self.move_selector().stage_moves.next().map(|(mov, _)| mov)
@@ -172,14 +171,14 @@ impl Grossmeister {
MoveGenStage::WinningOrEqualTactical => {
// Init stage moves
if self.move_selector().stage_moves.moves.is_empty() {
- // Generate ALL moves (for future re-use)
- let moves = self.board.generate_pseudolegal_moves();
- self.move_selector().all_moves = self.score_moves(moves);
+ // Generate all tactical moves (for future re-use)
+ let moves = self.board.generate_moves_core(true);
+ self.move_selector().tactical_moves = self.score_moves(moves);
// But we only care about current stage now
let new_stage =
- self.move_selector().all_moves.iter()
- .filter(|(m, score)| m.is_tactical() && *score >= 0.0)
+ self.move_selector().tactical_moves.iter()
+ .filter(|(_, score)| *score >= 0.0)
.copied()
.collect();
@@ -195,7 +194,7 @@ impl Grossmeister {
if self.move_selector().stage_moves.moves.is_empty() {
let new_stage = self.move_selector().killer_moves.clone()
.iter()
- .filter(|&m| self.move_selector().all_moves.iter().any(|(m2, _)| m2 == m)) // Test if killer is in the movelist
+ .filter(|&m| self.move_selector().tactical_moves.iter().any(|(m2, _)| m2 == m)) // Test if killer is in the movelist
.map(|&m| (m, 0.0))
.collect();
self.init_stage(new_stage);
@@ -207,12 +206,9 @@ impl Grossmeister {
}
MoveGenStage::Quiet => {
if self.move_selector().stage_moves.moves.is_empty() {
- let new_stage = self.move_selector().all_moves
- .iter()
- .filter(|(m, _)| !m.is_tactical())
- .copied()
- .collect();
- self.init_stage(new_stage);
+ let moves = self.board.generate_moves_core(false);
+ let scored = self.score_moves(moves);
+ self.init_stage(scored);
}
match self.move_selector().stage_moves.next() {
Some((mov, _)) => return Some(mov),
@@ -222,7 +218,7 @@ impl Grossmeister {
MoveGenStage::LosingTactical => {
if self.move_selector().stage_moves.moves.is_empty() {
let new_stage =
- self.move_selector().all_moves.iter()
+ self.move_selector().tactical_moves.iter()
.filter(|(m, score)| m.is_tactical() && *score < 0.0)
.copied()
.collect();