diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/board/engine.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/board/engine.rs b/src/board/engine.rs index feb3368..e11d96e 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -187,6 +187,18 @@ impl Board { 0.0 } + pub fn hash_move(&self) -> Option<Move> { + match self.transposition_table[(self.hash % TTABLE_SIZE) as usize] { + Some(item) => { + if item.hash == self.hash { + return Some(item.best_move) + } + None + } + None => None + } + } + pub fn order_moves(&self, moves: Vec<Move>) -> Vec<Move> { let mut moves_with_eval: Vec<(Move, f32)> = moves .iter() @@ -216,12 +228,8 @@ impl Board { let mut moves = self.generate_pseudolegal_moves(color); moves = self.order_moves(moves); - match self.transposition_table[(self.hash % TTABLE_SIZE) as usize] { - Some(item) => { - if item.hash == self.hash { - moves.insert(0, item.best_move); - } - } + match self.hash_move() { + Some(mov) => moves.insert(0, mov), None => {}, } @@ -292,12 +300,8 @@ impl Board { let mut moves = self.generate_pseudolegal_moves(color); moves = self.order_moves(moves); - match self.transposition_table[(self.hash % TTABLE_SIZE) as usize] { - Some(item) => { - if item.hash == self.hash { - moves.insert(0, item.best_move); - } - } + match self.hash_move() { + Some(mov) => moves.insert(0, mov), None => {}, } |