diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 05:18:38 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-01-25 05:18:38 +0300 |
commit | 3522398f7a456b400dc48de4c202a013490cd4fc (patch) | |
tree | fab5655517165e403a0c0965377f38306cc2b155 /src/board/mod.rs | |
parent | 46b862a25203cb492dd45ba1696a28338a42065b (diff) | |
download | chessnost-3522398f7a456b400dc48de4c202a013490cd4fc.tar.gz |
feat: use transposition table in negamax
Diffstat (limited to 'src/board/mod.rs')
-rw-r--r-- | src/board/mod.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/board/mod.rs b/src/board/mod.rs index a8166a1..2ff7f9c 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -1,13 +1,16 @@ use rand::Rng; use crate::{bitboard::{Bitboard, serialize_bitboard, bitscan, pop_count}, moves::{Move, MoveKind}, attacks::Attacks, square::Square}; + +use self::ttable::{TranspositionTable, TTABLE_SIZE}; mod engine; +mod ttable; pub enum CastlingSide { King, Queen, } -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq)] pub struct Board { pub pieces: [Bitboard; 12], @@ -26,6 +29,7 @@ pub struct Board { /// Zobrist hash of the current position pub hash: u64, + transposition_table: TranspositionTable, zobrist_seed: [u64; 781], attacks: Attacks, } @@ -121,6 +125,7 @@ impl Board { castling_rights: [[true; 2]; 2], // TODO: actualy parse from FEN ep_target: None, // TODO: parse from FEN hash: 0, + transposition_table: vec![None; TTABLE_SIZE as usize], zobrist_seed, }; board.update_occupancy(); @@ -524,7 +529,10 @@ impl Board { self.hash ^= self.zobrist_seed[source_piece * 12 + mov.target as usize]; PieceType::from(source_piece) }, - None => panic!("Move is malformed: source piece not found"), + None => { + self.print(); + panic!("{:?} is malformed: source piece not found", mov); + } }; // When castling, also move a rook |