aboutsummaryrefslogtreecommitdiff
path: root/src/zobrist.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-29 20:11:40 +0200
committerAdam <adammegarules1@gmail.com>2026-07-29 20:11:40 +0200
commitd528a20684570fb70f0e6b13a78bc6504a1edd89 (patch)
treeb227cab63e05ce3f2063b2298fd8c553f1a90fe4 /src/zobrist.cpp
parent43a8816a7c56096d974689e42f7f6f110d28d408 (diff)
adding testing new folder structer
Diffstat (limited to 'src/zobrist.cpp')
-rw-r--r--src/zobrist.cpp72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/zobrist.cpp b/src/zobrist.cpp
deleted file mode 100644
index cfc7769..0000000
--- a/src/zobrist.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include "zobrist.hpp"
-#include "board.hpp"
-
-#include <random>
-
-uint64_t PieceKeys[2][7][64];
-uint64_t SideKey;
-uint64_t CastleKeys[16];
-uint64_t EnPassantKeys[8];
-
-void InitZobrist() {
- std::mt19937_64 rng(1234567); // fixed seed
-
- for (int color = 0; color < 2; color++) {
- for (int piece = 0; piece < 7; piece++) {
- for (int square = 0; square < 64; square++) {
- PieceKeys[color][piece][square] = rng();
- }
- }
- }
-
- SideKey = rng();
-
- for (int i = 0; i < 16; i++) {
- CastleKeys[i] = rng();
- }
-
- for (int i = 0; i < 8; i++) {
- EnPassantKeys[i] = rng();
- }
-}
-
-uint64_t GenerateZobristKey(Game *b) {
- uint64_t key = 0;
-
- for (int square = 0; square < 64; square++) {
- Piece p = b->pieces[square];
-
- if (p.type == NONEPIECE)
- continue;
-
- key ^= PieceKeys[p.color][p.type][square];
- }
-
- // side to move
- if (b->turn)
- key ^= SideKey;
-
- // castling
- int castle = 0;
-
- if (b->whiteCastleKing)
- castle |= 1;
-
- if (b->whiteCastleQueen)
- castle |= 2;
-
- if (b->blackCastleKing)
- castle |= 4;
-
- if (b->blackCastleQueen)
- castle |= 8;
-
- key ^= CastleKeys[castle];
-
- // en passant
- if (b->canEnpassant) {
- key ^= EnPassantKeys[b->enPassant.file];
- }
-
- return key;
-}