aboutsummaryrefslogtreecommitdiff
path: root/src/bot.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-07-29 10:06:10 +0200
committerAdam <adammegarules1@gmail.com>2026-07-29 10:06:10 +0200
commit165fecafb6703edbec84fca6410c3f7f4005c4cc (patch)
treee7f6f2374afbe7a693e348a605ea036931719f98 /src/bot.cpp
parentb1b30252186822020163253498e2b764b91713d9 (diff)
optimazing
Diffstat (limited to 'src/bot.cpp')
-rw-r--r--src/bot.cpp8
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;