diff options
| author | Adam <adammegarules1@gmail.com> | 2026-07-29 10:06:10 +0200 |
|---|---|---|
| committer | Adam <adammegarules1@gmail.com> | 2026-07-29 10:06:10 +0200 |
| commit | 165fecafb6703edbec84fca6410c3f7f4005c4cc (patch) | |
| tree | e7f6f2374afbe7a693e348a605ea036931719f98 | |
| parent | b1b30252186822020163253498e2b764b91713d9 (diff) | |
optimazing
| -rw-r--r-- | src/bot.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/bot.cpp b/src/bot.cpp index 3394ae2..84949bb 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -131,9 +131,6 @@ Move EngineGetBestMove(Game *b) { return bestMove; } float minimax(int depth, Game *b, float alpha, float beta) { - if (depth == 0) { - return EvaluateBoardForWhite(b, depth); - } uint64_t gameHash = GenerateZobristKey(b); if (b->Transpositions->contains(gameHash)) { @@ -142,10 +139,12 @@ float minimax(int depth, Game *b, float alpha, float beta) { return data.Eval; } } + auto moves = GetLegalMoves(b); - if (moves.size() == 0) { + if (depth == 0 || moves.size() == 0) { return EvaluateBoardForWhite(b, depth); } + float bestEval; if (b->turn) { bestEval = -INFINITY; @@ -192,7 +191,6 @@ float EvaluateBoardForWhite(Game *b, int depth) { float score = 0; bool isStaleMate = false; - GetLegalMoves(b); if (b->state == WHITE_WON) { return MATE + depth; |
