diff options
Diffstat (limited to 'src/board/mod.rs')
-rw-r--r-- | src/board/mod.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/board/mod.rs b/src/board/mod.rs index 39248eb..1e4fd93 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -1,6 +1,6 @@ use crate::{bitboard::{Bitboard, BitboardFns}, moves::{Move, MoveKind}, attacks::Attacks, square::Square, board::io::IO, clock::Clock}; -use self::{zobrist::{ZobristSeed, Zobrist}, piece::Piece, color::Color}; +use self::{zobrist::{ZobristSeed, Zobrist, ZobristHash}, piece::Piece, color::Color}; pub mod io; pub mod color; pub mod piece; @@ -27,12 +27,12 @@ pub struct Board { pub clock: Clock, /// List of all positions to determine repetitions - pub positions: Vec<u64>, + pub positions: Vec<ZobristHash>, // Computed values pub occupancy: Bitboard, /// Zobrist hash of the current position - pub hash: u64, + pub hash: ZobristHash, zobrist_seed: ZobristSeed, @@ -256,7 +256,7 @@ impl Board { captured_piece: Option<Piece>, previous_ep_target: Option<Square>, previous_castling_rights: [[bool; 2]; 2], - previous_hash: u64, + previous_hash: ZobristHash, ) { let move_source_bb = mov.source.to_bitboard(); let move_target_bb = mov.target.to_bitboard(); @@ -388,6 +388,10 @@ impl Board { let square = king_bb.bitscan(); self.is_square_attacked(square, color.flip()) } + + pub fn threefold_repetition(&self) -> bool { + self.positions.iter().filter(|&&p| p == self.hash).count() >= 3 + } } |