Skip to content

Commit f58a033

Browse files
committed
tune
1 parent 747d713 commit f58a033

7 files changed

Lines changed: 194 additions & 72 deletions

File tree

.github/workflows/games.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,12 @@ jobs:
181181
--elo1 "$ELO1" \
182182
--alpha 0.05 \
183183
--beta 0.05 \
184-
--results $RESULTS
184+
--results $RESULTS | tee -a results.txt
185185
186186
- uses: actions/upload-artifact@v4
187187
with:
188188
name: results
189189
path: |
190-
shard-*/games_*.pgn
191190
ratings.txt
192191
sprt.txt
193192
results.txt

Weights.h

Lines changed: 103 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
#define WEIGHTS_H
33
#include "eval.h"
44
namespace engine::eval {
5-
inline Value tempo = 20;
6-
inline Value PawnValue = 100;
7-
inline Value KnightValue = 320;
8-
inline Value BishopValue = 330;
9-
inline Value RookValue = 500;
10-
inline Value QueenValue = 900;
5+
inline Value tempo = 28;
6+
inline Value PawnValueMG = 124;
7+
inline Value KnightValueMG = 781;
8+
inline Value BishopValueMG = 825;
9+
inline Value RookValueMG = 1276;
10+
inline Value QueenValueMG = 2538;
11+
inline Value PawnValueEG = 206;
12+
inline Value KnightValueEG = 854;
13+
inline Value BishopValueEG = 915;
14+
inline Value RookValueEG = 1380;
15+
inline Value QueenValueEG = 2682;
1116
inline Value fianchettoBonus = 20;
1217
inline Value trappedBishopPenalty = 60;
1318
inline Value centerWeight = 5;
@@ -16,8 +21,6 @@ inline Value mopUpEdgeDistWeight = 10;
1621
inline Value spaceWeight = 2;
1722
inline Value bishopPairMg = 25;
1823
inline Value bishopPairEg = 50;
19-
inline Value developedMg = 8;
20-
inline Value developedEg = 4;
2124
inline Value rookOpenFileMg = 25;
2225
inline Value rookOpenFileEg = 20;
2326
inline Value rookSemiOpenFileMg = 15;
@@ -35,6 +38,98 @@ inline Value kqkEdgeWeight = 15;
3538
inline Value krkDistWeight = 5;
3639
inline Value krkEdgeWeight = 10;
3740
inline Value kpkWeight = 15;
41+
inline Value mgMobilityCnt[7][8] = {
42+
{ 0, 0, 0, 0, 0, 0, 0, 0 },
43+
{ 0, 0, 0, 0, 0, 0, 0, 0 },
44+
{ -15, -8, -2, 4, 10, 16, 22, 28 },
45+
{ -20, -12, -4, 5, 14, 23, 32, 40 },
46+
{ -25, -15, -5, 5, 15, 25, 35, 45 },
47+
{ -30, -18, -6, 6, 18, 30, 42, 55 },
48+
{ -10, -5, 0, 5, 10, 15, 20, 25 }
49+
};
50+
inline Value egMobilityCnt[7][8] = {
51+
{ 0, 0, 0, 0, 0, 0, 0, 0 },
52+
{ 0, 0, 0, 0, 0, 0, 0, 0 },
53+
{ -20, -12, -4, 5, 14, 23, 32, 40 },
54+
{ -25, -15, -5, 5, 16, 27, 38, 50 },
55+
{ -30, -18, -6, 6, 18, 30, 42, 55 },
56+
{ -35, -22, -8, 8, 22, 35, 48, 60 },
57+
{ -15, -8, -2, 4, 10, 16, 22, 28 }
58+
};
59+
inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 };
60+
inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 };
61+
inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 };
62+
inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 };
63+
inline Value mg_knight_table[64] = { -50, -40, -30, -30, -30, -30, -40, -50, -40, -20, 0, 5, 5, 0, -20, -40,
64+
-30, 5, 10, 15, 15, 10, 5, -30, -30, 0, 15, 20, 20, 15, 0, -30,
65+
-30, 5, 15, 20, 20, 15, 5, -30, -30, 0, 10, 15, 15, 10, 0, -30,
66+
-40, -20, 0, 0, 0, 0, -20, -40, -50, -40, -30, -30, -30, -30, -40, -50 };
67+
inline Value mg_bishop_table[64] = { -20, -10, -10, -10, -10, -10, -10, -20, -10, 0, 0, 0, 0, 0, 0, -10,
68+
-10, 0, 10, 10, 10, 10, 0, -10, -10, 0, 5, 10, 10, 5, 0, -10,
69+
-10, 5, 5, 10, 10, 5, 5, -10, -10, 0, 10, 10, 10, 10, 0, -10,
70+
-10, 0, 0, 0, 0, 0, 0, -10, -20, -10, -10, -10, -10, -10, -10, -20 };
71+
inline Value mg_rook_table[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5,
72+
5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5,
73+
5, 5, 5, 0, 10, 15, 15, 15, 15, 15, 15, 10, 0, 0, 0, 0, 0, 0, 0, 0 };
74+
inline Value mg_king_table[64] = { -30, -40, -40, -50, -50, -40, -40, -30, -30, -40, -40, -50, -50, -40, -40, -30,
75+
-30, -40, -40, -50, -50, -40, -40, -30, -30, -40, -40, -50, -50, -40, -40, -30,
76+
-20, -30, -30, -40, -40, -30, -30, -20, -10, -20, -20, -20, -20, -20, -20, -10,
77+
20, 20, 0, 0, 0, 0, 20, 20, 20, 30, 10, 0, 0, 10, 30, 20 };
78+
inline Value mg_queen_table[64] = { -20, -10, -10, -5, -5, -10, -10, -20, -10, 0, 5, 0, 0, 0, 0, -10,
79+
-10, 5, 5, 5, 5, 5, 0, -10, 0, 0, 5, 5, 5, 5, 0, -5,
80+
-5, 0, 5, 5, 5, 5, 0, -5, -10, 0, 5, 5, 5, 5, 0, -10,
81+
-10, 0, 0, 0, 0, 0, 0, -10, -20, -10, -10, -5, -5, -10, -10, -20 };
82+
inline Value eg_knight_table[64] = { -50, -40, -20, -20, -20, -20, -40, -50, -40, -10, 5, 10, 10, 5, -10, -40,
83+
-30, 10, 20, 25, 25, 20, 10, -30, -30, 15, 25, 30, 30, 25, 15, -30,
84+
-30, 15, 25, 30, 30, 25, 15, -30, -30, 10, 20, 25, 25, 20, 10, -30,
85+
-40, -10, 5, 10, 10, 5, -10, -40, -50, -40, -20, -20, -20, -20, -40, -50 };
86+
inline Value eg_bishop_table[64] = { -10, -5, -5, -5, -5, -5, -5, -10, -5, 5, 10, 10, 10, 10, 5, -5, -5, 10, 15, 20, 20, 15,
87+
10, -5, -5, 10, 20, 25, 25, 20, 10, -5, -5, 10, 20, 25, 25, 20, 10, -5, -5, 10, 15, 20,
88+
20, 15, 10, -5, -5, 5, 10, 10, 10, 10, 5, -5, -10, -5, -5, -5, -5, -5, -5, -10 };
89+
inline Value eg_rook_table[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10,
90+
5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 10, 15, 20, 25, 25, 20, 15, 10, 10, 15, 20, 25,
91+
25, 20, 15, 10, 20, 25, 30, 35, 35, 30, 25, 20, 0, 0, 0, 5, 5, 0, 0, 0 };
92+
inline Value eg_king_table[64] = { -50, -40, -30, -20, -20, -30, -40, -50, -40, -20, 0, 10, 10, 0, -20, -40,
93+
-30, 0, 20, 30, 30, 20, 0, -30, -20, 10, 30, 40, 40, 30, 10, -20,
94+
-20, 10, 30, 40, 40, 30, 10, -20, -30, 0, 20, 30, 30, 20, 0, -30,
95+
-40, -20, 0, 10, 10, 0, -20, -40, -50, -40, -30, -20, -20, -30, -40, -50 };
96+
inline Value eg_queen_table[64] = { -10, -5, -5, 0, 0, -5, -5, -10, -5, 0, 5, 5, 5, 5, 0, -5, -5, 5, 10, 15, 15, 10,
97+
5, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 5, 10, 15,
98+
15, 10, 5, -5, -5, 0, 5, 5, 5, 5, 0, -5, -10, -5, -5, 0, 0, -5, -5, -10 };
99+
inline Value mg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -2, 2,
100+
5, 5, 2, -2, -5, -10, -5, 10, 20, 20, 10, -5, -10, -20, -10, 25, 40, 40, 25,
101+
-10, -20, -35, -20, 50, 80, 80, 50, -20, -35, -55, -40, 90, 130, 130, 90, -40, -55 };
102+
inline Value eg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -2, 2,
103+
5, 5, 2, -2, -5, -10, -5, 10, 20, 20, 10, -5, -10, -20, -10, 30, 55, 55, 30,
104+
-10, -20, -35, -20, 70, 110, 110, 70, -20, -35, -60, -45, 120, 180, 180, 120, -45, -60 };
105+
inline Value developedMg = 8;
106+
inline Value developedEg = 4;
107+
inline Value outpostBonusKnight[2] = { 15, 30 };
108+
inline Value outpostBonusBishop[2] = { 10, 25 };
109+
inline Value kingProtector[6][2] = {
110+
{ 0, 0 },
111+
{ 8, 12 },
112+
{ 5, 10 },
113+
{ 10, 15 },
114+
{ 3, 5 },
115+
{ 0, 0 }
116+
};
117+
inline Value threatByMinor[7][2] = {
118+
{ 0, 0 },
119+
{ 0, 0 },
120+
{ 15, 25 },
121+
{ 15, 25 },
122+
{ 25, 35 },
123+
{ 35, 50 }
124+
};
125+
inline Value threatByRook[7][2] = {
126+
{ 0, 0 },
127+
{ 0, 0 },
128+
{ 10, 15 },
129+
{ 10, 15 },
130+
{ 20, 25 },
131+
{ 25, 35 }
132+
};
38133
inline Value hangingScore = 70;
39134
inline Value overloadScore = 25;
40135
inline Value threatByRankScore = 10;
@@ -45,28 +140,5 @@ inline Value queenImWt = 50;
45140
inline Value rammedPawnPenalty = 10;
46141
inline Value rookOnSeventhBonus = 30;
47142
inline Value earlyQueenPenalty = 5;
48-
inline Value mgMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, { -15, -8, -2, 4, 10, 16, 22, 28 }, { -20, -12, -4, 5, 14, 23, 32, 40 }, { -25, -15, -5, 5, 15, 25, 35, 45 }, { -30, -18, -6, 6, 18, 30, 42, 55 }, { -10, -5, 0, 5, 10, 15, 20, 25 } };
49-
inline Value egMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0 }, { -20, -12, -4, 5, 14, 23, 32, 40 }, { -25, -15, -5, 5, 16, 27, 38, 50 }, { -30, -18, -6, 6, 18, 30, 42, 55 }, { -35, -22, -8, 8, 22, 35, 48, 60 }, { -15, -8, -2, 4, 10, 16, 22, 28 } };
50-
inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 };
51-
inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 };
52-
inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 };
53-
inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 };
54-
inline Value mg_knight_table[64] = { -50, -40, -30, -30, -30, -30, -40, -50, -40, -20, 0, 5, 5, 0, -20, -40, -30, 5, 10, 15, 15, 10, 5, -30, -30, 0, 15, 20, 20, 15, 0, -30, -30, 5, 15, 20, 20, 15, 5, -30, -30, 0, 10, 15, 15, 10, 0, -30, -40, -20, 0, 0, 0, 0, -20, -40, -50, -40, -30, -30, -30, -30, -40, -50 };
55-
inline Value mg_bishop_table[64] = { -20, -10, -10, -10, -10, -10, -10, -20, -10, 0, 0, 0, 0, 0, 0, -10, -10, 0, 10, 10, 10, 10, 0, -10, -10, 0, 5, 10, 10, 5, 0, -10, -10, 5, 5, 10, 10, 5, 5, -10, -10, 0, 10, 10, 10, 10, 0, -10, -10, 0, 0, 0, 0, 0, 0, -10, -20, -10, -10, -10, -10, -10, -10, -20 };
56-
inline Value mg_rook_table[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 0, 5, 5, 5, 5, 5, 5, 0, 10, 15, 15, 15, 15, 15, 15, 10, 0, 0, 0, 0, 0, 0, 0, 0 };
57-
inline Value mg_king_table[64] = { -30, -40, -40, -50, -50, -40, -40, -30, -30, -40, -40, -50, -50, -40, -40, -30, -30, -40, -40, -50, -50, -40, -40, -30, -30, -40, -40, -50, -50, -40, -40, -30, -20, -30, -30, -40, -40, -30, -30, -20, -10, -20, -20, -20, -20, -20, -20, -10, 20, 20, 0, 0, 0, 0, 20, 20, 20, 30, 10, 0, 0, 10, 30, 20 };
58-
inline Value mg_queen_table[64] = { -20, -10, -10, -5, -5, -10, -10, -20, -10, 0, 5, 0, 0, 0, 0, -10, -10, 5, 5, 5, 5, 5, 0, -10, 0, 0, 5, 5, 5, 5, 0, -5, -5, 0, 5, 5, 5, 5, 0, -5, -10, 0, 5, 5, 5, 5, 0, -10, -10, 0, 0, 0, 0, 0, 0, -10, -20, -10, -10, -5, -5, -10, -10, -20 };
59-
inline Value eg_knight_table[64] = { -50, -40, -20, -20, -20, -20, -40, -50, -40, -10, 5, 10, 10, 5, -10, -40, -30, 10, 20, 25, 25, 20, 10, -30, -30, 15, 25, 30, 30, 25, 15, -30, -30, 15, 25, 30, 30, 25, 15, -30, -30, 10, 20, 25, 25, 20, 10, -30, -40, -10, 5, 10, 10, 5, -10, -40, -50, -40, -20, -20, -20, -20, -40, -50 };
60-
inline Value eg_bishop_table[64] = { -10, -5, -5, -5, -5, -5, -5, -10, -5, 5, 10, 10, 10, 10, 5, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 10, 20, 25, 25, 20, 10, -5, -5, 10, 20, 25, 25, 20, 10, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 5, 10, 10, 10, 10, 5, -5, -10, -5, -5, -5, -5, -5, -5, -10 };
61-
inline Value eg_rook_table[64] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 0, 5, 10, 15, 15, 10, 5, 0, 10, 15, 20, 25, 25, 20, 15, 10, 10, 15, 20, 25, 25, 20, 15, 10, 20, 25, 30, 35, 35, 30, 25, 20, 0, 0, 0, 5, 5, 0, 0, 0 };
62-
inline Value eg_king_table[64] = { -50, -40, -30, -20, -20, -30, -40, -50, -40, -20, 0, 10, 10, 0, -20, -40, -30, 0, 20, 30, 30, 20, 0, -30, -20, 10, 30, 40, 40, 30, 10, -20, -20, 10, 30, 40, 40, 30, 10, -20, -30, 0, 20, 30, 30, 20, 0, -30, -40, -20, 0, 10, 10, 0, -20, -40, -50, -40, -30, -20, -20, -30, -40, -50 };
63-
inline Value eg_queen_table[64] = { -10, -5, -5, 0, 0, -5, -5, -10, -5, 0, 5, 5, 5, 5, 0, -5, -5, 5, 10, 15, 15, 10, 5, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 10, 15, 20, 20, 15, 10, -5, -5, 5, 10, 15, 15, 10, 5, -5, -5, 0, 5, 5, 5, 5, 0, -5, -10, -5, -5, 0, 0, -5, -5, -10 };
64-
inline Value mg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -2, 2, 5, 5, 2, -2, -5, -10, -5, 10, 20, 20, 10, -5, -10, -20, -10, 25, 40, 40, 25, -10, -20, -35, -20, 50, 80, 80, 50, -20, -35, -55, -40, 90, 130, 130, 90, -40, -55 };
65-
inline Value eg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -2, 2, 5, 5, 2, -2, -5, -10, -5, 10, 20, 20, 10, -5, -10, -20, -10, 30, 55, 55, 30, -10, -20, -35, -20, 70, 110, 110, 70, -20, -35, -60, -45, 120, 180, 180, 120, -45, -60 };
66-
inline Value outpostBonusKnight[2] = { 15, 30 };
67-
inline Value outpostBonusBishop[2] = { 10, 25 };
68-
inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } };
69-
inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } };
70-
inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } };
71143
} // namespace engine::eval
72144
#endif

