From 96791e7ab670176d25e313caf2a428e21ccef168 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 10 Aug 2026 17:17:49 +0200 Subject: folowing the lint suggestions --- src/evaluate.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/evaluate.cpp') diff --git a/src/evaluate.cpp b/src/evaluate.cpp index f08080d..9120445 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -1,7 +1,9 @@ #include "evaluate.hpp" #include "board/board.hpp" #include "moves.hpp" +#include #include +#include #include #include @@ -12,7 +14,7 @@ constexpr int ROOK_VALUE = 500; constexpr int QUEEN_VALUE = 900; constexpr int MATE = 10000; -static int PAWN_TABLE[64] = { +static std::array PAWN_TABLE = { 0, 0, 0, 0, 0, 0, 0, 0, // last rank promotes to a quuen 50, 50, 50, 50, 50, 50, 50, 50, // comments to stop formating to ruin it 10, 10, 20, 35, 35, 20, 10, 10, // @@ -23,7 +25,7 @@ static int PAWN_TABLE[64] = { 0, 0, 0, 0, 0, 0, 0, 0 // }; -static int KNIGHT_TABLE[64] = { +static std::array KNIGHT_TABLE = { -50, -40, -30, -30, -30, -30, -40, -50, // -40, -20, 0, 0, 0, 0, -20, -40, // -30, 0, 10, 15, 15, 10, 0, -30, // @@ -34,7 +36,7 @@ static int KNIGHT_TABLE[64] = { -50, -40, -30, -30, -30, -30, -40, -50, // }; -static int BISHOP_TABLE[64] = { +static std::array BISHOP_TABLE = { -20, -10, -10, -10, -10, -10, -10, -20, // -10, 5, 0, 0, 0, 0, 5, -10, // -10, 10, 10, 10, 10, 10, 10, -10, // @@ -45,7 +47,7 @@ static int BISHOP_TABLE[64] = { -20, -10, -10, -10, -10, -10, -10, -20, // }; -static int ROOK_TABLE[64] = { +static std::array ROOK_TABLE = { 0, 0, 5, 10, 10, 5, 0, 0, // 5, 10, 10, 10, 10, 10, 10, 5, // -5, 0, 0, 0, 0, 0, 0, -5, // @@ -56,7 +58,7 @@ static int ROOK_TABLE[64] = { 0, 0, 5, 10, 10, 5, 0, 0, // }; -static int QUEEN_TABLE[64] = { +static std::array QUEEN_TABLE = { -20, -10, -10, -5, -5, -10, -10, -20, // -10, 0, 0, 0, 0, 0, 0, -10, // -10, 0, 5, 5, 5, 5, 0, -10, // @@ -67,7 +69,7 @@ static int QUEEN_TABLE[64] = { -20, -10, -10, -5, -5, -10, -10, -20, // }; -static int KING_TABLE_EARLY[64] = { +static std::array KING_TABLE_EARLY = { -30, -40, -40, -50, -50, -40, -40, -30, // -30, -40, -40, -50, -50, -40, -40, -30, // -30, -40, -40, -50, -50, -40, -40, -30, // @@ -87,7 +89,7 @@ int EvaluateBoard(Game *g) { * i cound have come up with better name. * this function just takes square and if color is black rotate it */ -static int RotateBoardForBlack(const int square, const bool color) { +static size_t RotateBoardForBlack(const size_t square, const bool color) { return !color ? square : (56 ^ square); } @@ -114,7 +116,7 @@ int CountBoardMaterial(Game *g) { uint64_t piece_bitboard = g->PieceBitboard; while (piece_bitboard != 0) { - int i = __builtin_ctzll(piece_bitboard); + auto i = static_cast(__builtin_ctzll(piece_bitboard)); piece_bitboard &= piece_bitboard - 1; const Piece piece = g->pieces[i]; @@ -167,22 +169,24 @@ int CountBoardMaterial(Game *g) { bool IsEndgame(const Game *g) { int queens = 0; - int rooks = 0; + int minor = 0; for (const Piece &piece : g->pieces) { switch (piece.type) { case QUEEN: queens++; break; + case BISHOP: + case KNIGHT: case ROOK: - rooks++; + minor++; break; default: break; } } - return queens == 0 || (queens == 2 && rooks <= 1); + return queens == 0 || (queens == 2 && minor <= 1); } int EvaluateBoardForWhite(Game *g) { -- cgit v1.2.3