From 165fecafb6703edbec84fca6410c3f7f4005c4cc Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 29 Jul 2026 10:06:10 +0200 Subject: optimazing --- src/bot.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/bot.cpp') 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; -- cgit v1.2.3