|
@@ -3,7 +3,7 @@ use movegen::*;
|
|
use log::info;
|
|
use log::info;
|
|
use std::sync::Arc;
|
|
use std::sync::Arc;
|
|
use zobrist::{ZobristTable, Hash};
|
|
use zobrist::{ZobristTable, Hash};
|
|
-use crate::movegen;
|
|
|
|
|
|
+use crate::{movegen, zobrist::{self, get_zobrist}};
|
|
|
|
|
|
#[derive(Clone)]
|
|
#[derive(Clone)]
|
|
pub struct Board
|
|
pub struct Board
|
|
@@ -26,12 +26,12 @@ pub struct Board
|
|
// vvv
|
|
// vvv
|
|
pub turn_number: i32,
|
|
pub turn_number: i32,
|
|
pub halfmoves_since_last_event: i8,
|
|
pub halfmoves_since_last_event: i8,
|
|
- pub zobrist: Option<(Arc<ZobristTable>, Hash)>
|
|
|
|
|
|
+ pub zobrist_hash: Hash
|
|
}
|
|
}
|
|
|
|
|
|
impl Default for Board {
|
|
impl Default for Board {
|
|
fn default () -> Board {
|
|
fn default () -> Board {
|
|
- Board {
|
|
|
|
|
|
+ let mut b = Board {
|
|
pieces: [
|
|
pieces: [
|
|
ROW_2,
|
|
ROW_2,
|
|
0x42,
|
|
0x42,
|
|
@@ -51,17 +51,18 @@ impl Default for Board {
|
|
castling_rights: [true; 4],
|
|
castling_rights: [true; 4],
|
|
halfmoves_since_last_event: 0,
|
|
halfmoves_since_last_event: 0,
|
|
turn_number: 0,
|
|
turn_number: 0,
|
|
- zobrist: None
|
|
|
|
- }
|
|
|
|
|
|
+ zobrist_hash: 0
|
|
|
|
+ };
|
|
|
|
+ let z = b.calculate_zobrist(zobrist::get_zobrist());
|
|
|
|
+ b.zobrist_hash = z;
|
|
|
|
+ b
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
impl std::hash::Hash for Board {
|
|
impl std::hash::Hash for Board {
|
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
|
- if let Some((ref _zt, ref zb)) = &self.zobrist {
|
|
|
|
- zb.hash(state);
|
|
|
|
- }
|
|
|
|
|
|
+ self.zobrist_hash.hash(state);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -80,15 +81,18 @@ impl Eq for Board {
|
|
|
|
|
|
impl Board {
|
|
impl Board {
|
|
pub fn empty() -> Board {
|
|
pub fn empty() -> Board {
|
|
- Board {
|
|
|
|
|
|
+ let mut b = Board {
|
|
pieces: [0; 12],
|
|
pieces: [0; 12],
|
|
turn: WHITE,
|
|
turn: WHITE,
|
|
en_passant: None,
|
|
en_passant: None,
|
|
castling_rights: [true; 4],
|
|
castling_rights: [true; 4],
|
|
halfmoves_since_last_event: 0,
|
|
halfmoves_since_last_event: 0,
|
|
turn_number: 0,
|
|
turn_number: 0,
|
|
- zobrist: None
|
|
|
|
- }
|
|
|
|
|
|
+ zobrist_hash: 0
|
|
|
|
+ };
|
|
|
|
+ let z = b.calculate_zobrist(zobrist::get_zobrist());
|
|
|
|
+ b.zobrist_hash = z;
|
|
|
|
+ b
|
|
}
|
|
}
|
|
|
|
|
|
pub fn from_fen(fen: &[&str]) -> Option<Board> {
|
|
pub fn from_fen(fen: &[&str]) -> Option<Board> {
|
|
@@ -159,6 +163,8 @@ impl Board {
|
|
|
|
|
|
game.halfmoves_since_last_event = halfmoves_since_last_event.parse::<i8>().unwrap_or(0);
|
|
game.halfmoves_since_last_event = halfmoves_since_last_event.parse::<i8>().unwrap_or(0);
|
|
game.turn_number = turn_number.parse::<i32>().unwrap_or(0);
|
|
game.turn_number = turn_number.parse::<i32>().unwrap_or(0);
|
|
|
|
+
|
|
|
|
+ game.zobrist_hash = game.calculate_zobrist(zobrist::get_zobrist());
|
|
|
|
|
|
Some(game)
|
|
Some(game)
|
|
}
|
|
}
|
|
@@ -519,12 +525,15 @@ impl Board {
|
|
return board;
|
|
return board;
|
|
}
|
|
}
|
|
|
|
|
|
- pub fn update_zobrist(&mut self, h: Hash) {
|
|
|
|
- if let Some((ref _zt, ref mut zh)) = self.zobrist {
|
|
|
|
- *zh ^= h;
|
|
|
|
- }
|
|
|
|
|
|
+ fn update_zobrist(&mut self, h: Hash) {
|
|
|
|
+ self.zobrist_hash ^= h;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ///
|
|
|
|
+ /// calculates the zobrist hash independently from the field zobrist_hash
|
|
|
|
+ ///
|
|
|
|
+ /// doesn't set anything
|
|
|
|
+ ///
|
|
pub fn calculate_zobrist(&self, zt: &ZobristTable) -> Hash {
|
|
pub fn calculate_zobrist(&self, zt: &ZobristTable) -> Hash {
|
|
let mut hash: Hash = 0;
|
|
let mut hash: Hash = 0;
|
|
for pt in 0..6 {
|
|
for pt in 0..6 {
|
|
@@ -556,12 +565,7 @@ impl Board {
|
|
}
|
|
}
|
|
|
|
|
|
pub fn is_zobrist_correct(&self) -> bool {
|
|
pub fn is_zobrist_correct(&self) -> bool {
|
|
- if let Some((ref zt, zv)) = self.zobrist {
|
|
|
|
- self.calculate_zobrist(zt) == zv
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- false
|
|
|
|
- }
|
|
|
|
|
|
+ self.zobrist_hash == self.calculate_zobrist(zobrist::get_zobrist())
|
|
}
|
|
}
|
|
|
|
|
|
///
|
|
///
|
|
@@ -591,14 +595,10 @@ impl Board {
|
|
println!("incorrect zobrist before apply {} {:?}", mov.to_string(), mov);
|
|
println!("incorrect zobrist before apply {} {:?}", mov.to_string(), mov);
|
|
info!("incorrect zobrist before apply");
|
|
info!("incorrect zobrist before apply");
|
|
panic!("zobrist");
|
|
panic!("zobrist");
|
|
- let val = if let Some((ref zt, _zv)) = self.zobrist {
|
|
|
|
- self.calculate_zobrist(zt)
|
|
|
|
- } else { 0 };
|
|
|
|
- if let Some((ref _zt, ref mut zv)) = self.zobrist {
|
|
|
|
- *zv = val;
|
|
|
|
- }
|
|
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
+ let zobrist_table = get_zobrist();
|
|
|
|
+
|
|
// save irrecoverable values
|
|
// save irrecoverable values
|
|
let castling_rights_before = self.castling_rights.clone();
|
|
let castling_rights_before = self.castling_rights.clone();
|
|
let halfmoves_since_last_event_before = self.halfmoves_since_last_event.clone();
|
|
let halfmoves_since_last_event_before = self.halfmoves_since_last_event.clone();
|
|
@@ -636,10 +636,9 @@ impl Board {
|
|
if from_square(mov.to) & others != 0 {
|
|
if from_square(mov.to) & others != 0 {
|
|
if let Some((other_piece, other_side)) = self.get_square(mov.to) {
|
|
if let Some((other_piece, other_side)) = self.get_square(mov.to) {
|
|
// update zobrist
|
|
// update zobrist
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(other_piece, other_side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(other_piece, other_side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
|
|
+
|
|
*self.get_piece_mut(other_piece, other_side) &= !from_square(mov.to);
|
|
*self.get_piece_mut(other_piece, other_side) &= !from_square(mov.to);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -662,10 +661,10 @@ impl Board {
|
|
|
|
|
|
let moved_piece = mov.apply_to(self.get_piece(pt, side));
|
|
let moved_piece = mov.apply_to(self.get_piece(pt, side));
|
|
self.set_piece(pt, side, moved_piece);
|
|
self.set_piece(pt, side, moved_piece);
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(pt, side, mov.from) ^ zt.piece_hash(pt, side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ let hup = zobrist_table.piece_hash(pt, side, mov.from)
|
|
|
|
+ ^ zobrist_table.piece_hash(pt, side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
},
|
|
},
|
|
Move::Castling { mov:_, side, left } => {
|
|
Move::Castling { mov:_, side, left } => {
|
|
// invalidate future castling rights
|
|
// invalidate future castling rights
|
|
@@ -686,11 +685,14 @@ impl Board {
|
|
self.set_piece(KING, side, new_king);
|
|
self.set_piece(KING, side, new_king);
|
|
*self.get_piece_mut(ROOK, side) &= !rook;
|
|
*self.get_piece_mut(ROOK, side) &= !rook;
|
|
*self.get_piece_mut(ROOK, side) |= new_rook;
|
|
*self.get_piece_mut(ROOK, side) |= new_rook;
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hupk = zt.piece_hash(KING, side, square(king)) ^ zt.piece_hash(KING, side, square(new_king));
|
|
|
|
- let hup = zt.piece_hash(ROOK, side, square(rook)) ^ zt.piece_hash(ROOK, side, square(new_rook));
|
|
|
|
- *zv ^= hup ^ hupk;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ let hupk = zobrist_table.piece_hash(KING, side, square(king))
|
|
|
|
+ ^ zobrist_table.piece_hash(KING, side, square(new_king));
|
|
|
|
+ let hup = zobrist_table.piece_hash(ROOK, side, square(rook))
|
|
|
|
+ ^ zobrist_table.piece_hash(ROOK, side, square(new_rook));
|
|
|
|
+
|
|
|
|
+ self.update_zobrist(hupk ^ hup);
|
|
|
|
|
|
self.en_passant = None;
|
|
self.en_passant = None;
|
|
},
|
|
},
|
|
@@ -700,11 +702,10 @@ impl Board {
|
|
*self.get_piece_mut(PAWN, side) |= from_square(mov.to);
|
|
*self.get_piece_mut(PAWN, side) |= from_square(mov.to);
|
|
*self.get_piece_mut(PAWN, !side) &= !from_square(beaten);
|
|
*self.get_piece_mut(PAWN, !side) &= !from_square(beaten);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(PAWN, side, mov.from) ^ zt.piece_hash(PAWN, side, mov.to);
|
|
|
|
- let hupo = zt.piece_hash(PAWN, !side, beaten);
|
|
|
|
- *zv ^= hup ^ hupo;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(PAWN, side, mov.from)
|
|
|
|
+ ^ zobrist_table.piece_hash(PAWN, side, mov.to);
|
|
|
|
+ let hupo = zobrist_table.piece_hash(PAWN, !side, beaten);
|
|
|
|
+ self.update_zobrist(hup ^ hupo);
|
|
|
|
|
|
self.en_passant = None;
|
|
self.en_passant = None;
|
|
}
|
|
}
|
|
@@ -720,16 +721,13 @@ impl Board {
|
|
if let Some(pt) = captured {
|
|
if let Some(pt) = captured {
|
|
*self.get_piece_mut(pt, !side) &= !from_square(mov.to);
|
|
*self.get_piece_mut(pt, !side) &= !from_square(mov.to);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(pt, !side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(pt, !side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
}
|
|
}
|
|
*self.get_piece_mut(PAWN, side) &= !from_square(mov.from);
|
|
*self.get_piece_mut(PAWN, side) &= !from_square(mov.from);
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(PAWN, side, mov.from);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ let hup = zobrist_table.piece_hash(PAWN, side, mov.from);
|
|
|
|
+ self.update_zobrist(hup);
|
|
|
|
|
|
match promote_to {
|
|
match promote_to {
|
|
QUEEN => { *self.queens_mut(side) |= from_square(mov.to); }
|
|
QUEEN => { *self.queens_mut(side) |= from_square(mov.to); }
|
|
@@ -740,10 +738,8 @@ impl Board {
|
|
info!("internal error");
|
|
info!("internal error");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(promote_to, side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(promote_to, side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
self.en_passant = None;
|
|
self.en_passant = None;
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -755,24 +751,16 @@ impl Board {
|
|
}
|
|
}
|
|
|
|
|
|
self.turn = !self.turn;
|
|
self.turn = !self.turn;
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.turn_hash();
|
|
|
|
- let castling_hup = zt.all_castling_rights_hash(castling_rights_before) ^ zt.all_castling_rights_hash(self.castling_rights);
|
|
|
|
- let enpass_hup = en_passant_before.map(|f| zt.en_passant_hash(f)).unwrap_or(0) ^ self.en_passant.map(|f| zt.en_passant_hash(f)).unwrap_or(0);
|
|
|
|
- *zv ^= hup ^ castling_hup ^ enpass_hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.turn_hash();
|
|
|
|
+ let castling_hup = zobrist_table.all_castling_rights_hash(castling_rights_before) ^ zobrist_table.all_castling_rights_hash(self.castling_rights);
|
|
|
|
+ let enpass_hup = en_passant_before.map(|f| zobrist_table.en_passant_hash(f)).unwrap_or(0) ^ self.en_passant.map(|f| zobrist_table.en_passant_hash(f)).unwrap_or(0);
|
|
|
|
+ self.update_zobrist(hup ^ castling_hup ^ enpass_hup);
|
|
|
|
|
|
/*if !self.is_zobrist_correct() {
|
|
/*if !self.is_zobrist_correct() {
|
|
println!("{}", self.beautiful_print());
|
|
println!("{}", self.beautiful_print());
|
|
println!("incorrect zobrist after apply {} {:?}", mov.to_string(), mov);
|
|
println!("incorrect zobrist after apply {} {:?}", mov.to_string(), mov);
|
|
info!("incorrect zobrist after apply");
|
|
info!("incorrect zobrist after apply");
|
|
panic!("zobrist");
|
|
panic!("zobrist");
|
|
- let val = if let Some((ref zt, _zv)) = self.zobrist {
|
|
|
|
- self.calculate_zobrist(zt)
|
|
|
|
- } else { 0 };
|
|
|
|
- if let Some((ref _zt, ref mut zv)) = self.zobrist {
|
|
|
|
- *zv = val;
|
|
|
|
- }
|
|
|
|
}*/
|
|
}*/
|
|
|
|
|
|
MoveUndo {
|
|
MoveUndo {
|
|
@@ -793,11 +781,13 @@ impl Board {
|
|
panic!("zobrist");
|
|
panic!("zobrist");
|
|
}*/
|
|
}*/
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let crhup = zt.all_castling_rights_hash(self.castling_rights) ^ zt.all_castling_rights_hash(umov.castling_rights_before);
|
|
|
|
- let enpass_hup = self.en_passant.map(|f| zt.en_passant_hash(f)).unwrap_or(0) ^ umov.en_passant_before.map(|f| zt.en_passant_hash(f)).unwrap_or(0);
|
|
|
|
- *zv ^= crhup ^ enpass_hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let zobrist_table = get_zobrist();
|
|
|
|
+
|
|
|
|
+ let crhup = zobrist_table.all_castling_rights_hash(self.castling_rights)
|
|
|
|
+ ^ zobrist_table.all_castling_rights_hash(umov.castling_rights_before);
|
|
|
|
+ let enpass_hup = self.en_passant.map(|f| zobrist_table.en_passant_hash(f)).unwrap_or(0)
|
|
|
|
+ ^ umov.en_passant_before.map(|f| zobrist_table.en_passant_hash(f)).unwrap_or(0);
|
|
|
|
+ self.update_zobrist(crhup ^ enpass_hup);
|
|
|
|
|
|
self.castling_rights = umov.castling_rights_before;
|
|
self.castling_rights = umov.castling_rights_before;
|
|
self.halfmoves_since_last_event = umov.halfmoves_since_last_event_before;
|
|
self.halfmoves_since_last_event = umov.halfmoves_since_last_event_before;
|
|
@@ -818,18 +808,15 @@ impl Board {
|
|
*moved_piece_bb &= !from_square(mov.to);
|
|
*moved_piece_bb &= !from_square(mov.to);
|
|
*moved_piece_bb |= from_square(mov.from);
|
|
*moved_piece_bb |= from_square(mov.from);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(piece_type, side, mov.from) ^ zt.piece_hash(piece_type, side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(piece_type, side, mov.from)
|
|
|
|
+ ^ zobrist_table.piece_hash(piece_type, side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
|
|
|
|
if let Some(pt) = captured {
|
|
if let Some(pt) = captured {
|
|
*self.get_piece_mut(pt, !side) |= from_square(mov.to);
|
|
*self.get_piece_mut(pt, !side) |= from_square(mov.to);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(pt, !side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(pt, !side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
Move::Castling { mov: _, side, left } => {
|
|
Move::Castling { mov: _, side, left } => {
|
|
@@ -849,22 +836,21 @@ impl Board {
|
|
*self.get_piece_mut(ROOK, side) &= !rook;
|
|
*self.get_piece_mut(ROOK, side) &= !rook;
|
|
*self.get_piece_mut(ROOK, side) |= old_rook;
|
|
*self.get_piece_mut(ROOK, side) |= old_rook;
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let khup = zt.piece_hash(KING, side, square(old_king)) ^ zt.piece_hash(KING, side, square(king));
|
|
|
|
- let rhup = zt.piece_hash(ROOK, side, square(rook)) ^ zt.piece_hash(ROOK, side, square(old_rook));
|
|
|
|
- *zv ^= khup ^ rhup;
|
|
|
|
- }
|
|
|
|
|
|
+ let khup = zobrist_table.piece_hash(KING, side, square(old_king))
|
|
|
|
+ ^ zobrist_table.piece_hash(KING, side, square(king));
|
|
|
|
+ let rhup = zobrist_table.piece_hash(ROOK, side, square(rook))
|
|
|
|
+ ^ zobrist_table.piece_hash(ROOK, side, square(old_rook));
|
|
|
|
+ self.update_zobrist(khup ^ rhup);
|
|
},
|
|
},
|
|
Move::EnPassant { mov, beaten } => {
|
|
Move::EnPassant { mov, beaten } => {
|
|
*self.get_piece_mut(PAWN, side) |= from_square(mov.from);
|
|
*self.get_piece_mut(PAWN, side) |= from_square(mov.from);
|
|
*self.get_piece_mut(PAWN, side) &= !from_square(mov.to);
|
|
*self.get_piece_mut(PAWN, side) &= !from_square(mov.to);
|
|
*self.get_piece_mut(PAWN, !side) |= from_square(beaten);
|
|
*self.get_piece_mut(PAWN, !side) |= from_square(beaten);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let phup = zt.piece_hash(PAWN, side, mov.from) ^ zt.piece_hash(PAWN, side, mov.to);
|
|
|
|
- let chup = zt.piece_hash(PAWN, !side, beaten);
|
|
|
|
- *zv ^= phup ^ chup;
|
|
|
|
- }
|
|
|
|
|
|
+ let phup = zobrist_table.piece_hash(PAWN, side, mov.from)
|
|
|
|
+ ^ zobrist_table.piece_hash(PAWN, side, mov.to);
|
|
|
|
+ let chup = zobrist_table.piece_hash(PAWN, !side, beaten);
|
|
|
|
+ self.update_zobrist(phup ^ chup);
|
|
|
|
|
|
// should already be reverted
|
|
// should already be reverted
|
|
//self.en_passant = Some(indices_from_square(beaten).0);
|
|
//self.en_passant = Some(indices_from_square(beaten).0);
|
|
@@ -884,18 +870,15 @@ impl Board {
|
|
}
|
|
}
|
|
*self.pawns_mut(side) |= from_square(mov.from);
|
|
*self.pawns_mut(side) |= from_square(mov.from);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(PAWN, side, mov.from) ^ zt.piece_hash(promote_to, side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(PAWN, side, mov.from)
|
|
|
|
+ ^ zobrist_table.piece_hash(promote_to, side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
|
|
|
|
if let Some(pt) = captured {
|
|
if let Some(pt) = captured {
|
|
*self.get_piece_mut(pt, !side) |= from_square(mov.to);
|
|
*self.get_piece_mut(pt, !side) |= from_square(mov.to);
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- let hup = zt.piece_hash(pt, !side, mov.to);
|
|
|
|
- *zv ^= hup;
|
|
|
|
- }
|
|
|
|
|
|
+ let hup = zobrist_table.piece_hash(pt, !side, mov.to);
|
|
|
|
+ self.update_zobrist(hup);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -906,9 +889,7 @@ impl Board {
|
|
self.turn_number -= 1;
|
|
self.turn_number -= 1;
|
|
}
|
|
}
|
|
|
|
|
|
- if let Some((ref zt, ref mut zv)) = self.zobrist {
|
|
|
|
- *zv ^= zt.turn_hash();
|
|
|
|
- }
|
|
|
|
|
|
+ self.update_zobrist(zobrist_table.turn_hash());
|
|
|
|
|
|
/*if !self.is_zobrist_correct() {
|
|
/*if !self.is_zobrist_correct() {
|
|
println!("{}", self.beautiful_print());
|
|
println!("{}", self.beautiful_print());
|