From 3109a2516e75072835f1998a9b702003781612d5 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 28 Jul 2026 11:15:08 +0200 Subject: preventing 3 fold repetion --- src/board.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/board.cpp') diff --git a/src/board.cpp b/src/board.cpp index 0698571..e058df4 100644 --- a/src/board.cpp +++ b/src/board.cpp @@ -1,5 +1,6 @@ #include "board.hpp" #include "bot.hpp" +#include "zobrist.hpp" #include #include #include @@ -143,6 +144,14 @@ void PlayMove(Move move, Game *b) { } b->pieces[PositionToIndex(move.To)] = piece; b->pieces[PositionToIndex(move.From)] = {false, NONE, false}; + b->turn = !b->turn; + + uint64_t key = GenerateZobristKey(b); + + b->ThreeFoldMap[key]++; + if (b->ThreeFoldMap[key] >= 3) { + b->state = DRAW; + } }; int PositionToIndex(Position i) { return i.rank * 8 + i.file; } -- cgit v1.2.3