aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-29 15:05:17 +0200
committerAdam <adammegarules1@gmail.com>2026-07-29 15:05:17 +0200
commitdee861a68211a811948cc4effa130fc4ee8b5851 (patch)
tree50a2978029f807e4d401113a608854d3662bc808
parent9049515932987278eadf838e9be7c3c7fac093d5 (diff)
early return when no legal moves, skipping sort call
-rw-r--r--src/bot.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/bot.cpp b/src/bot.cpp
index 0f8d12a..a1b4fb2 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -119,6 +119,9 @@ int ScoreMove(const Game *board, const Move &move) {
std::vector<Move> GetSortedLegalMoves(Game *g) {
auto moves = GetLegalMoves(g);
+ if (moves.size() == 0) {
+ return moves;
+ }
std::sort(moves.begin(), moves.end(), [&](const Move &a, const Move &c) {
return ScoreMove(g, a) > ScoreMove(g, c);
});