diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-29 15:05:17 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-29 15:05:17 +0200 |
| commit | dee861a68211a811948cc4effa130fc4ee8b5851 (patch) | |
| tree | 50a2978029f807e4d401113a608854d3662bc808 | |
| parent | 9049515932987278eadf838e9be7c3c7fac093d5 (diff) | |
early return when no legal moves, skipping sort call
| -rw-r--r-- | src/bot.cpp | 3 |
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); }); |
