diff options
Diffstat (limited to 'src/moves.cpp')
| -rw-r--r-- | src/moves.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/moves.cpp b/src/moves.cpp index 8990621..9f75c25 100644 --- a/src/moves.cpp +++ b/src/moves.cpp @@ -594,26 +594,24 @@ bool IsSquareAttacked(const Game &g, Position square, bool byColor) { g.PieceBitboards[static_cast<size_t>(byColor)][QUEEN]; return bishop_attacks > 0; } -GameState GetNewGameState(Game *g) { - // make sure we dont override game ending states - if (g->state == DRAW || g->state == WHITE_WON || g->state == BLACK_WON) { - return g->state; +GameState GetboardState(Game *g, const std::vector<uint16_t> &moves) { + if (g->halfMoveClock >= 100) { + return DRAW; } - - auto legalMoves = GetLegalMoves(g, ALL); - - if (legalMoves.empty()) { - Position kingPosition = FindKing(*g, g->turn); - - bool check = IsSquareAttacked(*g, kingPosition, !g->turn); - - if (check) { - g->state = g->turn ? BLACK_WON : WHITE_WON; - } else { - g->state = DRAW; + if (isRepetionDraw(g->hash, g)) { + return DRAW; + }; + if (moves.empty()) { + const bool isCheck = IsSquareAttacked(*g, FindKing(*g, g->turn), !g->turn); + if (isCheck) { + if (g->turn) { + return BLACK_WON; + } + return WHITE_WON; } + return DRAW; } - return g->state; + return TURN; } static void GenerateCastlingMoves(const uint8_t &from, const Game &g, |
