diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-28 11:15:08 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-28 11:15:08 +0200 |
| commit | 3109a2516e75072835f1998a9b702003781612d5 (patch) | |
| tree | e0e2bbe0a1f31876884a65232557ec27f6816e57 /src/board.cpp | |
| parent | bb30752226c59148ae36beb248c8e4ed6eac39d1 (diff) | |
preventing 3 fold repetion
Diffstat (limited to 'src/board.cpp')
| -rw-r--r-- | src/board.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 <cassert> #include <cstdio> #include <iostream> @@ -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; } |
