From 54afeb6dd89fffae92274cb6fe2e9a86fd57c6e3 Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Sat, 15 Aug 2026 15:15:21 +0530 Subject: phase B --- src/engine/ttable.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/engine/ttable.c') diff --git a/src/engine/ttable.c b/src/engine/ttable.c index fc1b6f0..c98bf62 100644 --- a/src/engine/ttable.c +++ b/src/engine/ttable.c @@ -23,9 +23,13 @@ void zobrist_init() { u64 zobrist_hash(position_t position) { u64 output = 0; - for (int i = 0; i < 64; i++) { - int piece_type = find_piece_on_square(&position, i); - output ^= zobrist_keys.piece[piece_type][i]; + for (int piece = 0; piece < PIECE_TYPE_COUNT; piece++) { + bitboard_t bb = position.bitboards[piece]; + while (bb) { + int sq = __builtin_ctzll(bb); + bb &= bb - 1; + output ^= zobrist_keys.piece[piece][sq]; + } } if (position.castling & WHITE_SHORT_CASTLE) { -- cgit v1.2.3