aboutsummaryrefslogtreecommitdiff
path: root/src/evaluate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/evaluate.cpp')
-rw-r--r--src/evaluate.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/evaluate.cpp b/src/evaluate.cpp
index b1fc4f1..d2ee734 100644
--- a/src/evaluate.cpp
+++ b/src/evaluate.cpp
@@ -80,7 +80,19 @@ static std::array<int, 64> KING_TABLE_EARLY = {
20, 30, 10, 0, 0, 10, 30, 20, //
};
-int EvaluateBoard(Game *g) {
+static std::array<int, 64> KING_TABLE_LATE =
+ {
+ -50, -40, -30, -20, -20, -30, -40, -50, //
+ -30, -20, -10, 0, 0, -10, -20, -30, //
+ -30, -10, 20, 30, 30, 20, -10, -30, //
+ -30, -10, 30, 40, 40, 30, -10, -30, //
+ -30, -10, 30, 40, 40, 30, -10, -30, //
+ -30, -10, 20, 30, 30, 20, -10, -30, //
+ -30, -30, 0, 0, 0, 0, -30, -30, //
+ -50, -30, -30, -30, -30, -30, -30, -50, //
+}
+
+int EvaluateBoard(Game * g) {
int score = EvaluateBoardForWhite(g);
return g->turn ? score : score * -1;
};
@@ -111,7 +123,7 @@ static int ForceKingToEdgeBonus(const Position enemyKing,
return bonus;
}
-int CountBoardMaterial(Game *g) {
+int CountBoardMaterial(Game *g, bool isEndgame) {
int score = 0;
uint64_t piece_bitboard = g->PieceBitboard;
@@ -151,7 +163,11 @@ int CountBoardMaterial(Game *g) {
value += QUEEN_TABLE[RotateBoardForBlack(i, piece.color)];
break;
case KING:
- value = KING_TABLE_EARLY[RotateBoardForBlack(i, piece.color)];
+ if (isEndgame) {
+ value = KING_TABLE_LATE[RotateBoardForBlack(i, piece.color)];
+ } else {
+ value = KING_TABLE_EARLY[RotateBoardForBlack(i, piece.color)];
+ }
break;
default:
break;
@@ -204,9 +220,10 @@ int EvaluateBoardForWhite(Game *g) {
int score = 0;
+ bool isEndGame = IsEndgame(g);
score += CountBoardMaterial(g);
- if (IsEndgame(g)) {
+ if (isEndGame) {
Position whiteKing = FindKing(g, true);
Position blackKing = FindKing(g, false);