|
@@ -4,7 +4,7 @@ use log::info;
|
|
use zobrist::{ZobristTable};
|
|
use zobrist::{ZobristTable};
|
|
use zobrist;
|
|
use zobrist;
|
|
|
|
|
|
-#[derive(Clone)]
|
|
|
|
|
|
+#[derive(Clone, PartialEq, Eq)]
|
|
pub struct Game
|
|
pub struct Game
|
|
{
|
|
{
|
|
pub pieces: [Bitboard; 12],
|
|
pub pieces: [Bitboard; 12],
|
|
@@ -20,7 +20,8 @@ pub struct Game
|
|
///
|
|
///
|
|
pub castling_rights: [bool; 4],
|
|
pub castling_rights: [bool; 4],
|
|
pub halfmoves_since_last_event: i32,
|
|
pub halfmoves_since_last_event: i32,
|
|
- pub turn_number: i32,
|
|
|
|
|
|
+
|
|
|
|
+ pub zobrist: Option<zobrist::Hash>
|
|
}
|
|
}
|
|
|
|
|
|
impl Default for Game {
|
|
impl Default for Game {
|
|
@@ -44,7 +45,8 @@ impl Default for Game {
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -57,7 +59,8 @@ impl Game {
|
|
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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -128,7 +131,7 @@ impl Game {
|
|
info!("en passant on file {:?}", game.en_passant);
|
|
info!("en passant on file {:?}", game.en_passant);
|
|
|
|
|
|
game.halfmoves_since_last_event = halfmoves_since_last_event.parse::<i32>().unwrap_or(0);
|
|
game.halfmoves_since_last_event = halfmoves_since_last_event.parse::<i32>().unwrap_or(0);
|
|
- game.turn_number = turn_number.parse::<i32>().unwrap_or(0);
|
|
|
|
|
|
+ //game.turn_number = turn_number.parse::<i32>().unwrap_or(0);
|
|
|
|
|
|
Some(game)
|
|
Some(game)
|
|
}
|
|
}
|
|
@@ -445,3 +448,12 @@ impl Game {
|
|
return hash;
|
|
return hash;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+impl std::hash::Hash for Game {
|
|
|
|
+ fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
|
|
|
+ if let Some(zb) = self.zobrist {
|
|
|
|
+ zb.hash(state);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|