aboutsummaryrefslogtreecommitdiff
path: root/src/bot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bot.cpp')
-rw-r--r--src/bot.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/bot.cpp b/src/bot.cpp
index f9ca92f..4682998 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -5,6 +5,7 @@
#include "zobrist.hpp"
#include <algorithm>
+#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
@@ -35,7 +36,7 @@ bool searchStopped = false;
static int ScoreMove(const Game *board, const Move &move,
const Move *bestMove) {
// Indexed by PieceType (NONE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING).
- static constexpr int PIECE_VALUES[] = {
+ static constexpr std::array<int, 7> PIECE_VALUES = {
0, // NONEPIECE
100, // PAWN
320, // KNIGHT
@@ -126,7 +127,6 @@ static int quiescenceSearch(Game *b, int qdepth, int alpha, int beta, int ply) {
};
return alpha;
};
-
static int search(int depth, Game *b, int alpha, int beta, int ply) {
Nodes++;
if ((Nodes & 2047) == 0) {
@@ -230,7 +230,10 @@ static SearchResult SearchDepth(Game *b, int depth, const Move *previousBest) {
auto moves = GetSortedLegalMoves(b, true, previousBest);
if (moves.empty()) {
- return {{}, EvaluateBoardForWhite(b)};
+ return {
+ .bestMove = {},
+ .score = EvaluateBoardForWhite(b),
+ };
}
Move bestMove = moves[0];
@@ -255,16 +258,14 @@ static SearchResult SearchDepth(Game *b, int depth, const Move *previousBest) {
alpha = std::max(alpha, eval);
}
- return {bestMove, bestEval};
+ return {.bestMove = bestMove, .score = bestEval};
}
static void PrintInfo(const int depth, const int engineScore,
const uint64_t nps) {
if (std::abs(engineScore) >= MATE_THRESHOLD) {
int movesToMate = (MATE - std::abs(engineScore) + 1) / 2;
- if (movesToMate < 1) {
- movesToMate = 1;
- }
+ movesToMate = std::max(1, movesToMate);
std::cout << "info depth " << depth << " score mate "
<< (engineScore > 0 ? movesToMate : -movesToMate) << "\n"
<< std::flush;