eval.cpp

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,26 @@ Value *egPst[] = { nullptr, eg_pawn_table, eg_knight_table, eg_bishop_table, eg_
3232

3333
TUNE(SetRange(5, 30),
3434
tempo,
35-
SetRange(80, 120),
36-
PawnValue,
37-
SetRange(280, 370),
38-
KnightValue,
39-
SetRange(300, 400),
40-
BishopValue,
41-
SetRange(450, 550),
42-
RookValue,
35+
SetRange(80, 150),
36+
PawnValueMG,
37+
SetRange(160, 260),
38+
PawnValueEG,
39+
SetRange(650, 850),
40+
KnightValueMG,
41+
SetRange(750, 950),
42+
KnightValueEG,
43+
SetRange(700, 900),
44+
BishopValueMG,
4345
SetRange(800, 1000),
44-
QueenValue);
46+
BishopValueEG,
47+
SetRange(1100, 1400),
48+
RookValueMG,
49+
SetRange(1200, 1500),
50+
RookValueEG,
51+
SetRange(2200, 2800),
52+
QueenValueMG,
53+
SetRange(2400, 3000),
54+
QueenValueEG);
4555
TUNE(SetRange(-50, 70), mgMobilityCnt, egMobilityCnt);
4656
TUNE(SetRange(0, 30), fianchettoBonus, SetRange(0, 100), trappedBishopPenalty);
4757
TUNE(SetRange(-20, 20), kingTropismMg, kingTropismEg);
@@ -281,8 +291,8 @@ EvalComponents eval_components(const chess::Position &board) {
281291
continue;
282292
mgScore += _sign * mgPst[pt][_sq];
283293
egScore += _sign * egPst[pt][_sq];
284-
mgScore += _sign * piece_value(pt);
285-
egScore += _sign * piece_value(pt);
294+
mgScore += _sign * piece_value_mg(pt);
295+
egScore += _sign * piece_value_eg(pt);
286296
if (pt == KNIGHT)
287297
phase += KnightPhase;
288298
else if (pt == BISHOP)
@@ -715,18 +725,45 @@ EvalComponents eval_components(const chess::Position &board) {
715725
board.count<ROOK>() == 0 && board.count<QUEEN>() == 0)
716726
return { 0, 0, 0 };
717727

718-
phase = std::min((phase * 256 + TotalPhase / 2) / TotalPhase, 256);
728+
phase = std::min((phase * 128 + TotalPhase / 2) / TotalPhase, 128);
719729
return { mgScore, egScore, phase };
720730
}
721731
Value eval(const chess::Position &board) {
722-
const int sign = board.side_to_move() == WHITE ? 1 : -1;
723732
auto [mg, eg, phase] = eval_components(board);
724-
if (mg == 0 && eg == 0)
733+
// Draw detected by eval_components (returned {0,0,0})
734+
if (mg == 0 && eg == 0 && phase == 0)
725735
return 0;
726-
return (((mg * phase) + (eg * (256 - phase))) * sign) / 256 + engine::eval::tempo;
736+
737+
// Scale factor (guide-based, simplified)
738+
int sf = 64;
739+
int total = popcount(board.occ());
740+
int pawns = board.count<PAWN>();
741+
if (total == 2 && pawns == 0)
742+
return 0; // K vs K draw
743+
if (total <= 4 && pawns == 0)
744+
sf = 32;
745+
eg = eg * sf / 64;
746+
747+
// Tapered mix
748+
int v = (mg * phase + eg * (128 - phase)) / 128;
749+
750+
// Quantization to multiples of 16 (guide convention)
751+
v = (v / 16) * 16;
752+
753+
// 50-move rule scaling
754+
int rule50 = std::min(static_cast<int>(board.rule50_count()), 100);
755+
v = v * (100 - rule50) / 100;
756+
757+
// Convert to side-to-move perspective and add tempo
758+
const int sign = board.side_to_move() == WHITE ? 1 : -1;
759+
return v * sign + engine::eval::tempo;
760+
}
761+
Value piece_value_mg(PieceType pt) {
762+
Value pieces[] = { 0, PawnValueMG, KnightValueMG, BishopValueMG, RookValueMG, QueenValueMG, 0 };
763+
return pieces[pt];
727764
}
728-
Value piece_value(PieceType pt) {
729-
Value pieces[] = { 0, PawnValue, KnightValue, BishopValue, RookValue, QueenValue, 0 };
765+
Value piece_value_eg(PieceType pt) {
766+
Value pieces[] = { 0, PawnValueEG, KnightValueEG, BishopValueEG, RookValueEG, QueenValueEG, 0 };
730767
return pieces[pt];
731768
}
732769
} // namespace engine::eval

