From 17f245ac325cea859fb39799a9c8b088fc933808 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 31 Jul 2026 10:07:01 +0200 Subject: improving default depth --- src/board/board.cpp | 4 ++-- src/bot.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/board/board.cpp b/src/board/board.cpp index d0cf4c1..92d448d 100644 --- a/src/board/board.cpp +++ b/src/board/board.cpp @@ -13,11 +13,11 @@ Piece createPiece(PieceType type, bool color) { int PositionToIndex(Position i) { return i.rank * 8 + i.file; } -Position FindKing(Game *b, bool white) { +Position FindKing(Game *b, bool color) { for (int i = 0; i < 64; i++) { Piece piece = b->pieces[i]; - if (piece.type == KING && piece.color == white) { + if (piece.type == KING && piece.color == color) { return IndexToPosition(i); } } diff --git a/src/bot.cpp b/src/bot.cpp index 61c38fa..982a4a4 100644 --- a/src/bot.cpp +++ b/src/bot.cpp @@ -129,7 +129,6 @@ std::vector GetSortedLegalMoves(Game *g, bool generateQuietMoves) { } Move EngineGetBestMove(Game *b, const int depth) { - const int usedDepth = (depth != -1 ? depth : DEFAULT_DEPTH); const auto moves = GetSortedLegalMoves(b); if (moves.empty()) { std::cout << "Expected a position with legal moves"; @@ -145,7 +144,8 @@ Move EngineGetBestMove(Game *b, const int depth) { const float alpha = -INFINITY; const float beta = INFINITY; - const int eval = minimax(usedDepth - 1, b, alpha, beta); + const int eval = + minimax(depth <= 0 ? DEFAULT_DEPTH : depth, b, alpha, beta); UnMakeMove(undo, b); if (b->turn) { -- cgit v1.2.3