Skip to content

Commit d607487

Browse files
committed
tune
1 parent f7d5fed commit d607487

4 files changed

Lines changed: 22 additions & 29 deletions

File tree

.github/workflows/spsa.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: run SPSA (see gist)
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
output_exec:
7-
description: "Executable output file name"
8-
required: false
9-
default: "engine"
105
jobs:
116
worker:
127
runs-on: ubuntu-latest

Weights.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ inline Value mopUpEdgeDistWeight = 10;
1616
inline Value spaceWeight = 2;
1717
inline Value bishopPairMg = 25;
1818
inline Value bishopPairEg = 50;
19-
inline Value developedMg = 8;
20-
inline Value developedEg = 4;
2119
inline Value rookOpenFileMg = 25;
2220
inline Value rookOpenFileEg = 20;
2321
inline Value rookSemiOpenFileMg = 15;
@@ -35,16 +33,6 @@ inline Value kqkEdgeWeight = 15;
3533
inline Value krkDistWeight = 5;
3634
inline Value krkEdgeWeight = 10;
3735
inline Value kpkWeight = 15;
38-
inline Value hangingScore = 70;
39-
inline Value overloadScore = 25;
40-
inline Value threatByRankScore = 10;
41-
inline Value minorImWt = 30;
42-
inline Value bishopImWt = 15;
43-
inline Value rookImWt = 20;
44-
inline Value queenImWt = 50;
45-
inline Value rammedPawnPenalty = 10;
46-
inline Value rookOnSeventhBonus = 30;
47-
inline Value earlyQueenPenalty = 5;
4836
inline Value mgMobilityCnt[7][8] = {
4937
{ 0, 0, 0, 0, 0, 0, 0, 0 },
5038
{ 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -109,6 +97,8 @@ inline Value mg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10997
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,
11098
5, 5, 2, -2, -5, -10, -5, 10, 20, 20, 10, -5, -10, -20, -10, 30, 55, 55, 30,
11199
-10, -20, -35, -20, 70, 110, 110, 70, -20, -35, -60, -45, 120, 180, 180, 120, -45, -60 };
100+
inline Value developedMg = 8;
101+
inline Value developedEg = 4;
112102
inline Value outpostBonusKnight[2] = { 15, 30 };
113103
inline Value outpostBonusBishop[2] = { 10, 25 };
114104
inline Value kingProtector[6][2] = {
@@ -125,17 +115,25 @@ inline Value threatByMinor[7][2] = {
125115
{ 15, 25 },
126116
{ 15, 25 },
127117
{ 25, 35 },
128-
{ 35, 50 },
129-
{ 0, 0 }
118+
{ 35, 50 }
130119
};
131120
inline Value threatByRook[7][2] = {
132121
{ 0, 0 },
133122
{ 0, 0 },
134123
{ 10, 15 },
135124
{ 10, 15 },
136125
{ 20, 25 },
137-
{ 25, 35 },
138-
{ 0, 0 }
126+
{ 25, 35 }
139127
};
128+
inline Value hangingScore = 70;
129+
inline Value overloadScore = 25;
130+
inline Value threatByRankScore = 10;
131+
inline Value minorImWt = 30;
132+
inline Value bishopImWt = 15;
133+
inline Value rookImWt = 20;
134+
inline Value queenImWt = 50;
135+
inline Value rammedPawnPenalty = 10;
136+
inline Value rookOnSeventhBonus = 30;
137+
inline Value earlyQueenPenalty = 5;
140138
} // namespace engine::eval
141139
#endif

eval.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ EvalComponents eval_components(const chess::Position &board) {
238238
// Precompute pawn attacks (needed for outpost, threats, etc.)
239239
Bitboard pawnBB[2] = { board.pieces(PAWN, WHITE), board.pieces(PAWN, BLACK) };
240240
Bitboard pawnAtks[2] = { attacks::pawn<WHITE>(pawnBB[WHITE]), attacks::pawn<BLACK>(pawnBB[BLACK]) };
241-
#if 0
241+
#if 1
242242
// Development bonus: penalize undeveloped knights/bishops in middlegame
243243
int devCount[2] = { 0, 0 };
244244
for (Color c : { WHITE, BLACK }) {
@@ -250,7 +250,7 @@ EvalComponents eval_components(const chess::Position &board) {
250250
devCount[c] = popcount(knightsHome) + popcount(bishopsHome);
251251
}
252252
mgScore += (devCount[BLACK] - devCount[WHITE]) * developedMg;
253-
egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg;
253+
//egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg;
254254

255255
// Early queen development penalty: queen moved but minors still on back rank
256256
for (Color c : { WHITE, BLACK }) {
@@ -312,7 +312,7 @@ EvalComponents eval_components(const chess::Position &board) {
312312
mgScore += _sign * (7 - kd) * kingTropismMg[pt];
313313
egScore += _sign * (7 - kd) * kingTropismEg[pt];
314314
}
315-
#if 0
315+
#if 1
316316
// King protector: bonus for pieces close to own king
317317
if (pt != PAWN && pt != KING) {
318318
int kdist = square_distance(sq, board.kingSq(pc));
@@ -361,7 +361,7 @@ EvalComponents eval_components(const chess::Position &board) {
361361
}
362362
}
363363
}
364-
#if 0
364+
#if 1
365365
// Trapped bishop penalty
366366
for (Color c : { WHITE, BLACK }) {
367367
int s = (c == WHITE) ? 1 : -1;
@@ -394,7 +394,7 @@ EvalComponents eval_components(const chess::Position &board) {
394394
}
395395
}
396396
}
397-
#if 0
397+
#if 1
398398
// Rook on seventh rank bonus (endgame, x-raying >=2 undefended pawns)
399399
for (Color c : { WHITE, BLACK }) {
400400
int s = (c == WHITE) ? 1 : -1;
@@ -463,7 +463,7 @@ EvalComponents eval_components(const chess::Position &board) {
463463
}
464464
}
465465
}
466-
#if 0
466+
#if 1
467467
// Pawn rams: blocked pawn penalty
468468
for (Color c : { WHITE, BLACK }) {
469469
int s = (c == WHITE) ? 1 : -1;
@@ -606,7 +606,7 @@ EvalComponents eval_components(const chess::Position &board) {
606606
}
607607

608608
// --- Threat evaluation ---
609-
#if 0
609+
#if 1
610610
for (Color c : { WHITE, BLACK }) {
611611
int s = (c == WHITE) ? 1 : -1;
612612
Color opp = ~c;

spsa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def run_fastchess_match(plus_params, minus_params, args, iteration):
255255
return 0.5, 0.5
256256
stats = output_config.get("stats", {})
257257

258-
if stats_key in stats and "wins" in stats[stats_key]:
258+
if "Plus vs Minus" in stats and "wins" in stats["Plus vs Minus"]:
259259
w = stats[stats_key]["wins"]
260260
l = stats[stats_key]["losses"]
261261
d = stats[stats_key]["draws"]

0 commit comments

Comments
 (0)