eval.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ extern Value *egPst[];
5252

5353
Value eval(const chess::Position &board);
5454
EvalComponents eval_components(const chess::Position &board);
55-
Value piece_value(chess::PieceType pt);
55+
Value piece_value_mg(chess::PieceType pt);
56+
Value piece_value_eg(chess::PieceType pt);
5657
} // namespace eval
5758
} // namespace engine

movepick.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "search.h"
44
#include <algorithm>
55
using namespace chess;
6-
using engine::eval::piece_value;
6+
using engine::eval::piece_value_mg;
77
namespace engine::movepick {
88

99
static Bitboard att(PieceType pt, Square sq, Bitboard occ) {
@@ -66,15 +66,15 @@ Value see(Position &board, Move move) {
6666
Value gain[32];
6767
PieceType attacker = board.at<PieceType>(move.from());
6868

69-
gain[0] = piece_value(captured);
69+
gain[0] = piece_value_mg(captured);
7070

7171
Color stm = ~board.side_to_move();
7272
int d = 0;
7373

7474
while (++d < 32) {
7575

7676
// Charge the piece that just captured.
77-
gain[d] = piece_value(attacker) - gain[d - 1];
77+
gain[d] = piece_value_mg(attacker) - gain[d - 1];
7878

7979
if (gain[d] < 0)
8080
break;
@@ -109,8 +109,8 @@ void orderMoves(Position &board, Movelist &moves, Move ttMove, int ply, const en
109109
scores[i] = 10000;
110110
else if (board.isCapture(move)) {
111111
Value s = see(board, move);
112-
Value capturedVal = move.type_of() == EN_PASSANT ? piece_value(PAWN) : piece_value(board.at<PieceType>(move.to()));
113-
Value attackerVal = piece_value(board.at<PieceType>(move.from()));
112+
Value capturedVal = move.type_of() == EN_PASSANT ? piece_value_mg(PAWN) : piece_value_mg(board.at<PieceType>(move.to()));
113+
Value attackerVal = piece_value_mg(board.at<PieceType>(move.from()));
114114
scores[i] = (s >= -50 ? 9000 : 4000) + std::max(s, Value(-50)) + (capturedVal * 10 - attackerVal) / 100;
115115
} else if (move == session.killerMoves[ply][0])
116116
scores[i] = 8500;

search.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Value qsearch(Position &board, Value alpha, Value beta, search::Session &session
146146
continue;
147147
if (isCapture && !givesCheck && move.type_of() != PROMOTION) {
148148
Value capturedValue =
149-
move.type_of() == EN_PASSANT ? eval::piece_value(PAWN) : eval::piece_value(board.at<PieceType>(move.to()));
149+
move.type_of() == EN_PASSANT ? eval::piece_value_mg(PAWN) : eval::piece_value_mg(board.at<PieceType>(move.to()));
150150
if (standPat + capturedValue + 200 < alpha)
151151
continue;
152152
if (movepick::see(board, move) < 0)

0 commit comments

Comments
 (0)