aboutsummaryrefslogtreecommitdiff
path: root/src/evaluate.cpp
diff options
context:
space:
mode:
authorAdam <adammegarules1@gmail.com>2026-08-10 17:17:49 +0200
committerAdam <adammegarules1@gmail.com>2026-08-10 17:17:49 +0200
commit96791e7ab670176d25e313caf2a428e21ccef168 (patch)
treed1f16b1ebdfe00cda8f189f1d50cfb96059bdc14 /src/evaluate.cpp
parent5ad271953558c4b9212137c60187bc018e2f45f1 (diff)
folowing the lint suggestions
Diffstat (limited to 'src/evaluate.cpp')
-rw-r--r--src/evaluate.cpp26
1 files changed, 15 insertions, 11 deletions
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 <array>
#include <cassert>
+#include <cstddef>
#include <cstdlib>
#include <iostream>
@@ -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<int, 64> 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<int, 64> 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<int, 64> 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<int, 64> 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<int, 64> 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<int, 64> 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<size_t>(__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) {