aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index c5c5b85..d5ad989 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -164,16 +164,19 @@ std::vector<Move> GetLegalMoves(Game *g) {
}
}
- return legalMoves;
+ return legalMoves;
}
GameState GetNewGameState(Game *g) {
- auto legalMoves = GetLegalMoves(g);
-
// make sure we dont override game ending states
if (g->state == DRAW || g->state == STALEMATE || g->state == WHITE_WON ||
g->state == BLACK_WON) {
return g->state;
}
+ if (g->halfMoveClock >= 50) {
+ g->state = DRAW;
+ }
+
+ auto legalMoves = GetLegalMoves(g);
if (legalMoves.empty()) {
Position kingPosition = FindKing(g, g->turn);
@@ -186,7 +189,7 @@ GameState GetNewGameState(Game *g) {
g->state = STALEMATE;
}
}
- return TURN;
+ return g->state;
}
bool IsSquareAttacked(Game *g, Position square, bool white) {
int target = PositionToIndex(square);