From df977988a5c3ac7881b7e079aaa23869d6ed3758 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 11 Jul 2026 12:16:11 +0700 Subject: [PATCH 01/49] tune --- .github/workflows/spsa.yml | 8 +-- Weights.h | 117 ++++++++----------------------------- 2 files changed, 29 insertions(+), 96 deletions(-) diff --git a/.github/workflows/spsa.yml b/.github/workflows/spsa.yml index c73ebdf..2c7d10f 100644 --- a/.github/workflows/spsa.yml +++ b/.github/workflows/spsa.yml @@ -40,13 +40,13 @@ jobs: cmake --build . -j$(nproc) - name: Tune engine run: | - python spsa.py --iters 150 --pairs 30 --engine build/engine --workers $(nproc) + python spsa.py --iters 160 --pairs 30 --engine build/engine --workers $(nproc) - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: spsa-results path: | ./Weights.h - *.pgn - *.epd - compression-level: 0 + games*.pgn + games*.epd + compression-level: 9 diff --git a/Weights.h b/Weights.h index b20dd65..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -16,6 +16,8 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -33,98 +35,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -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 } -}; -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 } -}; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value developedMg = 8; -inline Value developedEg = 4; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 } -}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -135,5 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; +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 } }; +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 } }; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif From 7a71b9b2b4e9ce8c9c2eb8ce899a3a2e8b44b27c Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 11 Jul 2026 05:16:46 +0000 Subject: [PATCH 02/49] Apply clang-format --- Weights.h | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/Weights.h b/Weights.h index 7caf065..62b181b 100644 --- a/Weights.h +++ b/Weights.h @@ -45,28 +45,97 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; +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 } +}; +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 } +}; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 }, + { 0, 0 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 }, + { 0, 0 } +}; } // namespace engine::eval #endif From fab3ee7d71aa369f1616bf91e6f4b43307d4d9c2 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:32:46 +0700 Subject: [PATCH 03/49] shards for fastchess --- .github/workflows/games.yml | 104 ++++++++++++++++++++++++------------ spsa.py | 12 ++--- 2 files changed, 77 insertions(+), 39 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index ca44eb8..43c48a2 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: path: new persist-credentials: false @@ -64,7 +64,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: ref: ${{ github.event.inputs.base_ref }} path: base @@ -86,60 +86,98 @@ jobs: with: name: base-engine path: base/build/${{ github.event.inputs.output_exec }} - - - test: + prepare-tools: runs-on: ubuntu-latest - needs: [build-new, build-base] steps: - - name: Download engines - uses: actions/download-artifact@v4 + - run: | + mkdir tools + cd tools - - name: Install tools - env: - OUTPUT_EXEC: ${{ github.event.inputs.output_exec }} - run: | sudo apt update sudo apt install -y wget unzip - wget https://github.com/Disservin/fastchess/releases/download/v1.8.0-alpha/fastchess-linux-x86-64.tar tar -xf fastchess-linux-x86-64.tar chmod +x fastchess-linux-x86-64/fastchess mv fastchess-linux-x86-64/fastchess fastchess - wget https://github.com/official-stockfish/books/raw/refs/heads/master/UHO_Lichess_4852_v1.epd.zip unzip UHO_Lichess_4852_v1.epd.zip - wget https://github.com/michiguel/Ordo/releases/download/1.0/ordo-linux64 chmod +x ordo-linux64 + - uses: actions/upload-artifact@v4 + with: + name: tools + path: tools/ + test: + needs: [build-new, build-base, prepare-tools] + strategy: + fail-fast: false + matrix: + shard: [0, 1, 2, 3] + + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v4 + - name: Play games + env: + OUTPUT_EXEC: ${{ github.event.inputs.output_exec }} + TC: ${{ github.event.inputs.tc }} + run: | chmod +x new-engine/engine chmod +x base-engine/$OUTPUT_EXEC + tools/fastchess \ + -engine cmd=new-engine/engine name=new \ + -engine cmd=base-engine/$OUTPUT_EXEC name=base \ + -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ + -each tc=$TC \ + -rounds 1500 \ + -concurrency $(nproc) \ + -randomseed ${{ matrix.shard }} \ + -pgnout notation=san nodes=true \ + file=games_${{ matrix.shard }}.pgn \ + | tee results_${{ matrix.shard }}.txt + + - uses: actions/upload-artifact@v4 + with: + name: shard-${{ matrix.shard }} + path: | + games_${{ matrix.shard }}.pgn + results_${{ matrix.shard }}.txt + + evaluate: + needs: test + runs-on: ubuntu-latest + + steps: + - uses: actions/download-artifact@v4 - - name: Run fastchess + + - name: Run Ordo + run: | + ./ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn + + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + + - name: SPRT env: ELO0: ${{ github.event.inputs.elo0 }} ELO1: ${{ github.event.inputs.elo1 }} - TC: ${{ github.event.inputs.tc }} - OUTPUT_EXEC: ${{ github.event.inputs.output_exec }} - ROUNDS: ${{ github.event.inputs.rounds }} run: | - ./fastchess -recover \ - -engine cmd=new-engine/engine name=new \ - -engine cmd=base-engine/$OUTPUT_EXEC name=base \ - -openings file=UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC \ - -rounds $ROUNDS \ - -concurrency $(nproc) \ - -pgnout notation=san nodes=true file=games.pgn \ - -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 | tee results.txt - ./ordo-linux64 -o ratings.txt -- games.pgn - - name: Upload results - uses: actions/upload-artifact@v4 + pip install chess scipy + git clone https://github.com/jdart1/stats.git + python stats/sprt.py \ + --elo0 "$ELO0" \ + --elo1 "$ELO1" --alpha 0.05 --beta 0.05 --results $( + python extract_ptnml.py shard-*/*.pgn | tee results.txt | tail -n 1)> sprt.txt + - uses: actions/upload-artifact@v4 with: name: results path: | - games.pgn + shard-*/games_*.pgn ratings.txt - results.txt + sprt.txt + results.txt \ No newline at end of file diff --git a/spsa.py b/spsa.py index 82a4492..1f296a1 100644 --- a/spsa.py +++ b/spsa.py @@ -108,14 +108,14 @@ "options": [], "limit": { "tc": { - "increment": 0, + "increment": 100, "fixed_time": 0, - "time": 0, + "time": 10000, "moves": 0, "timemargin": 0 }, "nodes": 0, - "plies": 5 + "plies": 0 }, "variant": 0 }, @@ -128,14 +128,14 @@ "options": [], "limit": { "tc": { - "increment": 0, + "increment": 100, "fixed_time": 0, - "time": 0, + "time": 10000, "moves": 0, "timemargin": 0 }, "nodes": 0, - "plies": 5 + "plies": 0 }, "variant": 0 } From 992a884e71d2b1da305c3a393d419f5151224205 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:35:23 +0700 Subject: [PATCH 04/49] oopsie --- .github/workflows/games.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 43c48a2..668905d 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -98,12 +98,10 @@ jobs: sudo apt install -y wget unzip wget https://github.com/Disservin/fastchess/releases/download/v1.8.0-alpha/fastchess-linux-x86-64.tar tar -xf fastchess-linux-x86-64.tar - chmod +x fastchess-linux-x86-64/fastchess mv fastchess-linux-x86-64/fastchess fastchess wget https://github.com/official-stockfish/books/raw/refs/heads/master/UHO_Lichess_4852_v1.epd.zip unzip UHO_Lichess_4852_v1.epd.zip wget https://github.com/michiguel/Ordo/releases/download/1.0/ordo-linux64 - chmod +x ordo-linux64 - uses: actions/upload-artifact@v4 with: @@ -127,6 +125,8 @@ jobs: run: | chmod +x new-engine/engine chmod +x base-engine/$OUTPUT_EXEC + chmod +x tools/fastchess-linux-x86-64/fastchess + chmod +x tools/ordo-linux64 tools/fastchess \ -engine cmd=new-engine/engine name=new \ -engine cmd=base-engine/$OUTPUT_EXEC name=base \ @@ -156,7 +156,8 @@ jobs: - name: Run Ordo run: | - ./ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn + chmod +x tools/ordo-linux64 + tools/ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn - uses: actions/setup-python@v6 with: From a9869edd24aa32078164182d5bab2009d2157b79 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:37:01 +0700 Subject: [PATCH 05/49] oopsie --- .github/workflows/games.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 668905d..ad2284b 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -125,7 +125,7 @@ jobs: run: | chmod +x new-engine/engine chmod +x base-engine/$OUTPUT_EXEC - chmod +x tools/fastchess-linux-x86-64/fastchess + chmod +x tools/fastchess chmod +x tools/ordo-linux64 tools/fastchess \ -engine cmd=new-engine/engine name=new \ From a368d116af914e3963fe50e048cf6bb4c5c20666 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 11 Jul 2026 22:38:29 +0700 Subject: [PATCH 06/49] oopsie --- .github/workflows/games.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index ad2284b..fbe88bf 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -134,7 +134,6 @@ jobs: -each tc=$TC \ -rounds 1500 \ -concurrency $(nproc) \ - -randomseed ${{ matrix.shard }} \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ | tee results_${{ matrix.shard }}.txt From f35901ab657ee44e32a3d73a3279442661af5422 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 07:33:45 +0700 Subject: [PATCH 07/49] test --- .github/workflows/games.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index fbe88bf..ba037d9 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -132,7 +132,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC \ - -rounds 1500 \ + -rounds 1 \ -concurrency $(nproc) \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ @@ -156,7 +156,7 @@ jobs: - name: Run Ordo run: | chmod +x tools/ordo-linux64 - tools/ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn + tools/ordo-linux64 -o ratings.txt shard-*/games_*.pgn - uses: actions/setup-python@v6 with: From 53e66359d8cb2770e044efd145777408817244bb Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 07:36:48 +0700 Subject: [PATCH 08/49] test --- .github/workflows/games.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index ba037d9..cf09d27 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -156,7 +156,8 @@ jobs: - name: Run Ordo run: | chmod +x tools/ordo-linux64 - tools/ordo-linux64 -o ratings.txt shard-*/games_*.pgn + printf '<%s>\n' shard-*/game_*.pgn + tools/ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn - uses: actions/setup-python@v6 with: From cdd863f30ce39f1d1fa79ecb845ba72bf767f6f7 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 07:40:12 +0700 Subject: [PATCH 09/49] test --- .github/workflows/games.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index cf09d27..d812551 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -156,8 +156,9 @@ jobs: - name: Run Ordo run: | chmod +x tools/ordo-linux64 - printf '<%s>\n' shard-*/game_*.pgn - tools/ordo-linux64 -o ratings.txt -- shard-*/games_*.pgn + printf '<%s>\n' shard-*/games_*.pgn + cat shard-*/games_*.pgn > games.pgn + tools/ordo-linux64 -o ratings.txt games.pgn - uses: actions/setup-python@v6 with: From 1acb4886bcfc4048e52ddb82d61527645c287f35 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 07:45:36 +0700 Subject: [PATCH 10/49] test --- .github/workflows/games.yml | 14 +++-- extract_ptnml.py | 118 ++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 5 deletions(-) create mode 100644 extract_ptnml.py diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index d812551..833c93d 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -132,7 +132,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC \ - -rounds 1 \ + -rounds 1500 \ -concurrency $(nproc) \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ @@ -171,10 +171,14 @@ jobs: run: | pip install chess scipy git clone https://github.com/jdart1/stats.git - python stats/sprt.py \ - --elo0 "$ELO0" \ - --elo1 "$ELO1" --alpha 0.05 --beta 0.05 --results $( - python extract_ptnml.py shard-*/*.pgn | tee results.txt | tail -n 1)> sprt.txt + RESULTS=$(python extract_ptnml.py shard-*/*.pgn | tee results.txt | tail -n1) + python -m stats.sprt \ + --elo0 "$ELO0" \ + --elo1 "$ELO1" \ + --alpha 0.05 \ + --beta 0.05 \ + --results "$RESULTS" + - uses: actions/upload-artifact@v4 with: name: results diff --git a/extract_ptnml.py b/extract_ptnml.py new file mode 100644 index 0000000..fb67ed8 --- /dev/null +++ b/extract_ptnml.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python3 + +import argparse +import glob +from collections import defaultdict +from itertools import chain +import chess.pgn + +# [LL, LD/DL, WL/DD/LW, WD/DW, WW] +PTNML_INDEX = {-2: 0, -1: 1, 0: 2, 1: 3, 2: 4} + + +def score_from_new(headers): + result = headers["Result"] + + if result == "1/2-1/2": + return 0 + + new_is_white = headers["White"] == "new" + + if new_is_white: + return 1 if result == "1-0" else -1 + else: + return 1 if result == "0-1" else -1 + + +def main(): + parser = argparse.ArgumentParser( + description="Extract WDL and pentanomial statistics from fastchess PGNs" + ) + parser.add_argument("pgns", nargs="+") + args = parser.parse_args() + + pairs = defaultdict(list) + + # WDL = [loss, draw, win] + wdl = [0, 0, 0] + games = 0 + + for filename in chain.from_iterable(glob.glob(p) for p in args.pgns): + with open(filename, encoding="utf-8") as f: + while (game := chess.pgn.read_game(f)) is not None: + headers = game.headers + + score = score_from_new(headers) + + games += 1 + if score < 0: + wdl[0] += 1 + elif score == 0: + wdl[1] += 1 + else: + wdl[2] += 1 + + fen = headers.get("FEN") + round_id = headers.get("Round") + + if fen is None or round_id is None: + raise RuntimeError( + f"{filename}: missing FEN or Round tag" + ) + + # Include filename because each shard starts rounds again + key = ( + filename, + round_id, + fen, + ) + + pairs[key].append(score) + + ptnml = [0] * 5 + pairs_count = 0 + + for key, scores in pairs.items(): + if len(scores) != 2: + print( + f"Skipping incomplete pair {key}: got {len(scores)} games" + ) + continue + + # Make sure the two games are the repeat pair + if scores[0] + scores[1] not in PTNML_INDEX: + raise RuntimeError("Invalid pair score") + + ptnml[PTNML_INDEX[scores[0] + scores[1]]] += 1 + pairs_count += 1 + + print(f"Games: {games}") + print(f"Pairs: {pairs_count}") + + print() + print("WDL:") + print(f" Loss: {wdl[0]}") + print(f" Draw: {wdl[1]}") + print(f" Win : {wdl[2]}") + print() + print(wdl) + + print() + print("PTNML:") + names = [ + "LL", + "LD", + "WL/DD", + "WD", + "WW", + ] + + for name, count in zip(names, ptnml): + print(f" {name:10}: {count}") + + print() + print(ptnml) + + +if __name__ == "__main__": + main() \ No newline at end of file From a6c740c7bb034c469675fac4317cec0895737eef Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 07:50:19 +0700 Subject: [PATCH 11/49] test --- .github/workflows/games.yml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 833c93d..7616085 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -127,16 +127,30 @@ jobs: chmod +x base-engine/$OUTPUT_EXEC chmod +x tools/fastchess chmod +x tools/ordo-linux64 - tools/fastchess \ - -engine cmd=new-engine/engine name=new \ - -engine cmd=base-engine/$OUTPUT_EXEC name=base \ - -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC \ - -rounds 1500 \ - -concurrency $(nproc) \ - -pgnout notation=san nodes=true \ - file=games_${{ matrix.shard }}.pgn \ - | tee results_${{ matrix.shard }}.txt + max_retries=3 + for attempt in $(seq 1 $max_retries); do + echo "Fastchess attempt $attempt/$max_retries" + if tools/fastchess \ + -recover -repeat \ + -engine cmd=new-engine/engine name=new \ + -engine cmd=base-engine/$OUTPUT_EXEC name=base \ + -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ + -each tc=$TC \ + -rounds 1500 \ + -concurrency $(nproc) \ + -pgnout notation=san nodes=true \ + file=games_${{ matrix.shard }}.pgn \ + | tee results_${{ matrix.shard }}.txt; then + echo "Fastchess completed successfully." + exit 0 + fi + if [ "$attempt" -lt "$max_retries" ]; then + echo "Fastchess failed, retrying in 5 seconds..." + sleep 5 + fi + done + echo "Fastchess failed after $max_retries attempts." + exit 1 - uses: actions/upload-artifact@v4 with: From 12989edcf29b9fc66a232f6b8b93bd537c6e1bfe Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 08:17:49 +0700 Subject: [PATCH 12/49] test --- .github/workflows/games.yml | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 7616085..833c93d 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -127,30 +127,16 @@ jobs: chmod +x base-engine/$OUTPUT_EXEC chmod +x tools/fastchess chmod +x tools/ordo-linux64 - max_retries=3 - for attempt in $(seq 1 $max_retries); do - echo "Fastchess attempt $attempt/$max_retries" - if tools/fastchess \ - -recover -repeat \ - -engine cmd=new-engine/engine name=new \ - -engine cmd=base-engine/$OUTPUT_EXEC name=base \ - -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC \ - -rounds 1500 \ - -concurrency $(nproc) \ - -pgnout notation=san nodes=true \ - file=games_${{ matrix.shard }}.pgn \ - | tee results_${{ matrix.shard }}.txt; then - echo "Fastchess completed successfully." - exit 0 - fi - if [ "$attempt" -lt "$max_retries" ]; then - echo "Fastchess failed, retrying in 5 seconds..." - sleep 5 - fi - done - echo "Fastchess failed after $max_retries attempts." - exit 1 + tools/fastchess \ + -engine cmd=new-engine/engine name=new \ + -engine cmd=base-engine/$OUTPUT_EXEC name=base \ + -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ + -each tc=$TC \ + -rounds 1500 \ + -concurrency $(nproc) \ + -pgnout notation=san nodes=true \ + file=games_${{ matrix.shard }}.pgn \ + | tee results_${{ matrix.shard }}.txt - uses: actions/upload-artifact@v4 with: From 2650f132df9ae8d090f32ae3e51cfb58b65f0bea Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 11:05:05 +0700 Subject: [PATCH 13/49] test --- .github/workflows/games.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 833c93d..3c248df 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -128,8 +128,8 @@ jobs: chmod +x tools/fastchess chmod +x tools/ordo-linux64 tools/fastchess \ - -engine cmd=new-engine/engine name=new \ - -engine cmd=base-engine/$OUTPUT_EXEC name=base \ + -engine cmd=new-engine/engine name=new timeout=100000 \ + -engine cmd=base-engine/$OUTPUT_EXEC name=base timeout=100000 \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC \ -rounds 1500 \ From 45d9b0baf20f2eb167fbc681644ebc079908451c Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 11:11:56 +0700 Subject: [PATCH 14/49] fix --- .github/workflows/games.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 3c248df..3dff7cc 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -128,10 +128,10 @@ jobs: chmod +x tools/fastchess chmod +x tools/ordo-linux64 tools/fastchess \ - -engine cmd=new-engine/engine name=new timeout=100000 \ - -engine cmd=base-engine/$OUTPUT_EXEC name=base timeout=100000 \ + -engine cmd=new-engine/engine name=new \ + -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC \ + -each tc=$TC -startup-ms 60000 \ -rounds 1500 \ -concurrency $(nproc) \ -pgnout notation=san nodes=true \ From 15f5fa882d192cf214335cc5ef8a78b2e0842544 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 11:58:23 +0700 Subject: [PATCH 15/49] fix --- .github/workflows/games.yml | 2 +- Weights.h | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 3dff7cc..93aea91 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -132,7 +132,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC -startup-ms 60000 \ - -rounds 1500 \ + -rounds 1500 -repeat \ -concurrency $(nproc) \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ diff --git a/Weights.h b/Weights.h index 62b181b..b20dd65 100644 --- a/Weights.h +++ b/Weights.h @@ -16,8 +16,6 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; -inline Value developedMg = 8; -inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -35,16 +33,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -inline Value hangingScore = 70; -inline Value overloadScore = 25; -inline Value threatByRankScore = 10; -inline Value minorImWt = 30; -inline Value bishopImWt = 15; -inline Value rookImWt = 20; -inline Value queenImWt = 50; -inline Value rammedPawnPenalty = 10; -inline Value rookOnSeventhBonus = 30; -inline Value earlyQueenPenalty = 5; inline Value mgMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 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, 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 }; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; inline Value kingProtector[6][2] = { @@ -125,8 +115,7 @@ inline Value threatByMinor[7][2] = { { 15, 25 }, { 15, 25 }, { 25, 35 }, - { 35, 50 }, - { 0, 0 } + { 35, 50 } }; inline Value threatByRook[7][2] = { { 0, 0 }, @@ -134,8 +123,17 @@ inline Value threatByRook[7][2] = { { 10, 15 }, { 10, 15 }, { 20, 25 }, - { 25, 35 }, - { 0, 0 } + { 25, 35 } }; +inline Value hangingScore = 70; +inline Value overloadScore = 25; +inline Value threatByRankScore = 10; +inline Value minorImWt = 30; +inline Value bishopImWt = 15; +inline Value rookImWt = 20; +inline Value queenImWt = 50; +inline Value rammedPawnPenalty = 10; +inline Value rookOnSeventhBonus = 30; +inline Value earlyQueenPenalty = 5; } // namespace engine::eval #endif From 7ee1eb9c8b5404ba1ddfca6c04d05c67620b2597 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 19:26:25 +0700 Subject: [PATCH 16/49] tune --- Weights.h | 117 ++++++++++++------------------------------------------ 1 file changed, 25 insertions(+), 92 deletions(-) diff --git a/Weights.h b/Weights.h index b20dd65..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -16,6 +16,8 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -33,98 +35,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -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 } -}; -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 } -}; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value developedMg = 8; -inline Value developedEg = 4; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 } -}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -135,5 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; +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 } }; +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 } }; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif From 4e1e71fed0c41dd3baf39cde46e25f398dce2024 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sun, 12 Jul 2026 12:26:41 +0000 Subject: [PATCH 17/49] Apply clang-format --- Weights.h | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/Weights.h b/Weights.h index 7caf065..62b181b 100644 --- a/Weights.h +++ b/Weights.h @@ -45,28 +45,97 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; +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 } +}; +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 } +}; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 }, + { 0, 0 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 }, + { 0, 0 } +}; } // namespace engine::eval #endif From db09e38ce057e7e36312ff7b393a103886f5e5e7 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 12 Jul 2026 20:21:19 +0700 Subject: [PATCH 18/49] tune --- .github/workflows/games.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 93aea91..3f91644 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -122,6 +122,8 @@ jobs: env: OUTPUT_EXEC: ${{ github.event.inputs.output_exec }} TC: ${{ github.event.inputs.tc }} + ELO0: ${{ github.event.inputs.elo0 }} + ELO1: ${{ github.event.inputs.elo1 }} run: | chmod +x new-engine/engine chmod +x base-engine/$OUTPUT_EXEC @@ -131,9 +133,9 @@ jobs: -engine cmd=new-engine/engine name=new \ -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC -startup-ms 60000 \ - -rounds 1500 -repeat \ - -concurrency $(nproc) \ + -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000\ + -rounds 1500 -repeat -log level=err \ + -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ | tee results_${{ matrix.shard }}.txt @@ -176,7 +178,7 @@ jobs: --elo0 "$ELO0" \ --elo1 "$ELO1" \ --alpha 0.05 \ - --beta 0.05 \ + --beta 0.05 \ --results "$RESULTS" - uses: actions/upload-artifact@v4 From cb4c9c81cdc821efdf611558b95355ab85820148 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 13 Jul 2026 08:15:28 +0700 Subject: [PATCH 19/49] Update games.yml --- .github/workflows/games.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 3f91644..efa7c5b 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -154,6 +154,9 @@ jobs: steps: - uses: actions/download-artifact@v4 + - uses: actions/checkout@v6 + with: + persist-credentials: false - name: Run Ordo run: | @@ -188,4 +191,4 @@ jobs: shard-*/games_*.pgn ratings.txt sprt.txt - results.txt \ No newline at end of file + results.txt From b35fc7892fe7d935a2d1521d763ed1ee43e7b352 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Mon, 13 Jul 2026 22:14:32 +0700 Subject: [PATCH 20/49] tune --- Weights.h | 103 +----- extract_ptnml.py | 234 ++++++------ spsa.py | 908 +++++++++++++++++++++++------------------------ 3 files changed, 588 insertions(+), 657 deletions(-) diff --git a/Weights.h b/Weights.h index 62b181b..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -45,97 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } -}; -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 } -}; +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 } }; +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 } }; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 }, - { 0, 0 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 }, - { 0, 0 } -}; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif diff --git a/extract_ptnml.py b/extract_ptnml.py index fb67ed8..5a7ff0b 100644 --- a/extract_ptnml.py +++ b/extract_ptnml.py @@ -1,118 +1,118 @@ -#!/usr/bin/env python3 - -import argparse -import glob -from collections import defaultdict -from itertools import chain -import chess.pgn - -# [LL, LD/DL, WL/DD/LW, WD/DW, WW] -PTNML_INDEX = {-2: 0, -1: 1, 0: 2, 1: 3, 2: 4} - - -def score_from_new(headers): - result = headers["Result"] - - if result == "1/2-1/2": - return 0 - - new_is_white = headers["White"] == "new" - - if new_is_white: - return 1 if result == "1-0" else -1 - else: - return 1 if result == "0-1" else -1 - - -def main(): - parser = argparse.ArgumentParser( - description="Extract WDL and pentanomial statistics from fastchess PGNs" - ) - parser.add_argument("pgns", nargs="+") - args = parser.parse_args() - - pairs = defaultdict(list) - - # WDL = [loss, draw, win] - wdl = [0, 0, 0] - games = 0 - - for filename in chain.from_iterable(glob.glob(p) for p in args.pgns): - with open(filename, encoding="utf-8") as f: - while (game := chess.pgn.read_game(f)) is not None: - headers = game.headers - - score = score_from_new(headers) - - games += 1 - if score < 0: - wdl[0] += 1 - elif score == 0: - wdl[1] += 1 - else: - wdl[2] += 1 - - fen = headers.get("FEN") - round_id = headers.get("Round") - - if fen is None or round_id is None: - raise RuntimeError( - f"{filename}: missing FEN or Round tag" - ) - - # Include filename because each shard starts rounds again - key = ( - filename, - round_id, - fen, - ) - - pairs[key].append(score) - - ptnml = [0] * 5 - pairs_count = 0 - - for key, scores in pairs.items(): - if len(scores) != 2: - print( - f"Skipping incomplete pair {key}: got {len(scores)} games" - ) - continue - - # Make sure the two games are the repeat pair - if scores[0] + scores[1] not in PTNML_INDEX: - raise RuntimeError("Invalid pair score") - - ptnml[PTNML_INDEX[scores[0] + scores[1]]] += 1 - pairs_count += 1 - - print(f"Games: {games}") - print(f"Pairs: {pairs_count}") - - print() - print("WDL:") - print(f" Loss: {wdl[0]}") - print(f" Draw: {wdl[1]}") - print(f" Win : {wdl[2]}") - print() - print(wdl) - - print() - print("PTNML:") - names = [ - "LL", - "LD", - "WL/DD", - "WD", - "WW", - ] - - for name, count in zip(names, ptnml): - print(f" {name:10}: {count}") - - print() - print(ptnml) - - -if __name__ == "__main__": +#!/usr/bin/env python3 + +import argparse +import glob +from collections import defaultdict +from itertools import chain +import chess.pgn + +# [LL, LD/DL, WL/DD/LW, WD/DW, WW] +PTNML_INDEX = {-2: 0, -1: 1, 0: 2, 1: 3, 2: 4} + + +def score_from_new(headers): + result = headers["Result"] + + if result == "1/2-1/2": + return 0 + + new_is_white = headers["White"] == "new" + + if new_is_white: + return 1 if result == "1-0" else -1 + else: + return 1 if result == "0-1" else -1 + + +def main(): + parser = argparse.ArgumentParser( + description="Extract WDL and pentanomial statistics from fastchess PGNs" + ) + parser.add_argument("pgns", nargs="+") + args = parser.parse_args() + + pairs = defaultdict(list) + + # WDL = [loss, draw, win] + wdl = [0, 0, 0] + games = 0 + + for filename in chain.from_iterable(glob.glob(p) for p in args.pgns): + with open(filename, encoding="utf-8") as f: + while (game := chess.pgn.read_game(f)) is not None: + headers = game.headers + + score = score_from_new(headers) + + games += 1 + if score < 0: + wdl[0] += 1 + elif score == 0: + wdl[1] += 1 + else: + wdl[2] += 1 + + fen = headers.get("FEN") + round_id = headers.get("Round") + + if fen is None or round_id is None: + raise RuntimeError( + f"{filename}: missing FEN or Round tag" + ) + + # Include filename because each shard starts rounds again + key = ( + filename, + round_id, + fen, + ) + + pairs[key].append(score) + + ptnml = [0] * 5 + pairs_count = 0 + + for key, scores in pairs.items(): + if len(scores) != 2: + print( + f"Skipping incomplete pair {key}: got {len(scores)} games" + ) + continue + + # Make sure the two games are the repeat pair + if scores[0] + scores[1] not in PTNML_INDEX: + raise RuntimeError("Invalid pair score") + + ptnml[PTNML_INDEX[scores[0] + scores[1]]] += 1 + pairs_count += 1 + + print(f"Games: {games}") + print(f"Pairs: {pairs_count}") + + print() + print("WDL:") + print(f" Loss: {wdl[0]}") + print(f" Draw: {wdl[1]}") + print(f" Win : {wdl[2]}") + print() + print(wdl) + + print() + print("PTNML:") + names = [ + "LL", + "LD", + "WL/DD", + "WD", + "WW", + ] + + for name, count in zip(names, ptnml): + print(f" {name:10}: {count}") + + print() + print(ptnml) + + +if __name__ == "__main__": main() \ No newline at end of file diff --git a/spsa.py b/spsa.py index 1f296a1..28f9e4c 100644 --- a/spsa.py +++ b/spsa.py @@ -1,454 +1,454 @@ -import argparse -import csv -import random -import subprocess -import os -import json -import logging -import re -import copy -import tempfile -from collections import defaultdict -logger = logging.getLogger("spsa_tuner") -FASTCHESS_TEMPLATE = { - "resign": { - "move_count": 1, - "score": 0, - "twosided": False, - "enabled": False - }, - "draw": { - "move_number": 0, - "move_count": 1, - "score": 0, - "enabled": False - }, - "maxmoves": { - "move_count": 1, - "enabled": False - }, - "tb_adjudication": { - "syzygy_dirs": "", - "max_pieces": 0, - "ignore_50_move_rule": False, - "enabled": False - }, - "opening": { - "file": "UHO_Lichess_4852_v1.epd", - "format": 0, - "order": 0, - "plies": -1, - "start": 1 - }, - "pgn": { - "additional_lines_rgx": [], - "event_name": "Fastchess Tournament", - "site": "?", - "file": "", - "notation": 0, - "append_file": True, - "track_nodes": False, - "track_seldepth": False, - "track_nps": False, - "track_hashfull": False, - "track_tbhits": False, - "track_timeleft": False, - "track_latency": False, - "track_pv": False, - "min": False, - "crc": False - }, - "epd": { - "file": "", - "append_file": True - }, - "sprt": { - "alpha": 0.05, - "beta": 0.05, - "elo0": 0.0, - "elo1": 5.0, - "model": "normalized", - "enabled": True - }, - "config_name": "config.json", - "output": 0, - "variant": 0, - "type": 0, - "gauntlet_seeds": 1, - "seed": 0, - "ratinginterval": 10, - "scoreinterval": 1, - "wait": 0, - "autosaveinterval": 5, - "games": 2, - "rounds": 2000, - "concurrency": 6, - "force_concurrency": False, - "recover": True, - "noswap": False, - "reverse": False, - "report_penta": True, - "affinity": False, - "show_latency": False, - "log": { - "file": "", - "level": 2, - "append_file": True, - "compress": False, - "realtime": True, - "engine_coms": False - }, - "engines": [ - { - "name": "Plus", - "dir": "", - "cmd": "engine", - "args": "", - "restart": False, - "options": [], - "limit": { - "tc": { - "increment": 100, - "fixed_time": 0, - "time": 10000, - "moves": 0, - "timemargin": 0 - }, - "nodes": 0, - "plies": 0 - }, - "variant": 0 - }, - { - "name": "Minus", - "dir": "", - "cmd": "engine", - "args": "", - "restart": False, - "options": [], - "limit": { - "tc": { - "increment": 100, - "fixed_time": 0, - "time": 10000, - "moves": 0, - "timemargin": 0 - }, - "nodes": 0, - "plies": 0 - }, - "variant": 0 - } - ], - "stats": { - "Plus vs Minus": { - "wins": 0, - "losses": 0, - "draws": 0, - "penta_WW": 0, - "penta_WD": 0, - "penta_WL": 0, - "penta_DD": 0, - "penta_LD": 0, - "penta_LL": 0 - } - } -} - -# --- CLI Parser --- -parser = argparse.ArgumentParser(description="a SPSA tuner") -parser.add_argument("--engine", required=True, help="engine") -parser.add_argument("--infile", default="spsa_params.txt", help="inputs") -parser.add_argument("--outfile", default="spsa_params.txt", help="outs") -parser.add_argument("--iters", type=int, default=10, help="iters") -parser.add_argument("--pairs", type=int, default=4, help="pairs (including repeats)") -parser.add_argument("--workers", type=int, default=6, help="concurrency") -parser.add_argument("--stable_offset", type=int, default=3000, help="stability const") -parser.add_argument("--lr", type=float, default=1e-1, help="base lr") -parser.add_argument("--alpha", type=float, default=0.602, help="alpha") -parser.add_argument("--gamma", type=float, default=0.101, help="gamma") -parser.add_argument("--hash", type=str, default="16", help="TT size") - -# --- params --- -def load_params(path, engine_path): - params = {} - if os.path.exists(path): - with open(path) as f: - for row in csv.reader(f): - try: - if not row: - continue - line = row[0].strip() - - if line.startswith("(") and line.endswith(")"): - line = line[1:-1] - if len(row) == 6: - name, val, lo, hi, step, a = row - c = max(2.0 * float(step), 1.0) - elif len(row) == 7: - name, val, lo, hi, step, a, c = row - else: - raise ValueError(f"Bad row: {row}") - params[name] = { - "value": float(val), - "min": float(lo), - "max": float(hi), - "step": float(step), - "a": float(a), - "c": float(c), - } - except Exception as e:print(e, row) - return params - else: - logger.info("%s not found, starting engine to capture parameters", path) - with tempfile.NamedTemporaryFile(mode="r+", delete=False) as tmp: - subprocess.run([engine_path], stdout=tmp, stderr=subprocess.STDOUT, input="quit\n", text=True) - tmp.seek(0) - return load_params(tmp.name, engine_path) - -def save_params(path, params): - with open(path, "w", newline="", encoding="utf-8") as f: - w = csv.writer(f) - for n, p in params.items(): - w.writerow([n, p["value"], p["min"], p["max"], p["step"], p["a"], p["c"]]) - -# --- runner --- -def run_fastchess_match(plus_params, minus_params, args, iteration): - config = copy.deepcopy(FASTCHESS_TEMPLATE) - config["rounds"] = args.pairs - config["concurrency"] = args.workers - config["pgn"]["file"]=f"games{random.randint(0,2**31-1)}.pgn" - config["epd"]["file"]=f"games{random.randint(0,2**31-1)}.epd" - options_plus = [["Hash", str(args.hash)]] - for n, v in plus_params.items(): - options_plus.append([n, str(int(round(v)))]) - - options_minus = [["Hash", str(args.hash)]] - for n, v in minus_params.items(): - options_minus.append([n, str(int(round(v)))]) - - config["engines"][0]["cmd"] = args.engine - config["engines"][0]["options"] = options_plus - - config["engines"][1]["cmd"] = args.engine - config["engines"][1]["options"] = options_minus - - temp_config_path = "config.json" - with open(temp_config_path, "w", encoding="utf-8") as f: - json.dump(config, f, indent=4) - - logger.info(f"--- Iteration {iteration}: {args.pairs} pairs ---") - cmd = ["./fastchess", "-config", f"file={temp_config_path}"] - try: - result = subprocess.run(cmd, capture_output=True, text=True, check=True) - except subprocess.CalledProcessError as e: - print("Return code:", e.returncode) - print("STDOUT:") - print(e.stdout) - print("STDERR:") - print(e.stderr) - with open(temp_config_path, "r", encoding="utf-8") as f: - output_config = json.load(f) - print(json.dumps(output_config["stats"], indent=2)) - stats = output_config.get("stats", {}) - stats_key = "Plus vs Minus" - - if stats_key in stats and "wins" in stats[stats_key]: - w = stats[stats_key]["wins"] - l = stats[stats_key]["losses"] - d = stats[stats_key]["draws"] - else: - w, l, d = 0, 0, 0 - logger.error("HOW IS THAT NOT EXIST") - - total_games = w + l + d - if total_games == 0: - logger.error("as we saw") - logger.debug(result.stdout) - logger.debug(result.stderr) - return 0.5, 0.5 - - f_plus = (w + 0.5 * d) / total_games - f_minus = (l + 0.5 * d) / total_games - - logger.info(f"Plus: WDL=[{w},{d},{l}] total={total_games}") - return f_plus, f_minus - - -INDEX_RE = re.compile(r"\[(\d+)\]") -def regroup_ndim(names, values): - scalars = {} - arrays_raw = defaultdict(dict) - for n, v in zip(names, values): - indices = [int(i) for i in INDEX_RE.findall(n)] - if indices: - base_name = n.split('[')[0].strip() - arrays_raw[base_name][tuple(indices)] = int(round(v)) - else: - scalars[n] = int(round(v)) - return scalars, arrays_raw - -def finalize_ndim_arrays(arrays_raw): - out_arrays = {} - for name, coord_dict in arrays_raw.items(): - sample_coords = list(coord_dict.keys())[0] - ndim = len(sample_coords) - shape = [] - for d in range(ndim): - max_idx = max(coords[d] for coords in coord_dict.keys()) - shape.append(max_idx + 1) - - def create_nested_list(dims): - if len(dims) == 1: - return [0] * dims[0] - return [create_nested_list(dims[1:]) for _ in range(dims[0])] - - nested_arr = create_nested_list(shape) - for coords, val in coord_dict.items(): - current = nested_arr - for i in range(len(coords) - 1): - current = current[coords[i]] - current[coords[-1]] = val - out_arrays[name] = (shape, nested_arr) - return out_arrays - -def format_cpp_array(arr): - if not isinstance(arr, list): - return str(arr) - inner = ", ".join(format_cpp_array(item) for item in arr) - return f"{{ {inner} }}" - -def write_weights_header(names, x): - scalars, arrays_raw = regroup_ndim(names, x) - arrays = finalize_ndim_arrays(arrays_raw) if arrays_raw else {} - lines = [ - "#ifndef WEIGHTS_H", - "#define WEIGHTS_H", - '#include "eval.h"', - "namespace engine::eval {", - ] - for k, v in scalars.items(): - lines.append(f"inline Value {k} = {v};") - for k, (shape, arr) in arrays.items(): - shape_str = "".join(f"[{dim}]" for dim in shape) - cpp_initializer = format_cpp_array(arr) - lines.append(f"inline Value {k}{shape_str} = {cpp_initializer};") - lines.append("} // namespace engine::eval") - lines.append("#endif") - - # Also write to the default location - with open("Weights.h", "w", encoding="utf-8") as f: - f.writelines(l + "\n" for l in lines) -# --- SPSA Core --- -def spsa_core(params, args): - for k in range(args.iters): - logger.info(f"=== iter: {k} ===") - - deltas = {n: (1 if random.random() < 0.5 else -1) for n in params} - ak = {n: p["a"] / (k + args.stable_offset) ** args.alpha for n, p in params.items()} - ck = { - n: p["c"] / (k + 1) ** args.gamma - for n, p in params.items() - } - - while True: - - deltas = { - n: 1 if random.random() < 0.5 else -1 - for n in params - } - - plus = { - n: min( - p["max"], - max( - p["min"], - p["value"] + ck[n] * deltas[n] - ), - ) - for n, p in params.items() - } - - minus = { - n: min( - p["max"], - max( - p["min"], - p["value"] - ck[n] * deltas[n] - ), - ) - for n, p in params.items() - } - - plus_int = { - n: int(round(v)) - for n, v in plus.items() - } - - minus_int = { - n: int(round(v)) - for n, v in minus.items() - } - - if plus_int != minus_int: - break - plus_int = {n: int(round(v)) for n, v in plus.items()} - minus_int = {n: int(round(v)) for n, v in minus.items()} - - if plus_int == minus_int: - continue - f_plus, f_minus = run_fastchess_match(plus, minus, args, k) - - for n, p in params.items(): - score = 2.0 * f_plus - 1.0 - - ghat = score / ( - 2 * ck[n] * deltas[n] - ) - old_val = p["value"] - new_val = old_val + ak[n] * ghat - p["value"] = min(p["max"], max(p["min"], new_val)) - - if int(round(old_val)) != int(round(p["value"])): - logger.info( - "[%s] %.3f -> %.3f | grad=% .4f ak=%.4f ck=%.3f", - n, - old_val, - p["value"], - ghat, - ak[n], - ck[n], - ) - - print(f"iter {k}: score (plus) = {f_plus:.3f}") - save_params(args.outfile, params) - write_weights_header(list(params.keys()), [p["value"] for p in params.values()]) - - return params - -def main(): - logging.basicConfig( - level=logging.DEBUG, - format="%(asctime)s [%(levelname)s] %(message)s", - datefmt="%H:%M:%S" - ) - args = parser.parse_args() - - logger.info("loading params") - params = load_params(args.infile, args.engine) - for name, p in params.items(): - - assert p["min"] <= p["value"] <= p["max"] - - assert p["step"] > 0 - assert p["a"] > 0 - assert p["c"] > 0 - write_weights_header(list(params.keys()), [p["value"] for p in params.values()]) - logger.info(f"got {len(params)} params.") - - tuned_params = spsa_core(params, args) - save_params(args.outfile, tuned_params) - logger.info("FINISHED. now run a SPRT.") - -if __name__ == "__main__": - main() +import argparse +import csv +import random +import subprocess +import os +import json +import logging +import re +import copy +import tempfile +from collections import defaultdict +logger = logging.getLogger("spsa_tuner") +FASTCHESS_TEMPLATE = { + "resign": { + "move_count": 1, + "score": 0, + "twosided": False, + "enabled": False + }, + "draw": { + "move_number": 0, + "move_count": 1, + "score": 0, + "enabled": False + }, + "maxmoves": { + "move_count": 1, + "enabled": False + }, + "tb_adjudication": { + "syzygy_dirs": "", + "max_pieces": 0, + "ignore_50_move_rule": False, + "enabled": False + }, + "opening": { + "file": "UHO_Lichess_4852_v1.epd", + "format": 0, + "order": 0, + "plies": -1, + "start": 1 + }, + "pgn": { + "additional_lines_rgx": [], + "event_name": "Fastchess Tournament", + "site": "?", + "file": "", + "notation": 0, + "append_file": True, + "track_nodes": False, + "track_seldepth": False, + "track_nps": False, + "track_hashfull": False, + "track_tbhits": False, + "track_timeleft": False, + "track_latency": False, + "track_pv": False, + "min": False, + "crc": False + }, + "epd": { + "file": "", + "append_file": True + }, + "sprt": { + "alpha": 0.05, + "beta": 0.05, + "elo0": 0.0, + "elo1": 5.0, + "model": "normalized", + "enabled": True + }, + "config_name": "config.json", + "output": 0, + "variant": 0, + "type": 0, + "gauntlet_seeds": 1, + "seed": 0, + "ratinginterval": 10, + "scoreinterval": 1, + "wait": 0, + "autosaveinterval": 5, + "games": 2, + "rounds": 2000, + "concurrency": 6, + "force_concurrency": False, + "recover": True, + "noswap": False, + "reverse": False, + "report_penta": True, + "affinity": False, + "show_latency": False, + "log": { + "file": "", + "level": 2, + "append_file": True, + "compress": False, + "realtime": True, + "engine_coms": False + }, + "engines": [ + { + "name": "Plus", + "dir": "", + "cmd": "engine", + "args": "", + "restart": False, + "options": [], + "limit": { + "tc": { + "increment": 100, + "fixed_time": 0, + "time": 10000, + "moves": 0, + "timemargin": 0 + }, + "nodes": 0, + "plies": 0 + }, + "variant": 0 + }, + { + "name": "Minus", + "dir": "", + "cmd": "engine", + "args": "", + "restart": False, + "options": [], + "limit": { + "tc": { + "increment": 100, + "fixed_time": 0, + "time": 10000, + "moves": 0, + "timemargin": 0 + }, + "nodes": 0, + "plies": 0 + }, + "variant": 0 + } + ], + "stats": { + "Plus vs Minus": { + "wins": 0, + "losses": 0, + "draws": 0, + "penta_WW": 0, + "penta_WD": 0, + "penta_WL": 0, + "penta_DD": 0, + "penta_LD": 0, + "penta_LL": 0 + } + } +} + +# --- CLI Parser --- +parser = argparse.ArgumentParser(description="a SPSA tuner") +parser.add_argument("--engine", required=True, help="engine") +parser.add_argument("--infile", default="spsa_params.txt", help="inputs") +parser.add_argument("--outfile", default="spsa_params.txt", help="outs") +parser.add_argument("--iters", type=int, default=10, help="iters") +parser.add_argument("--pairs", type=int, default=4, help="pairs (including repeats)") +parser.add_argument("--workers", type=int, default=6, help="concurrency") +parser.add_argument("--stable_offset", type=int, default=3000, help="stability const") +parser.add_argument("--lr", type=float, default=1e-1, help="base lr") +parser.add_argument("--alpha", type=float, default=0.602, help="alpha") +parser.add_argument("--gamma", type=float, default=0.101, help="gamma") +parser.add_argument("--hash", type=str, default="16", help="TT size") + +# --- params --- +def load_params(path, engine_path): + params = {} + if os.path.exists(path): + with open(path) as f: + for row in csv.reader(f): + try: + if not row: + continue + line = row[0].strip() + + if line.startswith("(") and line.endswith(")"): + line = line[1:-1] + if len(row) == 6: + name, val, lo, hi, step, a = row + c = max(2.0 * float(step), 1.0) + elif len(row) == 7: + name, val, lo, hi, step, a, c = row + else: + raise ValueError(f"Bad row: {row}") + params[name] = { + "value": float(val), + "min": float(lo), + "max": float(hi), + "step": float(step), + "a": float(a), + "c": float(c), + } + except Exception as e:print(e, row) + return params + else: + logger.info("%s not found, starting engine to capture parameters", path) + with tempfile.NamedTemporaryFile(mode="r+", delete=False) as tmp: + subprocess.run([engine_path], stdout=tmp, stderr=subprocess.STDOUT, input="quit\n", text=True) + tmp.seek(0) + return load_params(tmp.name, engine_path) + +def save_params(path, params): + with open(path, "w", newline="", encoding="utf-8") as f: + w = csv.writer(f) + for n, p in params.items(): + w.writerow([n, p["value"], p["min"], p["max"], p["step"], p["a"], p["c"]]) + +# --- runner --- +def run_fastchess_match(plus_params, minus_params, args, iteration): + config = copy.deepcopy(FASTCHESS_TEMPLATE) + config["rounds"] = args.pairs + config["concurrency"] = args.workers + config["pgn"]["file"]=f"games{random.randint(0,2**31-1)}.pgn" + config["epd"]["file"]=f"games{random.randint(0,2**31-1)}.epd" + options_plus = [["Hash", str(args.hash)]] + for n, v in plus_params.items(): + options_plus.append([n, str(int(round(v)))]) + + options_minus = [["Hash", str(args.hash)]] + for n, v in minus_params.items(): + options_minus.append([n, str(int(round(v)))]) + + config["engines"][0]["cmd"] = args.engine + config["engines"][0]["options"] = options_plus + + config["engines"][1]["cmd"] = args.engine + config["engines"][1]["options"] = options_minus + + temp_config_path = "config.json" + with open(temp_config_path, "w", encoding="utf-8") as f: + json.dump(config, f, indent=4) + + logger.info(f"--- Iteration {iteration}: {args.pairs} pairs ---") + cmd = ["./fastchess", "-config", f"file={temp_config_path}"] + try: + result = subprocess.run(cmd, capture_output=True, text=True, check=True) + except subprocess.CalledProcessError as e: + print("Return code:", e.returncode) + print("STDOUT:") + print(e.stdout) + print("STDERR:") + print(e.stderr) + with open(temp_config_path, "r", encoding="utf-8") as f: + output_config = json.load(f) + print(json.dumps(output_config["stats"], indent=2)) + stats = output_config.get("stats", {}) + stats_key = "Plus vs Minus" + + if stats_key in stats and "wins" in stats[stats_key]: + w = stats[stats_key]["wins"] + l = stats[stats_key]["losses"] + d = stats[stats_key]["draws"] + else: + w, l, d = 0, 0, 0 + logger.error("HOW IS THAT NOT EXIST") + + total_games = w + l + d + if total_games == 0: + logger.error("as we saw") + logger.debug(result.stdout) + logger.debug(result.stderr) + return 0.5, 0.5 + + f_plus = (w + 0.5 * d) / total_games + f_minus = (l + 0.5 * d) / total_games + + logger.info(f"Plus: WDL=[{w},{d},{l}] total={total_games}") + return f_plus, f_minus + + +INDEX_RE = re.compile(r"\[(\d+)\]") +def regroup_ndim(names, values): + scalars = {} + arrays_raw = defaultdict(dict) + for n, v in zip(names, values): + indices = [int(i) for i in INDEX_RE.findall(n)] + if indices: + base_name = n.split('[')[0].strip() + arrays_raw[base_name][tuple(indices)] = int(round(v)) + else: + scalars[n] = int(round(v)) + return scalars, arrays_raw + +def finalize_ndim_arrays(arrays_raw): + out_arrays = {} + for name, coord_dict in arrays_raw.items(): + sample_coords = list(coord_dict.keys())[0] + ndim = len(sample_coords) + shape = [] + for d in range(ndim): + max_idx = max(coords[d] for coords in coord_dict.keys()) + shape.append(max_idx + 1) + + def create_nested_list(dims): + if len(dims) == 1: + return [0] * dims[0] + return [create_nested_list(dims[1:]) for _ in range(dims[0])] + + nested_arr = create_nested_list(shape) + for coords, val in coord_dict.items(): + current = nested_arr + for i in range(len(coords) - 1): + current = current[coords[i]] + current[coords[-1]] = val + out_arrays[name] = (shape, nested_arr) + return out_arrays + +def format_cpp_array(arr): + if not isinstance(arr, list): + return str(arr) + inner = ", ".join(format_cpp_array(item) for item in arr) + return f"{{ {inner} }}" + +def write_weights_header(names, x): + scalars, arrays_raw = regroup_ndim(names, x) + arrays = finalize_ndim_arrays(arrays_raw) if arrays_raw else {} + lines = [ + "#ifndef WEIGHTS_H", + "#define WEIGHTS_H", + '#include "eval.h"', + "namespace engine::eval {", + ] + for k, v in scalars.items(): + lines.append(f"inline Value {k} = {v};") + for k, (shape, arr) in arrays.items(): + shape_str = "".join(f"[{dim}]" for dim in shape) + cpp_initializer = format_cpp_array(arr) + lines.append(f"inline Value {k}{shape_str} = {cpp_initializer};") + lines.append("} // namespace engine::eval") + lines.append("#endif") + + # Also write to the default location + with open("Weights.h", "w", encoding="utf-8") as f: + f.writelines(l + "\n" for l in lines) +# --- SPSA Core --- +def spsa_core(params, args): + for k in range(args.iters): + logger.info(f"=== iter: {k} ===") + + deltas = {n: (1 if random.random() < 0.5 else -1) for n in params} + ak = {n: p["a"] / (k + args.stable_offset) ** args.alpha for n, p in params.items()} + ck = { + n: p["c"] / (k + 1) ** args.gamma + for n, p in params.items() + } + + while True: + + deltas = { + n: 1 if random.random() < 0.5 else -1 + for n in params + } + + plus = { + n: min( + p["max"], + max( + p["min"], + p["value"] + ck[n] * deltas[n] + ), + ) + for n, p in params.items() + } + + minus = { + n: min( + p["max"], + max( + p["min"], + p["value"] - ck[n] * deltas[n] + ), + ) + for n, p in params.items() + } + + plus_int = { + n: int(round(v)) + for n, v in plus.items() + } + + minus_int = { + n: int(round(v)) + for n, v in minus.items() + } + + if plus_int != minus_int: + break + plus_int = {n: int(round(v)) for n, v in plus.items()} + minus_int = {n: int(round(v)) for n, v in minus.items()} + + if plus_int == minus_int: + continue + f_plus, f_minus = run_fastchess_match(plus, minus, args, k) + + for n, p in params.items(): + score = 2.0 * f_plus - 1.0 + + ghat = score / ( + 2 * ck[n] * deltas[n] + ) + old_val = p["value"] + new_val = old_val + ak[n] * ghat + p["value"] = min(p["max"], max(p["min"], new_val)) + + if int(round(old_val)) != int(round(p["value"])): + logger.info( + "[%s] %.3f -> %.3f | grad=% .4f ak=%.4f ck=%.3f", + n, + old_val, + p["value"], + ghat, + ak[n], + ck[n], + ) + + print(f"iter {k}: score (plus) = {f_plus:.3f}") + save_params(args.outfile, params) + write_weights_header(list(params.keys()), [p["value"] for p in params.values()]) + + return params + +def main(): + logging.basicConfig( + level=logging.DEBUG, + format="%(asctime)s [%(levelname)s] %(message)s", + datefmt="%H:%M:%S" + ) + args = parser.parse_args() + + logger.info("loading params") + params = load_params(args.infile, args.engine) + for name, p in params.items(): + + assert p["min"] <= p["value"] <= p["max"] + + assert p["step"] > 0 + assert p["a"] > 0 + assert p["c"] > 0 + write_weights_header(list(params.keys()), [p["value"] for p in params.values()]) + logger.info(f"got {len(params)} params.") + + tuned_params = spsa_core(params, args) + save_params(args.outfile, tuned_params) + logger.info("FINISHED. now run a SPRT.") + +if __name__ == "__main__": + main() From 14ffaa5af5f236d5ea315859e8e5a1aa6c3efd0b Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 13 Jul 2026 15:14:56 +0000 Subject: [PATCH 21/49] Apply clang-format --- Weights.h | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/Weights.h b/Weights.h index 7caf065..62b181b 100644 --- a/Weights.h +++ b/Weights.h @@ -45,28 +45,97 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; +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 } +}; +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 } +}; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 }, + { 0, 0 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 }, + { 0, 0 } +}; } // namespace engine::eval #endif From 680f08dac81ce9fc8d2087490fc94ab191ee2761 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 14 Jul 2026 11:16:54 +0700 Subject: [PATCH 22/49] tune --- .github/workflows/spsa.yml | 2 +- spsa.py | 62 +++++++++----------------------------- tune.cpp | 4 +-- 3 files changed, 18 insertions(+), 50 deletions(-) diff --git a/.github/workflows/spsa.yml b/.github/workflows/spsa.yml index 2c7d10f..537d65f 100644 --- a/.github/workflows/spsa.yml +++ b/.github/workflows/spsa.yml @@ -40,7 +40,7 @@ jobs: cmake --build . -j$(nproc) - name: Tune engine run: | - python spsa.py --iters 160 --pairs 30 --engine build/engine --workers $(nproc) + python spsa.py --iters 160 --pairs 30 --engine build/engine --workers $(nproc) --stable_offset 2000 - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/spsa.py b/spsa.py index 28f9e4c..58382aa 100644 --- a/spsa.py +++ b/spsa.py @@ -164,7 +164,6 @@ parser.add_argument("--pairs", type=int, default=4, help="pairs (including repeats)") parser.add_argument("--workers", type=int, default=6, help="concurrency") parser.add_argument("--stable_offset", type=int, default=3000, help="stability const") -parser.add_argument("--lr", type=float, default=1e-1, help="base lr") parser.add_argument("--alpha", type=float, default=0.602, help="alpha") parser.add_argument("--gamma", type=float, default=0.101, help="gamma") parser.add_argument("--hash", type=str, default="16", help="TT size") @@ -182,6 +181,7 @@ def load_params(path, engine_path): if line.startswith("(") and line.endswith(")"): line = line[1:-1] + row[0]=line if len(row) == 6: name, val, lo, hi, step, a = row c = max(2.0 * float(step), 1.0) @@ -247,11 +247,13 @@ def run_fastchess_match(plus_params, minus_params, args, iteration): print(e.stdout) print("STDERR:") print(e.stderr) - with open(temp_config_path, "r", encoding="utf-8") as f: - output_config = json.load(f) - print(json.dumps(output_config["stats"], indent=2)) + try: + with open(temp_config_path, "r", encoding="utf-8") as f: + output_config = json.load(f) + except Exception: + logger.error("Could not read fastchess output config.") + return 0.5, 0.5 stats = output_config.get("stats", {}) - stats_key = "Plus vs Minus" if stats_key in stats and "wins" in stats[stats_key]: w = stats[stats_key]["wins"] @@ -346,50 +348,16 @@ def spsa_core(params, args): deltas = {n: (1 if random.random() < 0.5 else -1) for n in params} ak = {n: p["a"] / (k + args.stable_offset) ** args.alpha for n, p in params.items()} - ck = { - n: p["c"] / (k + 1) ** args.gamma - for n, p in params.items() - } + ck = {n: p["c"] / (k + 1) ** args.gamma for n, p in params.items()} while True: - - deltas = { - n: 1 if random.random() < 0.5 else -1 - for n in params - } - - plus = { - n: min( - p["max"], - max( - p["min"], - p["value"] + ck[n] * deltas[n] - ), - ) - for n, p in params.items() - } - - minus = { - n: min( - p["max"], - max( - p["min"], - p["value"] - ck[n] * deltas[n] - ), - ) - for n, p in params.items() - } - - plus_int = { - n: int(round(v)) - for n, v in plus.items() - } - - minus_int = { - n: int(round(v)) - for n, v in minus.items() - } - + deltas = {n: 1 if random.random() < 0.5 else -1 for n in params} + plus = {n: min(p["max"], max(p["min"], p["value"] + ck[n] * deltas[n])) + for n, p in params.items()} + minus = {n: min(p["max"], max(p["min"], p["value"] - ck[n] * deltas[n])) + for n, p in params.items()} + plus_int = {n: int(round(v)) for n, v in plus.items()} + minus_int = {n: int(round(v)) for n, v in minus.items()} if plus_int != minus_int: break plus_int = {n: int(round(v)) for n, v in plus.items()} diff --git a/tune.cpp b/tune.cpp index c118521..5d38acf 100644 --- a/tune.cpp +++ b/tune.cpp @@ -76,8 +76,8 @@ void Tune::make_option(OptionsMap *opts, const string &n, int v, const SetRange << v << "," // << a << "," // << b << "," // - << (b - a) / 20.0 << "," // - << "0.0020" << '\n'; + << (b - a) / 10.0 << "," // + << 0.2 << '\n'; } string Tune::next(string &names, bool pop) { From f7d5feda04458d24780dd8585d9c9188fd0b7c55 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 14 Jul 2026 12:45:08 +0700 Subject: [PATCH 23/49] tune --- .github/workflows/spsa.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/spsa.yml b/.github/workflows/spsa.yml index 537d65f..447f20b 100644 --- a/.github/workflows/spsa.yml +++ b/.github/workflows/spsa.yml @@ -3,10 +3,6 @@ name: run SPSA (see gist) on: workflow_dispatch: inputs: - base_ref: - description: "Tune branch" - required: false - default: "HandcraftedEngine" output_exec: description: "Executable output file name" required: false @@ -18,7 +14,6 @@ jobs: steps: - uses: actions/checkout@v6 with: - ref: ${{ github.event.inputs.base_ref }} persist-credentials: false - uses: actions/setup-python@v6 From d607487808a25a3b137318a642f22765da170bac Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 14 Jul 2026 12:55:56 +0700 Subject: [PATCH 24/49] tune --- .github/workflows/spsa.yml | 5 ----- Weights.h | 30 ++++++++++++++---------------- eval.cpp | 14 +++++++------- spsa.py | 2 +- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/spsa.yml b/.github/workflows/spsa.yml index 447f20b..ddadd9e 100644 --- a/.github/workflows/spsa.yml +++ b/.github/workflows/spsa.yml @@ -2,11 +2,6 @@ name: run SPSA (see gist) on: workflow_dispatch: - inputs: - output_exec: - description: "Executable output file name" - required: false - default: "engine" jobs: worker: runs-on: ubuntu-latest diff --git a/Weights.h b/Weights.h index 62b181b..b20dd65 100644 --- a/Weights.h +++ b/Weights.h @@ -16,8 +16,6 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; -inline Value developedMg = 8; -inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -35,16 +33,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -inline Value hangingScore = 70; -inline Value overloadScore = 25; -inline Value threatByRankScore = 10; -inline Value minorImWt = 30; -inline Value bishopImWt = 15; -inline Value rookImWt = 20; -inline Value queenImWt = 50; -inline Value rammedPawnPenalty = 10; -inline Value rookOnSeventhBonus = 30; -inline Value earlyQueenPenalty = 5; inline Value mgMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 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, 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 }; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; inline Value kingProtector[6][2] = { @@ -125,8 +115,7 @@ inline Value threatByMinor[7][2] = { { 15, 25 }, { 15, 25 }, { 25, 35 }, - { 35, 50 }, - { 0, 0 } + { 35, 50 } }; inline Value threatByRook[7][2] = { { 0, 0 }, @@ -134,8 +123,17 @@ inline Value threatByRook[7][2] = { { 10, 15 }, { 10, 15 }, { 20, 25 }, - { 25, 35 }, - { 0, 0 } + { 25, 35 } }; +inline Value hangingScore = 70; +inline Value overloadScore = 25; +inline Value threatByRankScore = 10; +inline Value minorImWt = 30; +inline Value bishopImWt = 15; +inline Value rookImWt = 20; +inline Value queenImWt = 50; +inline Value rammedPawnPenalty = 10; +inline Value rookOnSeventhBonus = 30; +inline Value earlyQueenPenalty = 5; } // namespace engine::eval #endif diff --git a/eval.cpp b/eval.cpp index ca6517d..02d6327 100644 --- a/eval.cpp +++ b/eval.cpp @@ -238,7 +238,7 @@ EvalComponents eval_components(const chess::Position &board) { // Precompute pawn attacks (needed for outpost, threats, etc.) Bitboard pawnBB[2] = { board.pieces(PAWN, WHITE), board.pieces(PAWN, BLACK) }; Bitboard pawnAtks[2] = { attacks::pawn(pawnBB[WHITE]), attacks::pawn(pawnBB[BLACK]) }; -#if 0 +#if 1 // Development bonus: penalize undeveloped knights/bishops in middlegame int devCount[2] = { 0, 0 }; for (Color c : { WHITE, BLACK }) { @@ -250,7 +250,7 @@ EvalComponents eval_components(const chess::Position &board) { devCount[c] = popcount(knightsHome) + popcount(bishopsHome); } mgScore += (devCount[BLACK] - devCount[WHITE]) * developedMg; - egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg; + //egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg; // Early queen development penalty: queen moved but minors still on back rank for (Color c : { WHITE, BLACK }) { @@ -312,7 +312,7 @@ EvalComponents eval_components(const chess::Position &board) { mgScore += _sign * (7 - kd) * kingTropismMg[pt]; egScore += _sign * (7 - kd) * kingTropismEg[pt]; } -#if 0 +#if 1 // King protector: bonus for pieces close to own king if (pt != PAWN && pt != KING) { int kdist = square_distance(sq, board.kingSq(pc)); @@ -361,7 +361,7 @@ EvalComponents eval_components(const chess::Position &board) { } } } -#if 0 +#if 1 // Trapped bishop penalty for (Color c : { WHITE, BLACK }) { int s = (c == WHITE) ? 1 : -1; @@ -394,7 +394,7 @@ EvalComponents eval_components(const chess::Position &board) { } } } -#if 0 +#if 1 // Rook on seventh rank bonus (endgame, x-raying >=2 undefended pawns) for (Color c : { WHITE, BLACK }) { int s = (c == WHITE) ? 1 : -1; @@ -463,7 +463,7 @@ EvalComponents eval_components(const chess::Position &board) { } } } -#if 0 +#if 1 // Pawn rams: blocked pawn penalty for (Color c : { WHITE, BLACK }) { int s = (c == WHITE) ? 1 : -1; @@ -606,7 +606,7 @@ EvalComponents eval_components(const chess::Position &board) { } // --- Threat evaluation --- -#if 0 +#if 1 for (Color c : { WHITE, BLACK }) { int s = (c == WHITE) ? 1 : -1; Color opp = ~c; diff --git a/spsa.py b/spsa.py index 58382aa..8f7325c 100644 --- a/spsa.py +++ b/spsa.py @@ -255,7 +255,7 @@ def run_fastchess_match(plus_params, minus_params, args, iteration): return 0.5, 0.5 stats = output_config.get("stats", {}) - if stats_key in stats and "wins" in stats[stats_key]: + if "Plus vs Minus" in stats and "wins" in stats["Plus vs Minus"]: w = stats[stats_key]["wins"] l = stats[stats_key]["losses"] d = stats[stats_key]["draws"] From 6b8dfd67ba2b9af9a8e5f6f490bd124e1f58f1b4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 14 Jul 2026 05:56:12 +0000 Subject: [PATCH 25/49] Apply clang-format --- eval.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eval.cpp b/eval.cpp index 02d6327..2ef14de 100644 --- a/eval.cpp +++ b/eval.cpp @@ -250,7 +250,7 @@ EvalComponents eval_components(const chess::Position &board) { devCount[c] = popcount(knightsHome) + popcount(bishopsHome); } mgScore += (devCount[BLACK] - devCount[WHITE]) * developedMg; - //egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg; + // egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg; // Early queen development penalty: queen moved but minors still on back rank for (Color c : { WHITE, BLACK }) { @@ -261,8 +261,8 @@ EvalComponents eval_components(const chess::Position &board) { int undeveloped = popcount((board.pieces(KNIGHT, c) | board.pieces(BISHOP, c)) & backRank); if (undeveloped >= 2) { mgScore -= s * earlyQueenPenalty; - //disabled intentionally in endgames - //egScore -= s * earlyQueenPenalty; + // disabled intentionally in endgames + // egScore -= s * earlyQueenPenalty; } } } From ccbc9f1f65b44c08d543e0a54b57bad7076e2be4 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 14 Jul 2026 13:34:01 +0700 Subject: [PATCH 26/49] tune --- .github/workflows/games.yml | 3 +-- spsa.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index efa7c5b..f3655fe 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -152,11 +152,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4 - - uses: actions/checkout@v6 with: persist-credentials: false + - uses: actions/download-artifact@v4 - name: Run Ordo run: | diff --git a/spsa.py b/spsa.py index 8f7325c..06ee2f2 100644 --- a/spsa.py +++ b/spsa.py @@ -254,8 +254,8 @@ def run_fastchess_match(plus_params, minus_params, args, iteration): logger.error("Could not read fastchess output config.") return 0.5, 0.5 stats = output_config.get("stats", {}) - - if "Plus vs Minus" in stats and "wins" in stats["Plus vs Minus"]: + stats_key="Plus vs Minus" + if stats_key in stats and "wins" in stats[stats_key]: w = stats[stats_key]["wins"] l = stats[stats_key]["losses"] d = stats[stats_key]["draws"] From 7492d7b7fc3a761f5a0d4ff3ea275fde8770322d Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Tue, 14 Jul 2026 22:48:56 +0700 Subject: [PATCH 27/49] Update spsa.yml --- .github/workflows/spsa.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spsa.yml b/.github/workflows/spsa.yml index ddadd9e..fe27de6 100644 --- a/.github/workflows/spsa.yml +++ b/.github/workflows/spsa.yml @@ -30,7 +30,7 @@ jobs: cmake --build . -j$(nproc) - name: Tune engine run: | - python spsa.py --iters 160 --pairs 30 --engine build/engine --workers $(nproc) --stable_offset 2000 + python spsa.py --iters 40 --pairs 30 --engine build/engine --workers $(nproc) - name: Upload artifacts uses: actions/upload-artifact@v4 with: From e1fe5fdc37bba31f3668a38eb41de8d603c0fd4b Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Wed, 15 Jul 2026 08:01:45 +0700 Subject: [PATCH 28/49] tune --- Weights.h | 117 ++++++++++++------------------------------------------ 1 file changed, 25 insertions(+), 92 deletions(-) diff --git a/Weights.h b/Weights.h index b20dd65..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -16,6 +16,8 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -33,98 +35,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -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 } -}; -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 } -}; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value developedMg = 8; -inline Value developedEg = 4; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 } -}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -135,5 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; +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 } }; +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 } }; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif From 4ea5a29b8dccb47eaefd2cfcd3c34742b9cf15e3 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Jul 2026 01:02:06 +0000 Subject: [PATCH 29/49] Apply clang-format --- Weights.h | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/Weights.h b/Weights.h index 7caf065..62b181b 100644 --- a/Weights.h +++ b/Weights.h @@ -45,28 +45,97 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; +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 } +}; +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 } +}; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 }, + { 0, 0 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 }, + { 0, 0 } +}; } // namespace engine::eval #endif From b1f0b827b38bc90819ae095fad86ba57b7cf876b Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Wed, 15 Jul 2026 13:50:26 +0700 Subject: [PATCH 30/49] Update extract_ptnml.py --- extract_ptnml.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extract_ptnml.py b/extract_ptnml.py index 5a7ff0b..ca7e054 100644 --- a/extract_ptnml.py +++ b/extract_ptnml.py @@ -112,7 +112,7 @@ def main(): print() print(ptnml) - + print(" ".join([str(w) for w in ptnml])) if __name__ == "__main__": - main() \ No newline at end of file + main() From e31fdf3f041bd244c1c11ac7a4ebfb3164babc99 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Wed, 15 Jul 2026 13:51:47 +0700 Subject: [PATCH 31/49] Update Weights.h --- Weights.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Weights.h b/Weights.h index 62b181b..b20dd65 100644 --- a/Weights.h +++ b/Weights.h @@ -16,8 +16,6 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; -inline Value developedMg = 8; -inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -35,16 +33,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -inline Value hangingScore = 70; -inline Value overloadScore = 25; -inline Value threatByRankScore = 10; -inline Value minorImWt = 30; -inline Value bishopImWt = 15; -inline Value rookImWt = 20; -inline Value queenImWt = 50; -inline Value rammedPawnPenalty = 10; -inline Value rookOnSeventhBonus = 30; -inline Value earlyQueenPenalty = 5; inline Value mgMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 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, 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 }; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; inline Value kingProtector[6][2] = { @@ -125,8 +115,7 @@ inline Value threatByMinor[7][2] = { { 15, 25 }, { 15, 25 }, { 25, 35 }, - { 35, 50 }, - { 0, 0 } + { 35, 50 } }; inline Value threatByRook[7][2] = { { 0, 0 }, @@ -134,8 +123,17 @@ inline Value threatByRook[7][2] = { { 10, 15 }, { 10, 15 }, { 20, 25 }, - { 25, 35 }, - { 0, 0 } + { 25, 35 } }; +inline Value hangingScore = 70; +inline Value overloadScore = 25; +inline Value threatByRankScore = 10; +inline Value minorImWt = 30; +inline Value bishopImWt = 15; +inline Value rookImWt = 20; +inline Value queenImWt = 50; +inline Value rammedPawnPenalty = 10; +inline Value rookOnSeventhBonus = 30; +inline Value earlyQueenPenalty = 5; } // namespace engine::eval #endif From 62b72febe22e014849174ddbdffe8836707b739d Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Wed, 15 Jul 2026 22:15:07 +0700 Subject: [PATCH 32/49] tune --- Weights.h | 117 ++++++++++++------------------------------------------ 1 file changed, 25 insertions(+), 92 deletions(-) diff --git a/Weights.h b/Weights.h index b20dd65..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -16,6 +16,8 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -33,98 +35,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -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 } -}; -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 } -}; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value developedMg = 8; -inline Value developedEg = 4; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 } -}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -135,5 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; +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 } }; +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 } }; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif From 091928daac77612f4f321d35f447551fd6bd851a Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 15 Jul 2026 15:15:43 +0000 Subject: [PATCH 33/49] Apply clang-format --- Weights.h | 103 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 17 deletions(-) diff --git a/Weights.h b/Weights.h index 7caf065..62b181b 100644 --- a/Weights.h +++ b/Weights.h @@ -45,28 +45,97 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; +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 } +}; +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 } +}; inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 }, + { 0, 0 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 }, + { 0, 0 } +}; } // namespace engine::eval #endif From cc2cd40b232d3a4adb0f0e9d631155ab60982587 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 16 Jul 2026 08:14:26 +0700 Subject: [PATCH 34/49] Update games.yml --- .github/workflows/games.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index f3655fe..f9fe2af 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -181,7 +181,7 @@ jobs: --elo1 "$ELO1" \ --alpha 0.05 \ --beta 0.05 \ - --results "$RESULTS" + --results $RESULTS - uses: actions/upload-artifact@v4 with: From 3104f3812ae0420ebd69aff06a25a3f856e2282d Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Thu, 16 Jul 2026 12:07:29 +0700 Subject: [PATCH 35/49] tune --- .github/workflows/games.yml | 4 ++-- Weights.h | 32 +++++++++++++++----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index f9fe2af..26f4d74 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -112,7 +112,7 @@ jobs: strategy: fail-fast: false matrix: - shard: [0, 1, 2, 3] + shard: [0, 1, 2, 3,4,5,6,7] runs-on: ubuntu-latest @@ -134,7 +134,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000\ - -rounds 1500 -repeat -log level=err \ + -rounds 375 -repeat -log level=err \ -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ diff --git a/Weights.h b/Weights.h index 62b181b..3d4706f 100644 --- a/Weights.h +++ b/Weights.h @@ -16,8 +16,6 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; -inline Value developedMg = 8; -inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -35,16 +33,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -inline Value hangingScore = 70; -inline Value overloadScore = 25; -inline Value threatByRankScore = 10; -inline Value minorImWt = 30; -inline Value bishopImWt = 15; -inline Value rookImWt = 20; -inline Value queenImWt = 50; -inline Value rammedPawnPenalty = 10; -inline Value rookOnSeventhBonus = 30; -inline Value earlyQueenPenalty = 5; inline Value mgMobilityCnt[7][8] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 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, 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 }; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; inline Value kingProtector[6][2] = { @@ -125,8 +115,7 @@ inline Value threatByMinor[7][2] = { { 15, 25 }, { 15, 25 }, { 25, 35 }, - { 35, 50 }, - { 0, 0 } + { 35, 50 } }; inline Value threatByRook[7][2] = { { 0, 0 }, @@ -134,8 +123,17 @@ inline Value threatByRook[7][2] = { { 10, 15 }, { 10, 15 }, { 20, 25 }, - { 25, 35 }, - { 0, 0 } + { 25, 35 } }; +inline Value hangingScore = 70; +inline Value overloadScore = 25; +inline Value threatByRankScore = 10; +inline Value minorImWt = 30; +inline Value bishopImWt = 15; +inline Value rookImWt = 20; +inline Value queenImWt = 50; +inline Value rammedPawnPenalty = 10; +inline Value rookOnSeventhBonus = 30; +inline Value earlyQueenPenalty = 5; } // namespace engine::eval -#endif +#endif \ No newline at end of file From 747d7139f882eff3d950639ff91a760b8727b81a Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Fri, 17 Jul 2026 08:00:11 +0700 Subject: [PATCH 36/49] tune --- Weights.h | 119 ++++++++++++------------------------------------------ 1 file changed, 26 insertions(+), 93 deletions(-) diff --git a/Weights.h b/Weights.h index 3d4706f..7caf065 100644 --- a/Weights.h +++ b/Weights.h @@ -16,6 +16,8 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; +inline Value developedMg = 8; +inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -33,98 +35,6 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; -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 } -}; -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 } -}; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value developedMg = 8; -inline Value developedEg = 4; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { - { 0, 0 }, - { 8, 12 }, - { 5, 10 }, - { 10, 15 }, - { 3, 5 }, - { 0, 0 } -}; -inline Value threatByMinor[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 15, 25 }, - { 15, 25 }, - { 25, 35 }, - { 35, 50 } -}; -inline Value threatByRook[7][2] = { - { 0, 0 }, - { 0, 0 }, - { 10, 15 }, - { 10, 15 }, - { 20, 25 }, - { 25, 35 } -}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -135,5 +45,28 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; +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 } }; +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 } }; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; +inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; +inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval -#endif \ No newline at end of file +#endif From f58a033db2cf5c2e633aa6441e4ce60f272973cb Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Fri, 17 Jul 2026 09:37:42 +0700 Subject: [PATCH 37/49] tune --- .github/workflows/games.yml | 3 +- Weights.h | 134 +++++++++++++++++++++++++++--------- eval.cpp | 71 ++++++++++++++----- eval.h | 3 +- movepick.cpp | 10 +-- search.cpp | 2 +- tune_cmd.cpp | 43 ++++++++---- 7 files changed, 194 insertions(+), 72 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 26f4d74..86fa4ed 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -181,13 +181,12 @@ jobs: --elo1 "$ELO1" \ --alpha 0.05 \ --beta 0.05 \ - --results $RESULTS + --results $RESULTS | tee -a results.txt - uses: actions/upload-artifact@v4 with: name: results path: | - shard-*/games_*.pgn ratings.txt sprt.txt results.txt diff --git a/Weights.h b/Weights.h index 7caf065..ef917e9 100644 --- a/Weights.h +++ b/Weights.h @@ -2,12 +2,17 @@ #define WEIGHTS_H #include "eval.h" namespace engine::eval { -inline Value tempo = 20; -inline Value PawnValue = 100; -inline Value KnightValue = 320; -inline Value BishopValue = 330; -inline Value RookValue = 500; -inline Value QueenValue = 900; +inline Value tempo = 28; +inline Value PawnValueMG = 124; +inline Value KnightValueMG = 781; +inline Value BishopValueMG = 825; +inline Value RookValueMG = 1276; +inline Value QueenValueMG = 2538; +inline Value PawnValueEG = 206; +inline Value KnightValueEG = 854; +inline Value BishopValueEG = 915; +inline Value RookValueEG = 1380; +inline Value QueenValueEG = 2682; inline Value fianchettoBonus = 20; inline Value trappedBishopPenalty = 60; inline Value centerWeight = 5; @@ -16,8 +21,6 @@ inline Value mopUpEdgeDistWeight = 10; inline Value spaceWeight = 2; inline Value bishopPairMg = 25; inline Value bishopPairEg = 50; -inline Value developedMg = 8; -inline Value developedEg = 4; inline Value rookOpenFileMg = 25; inline Value rookOpenFileEg = 20; inline Value rookSemiOpenFileMg = 15; @@ -35,6 +38,98 @@ inline Value kqkEdgeWeight = 15; inline Value krkDistWeight = 5; inline Value krkEdgeWeight = 10; inline Value kpkWeight = 15; +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 } +}; +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 } +}; +inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; +inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; +inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; +inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +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 }; +inline Value developedMg = 8; +inline Value developedEg = 4; +inline Value outpostBonusKnight[2] = { 15, 30 }; +inline Value outpostBonusBishop[2] = { 10, 25 }; +inline Value kingProtector[6][2] = { + { 0, 0 }, + { 8, 12 }, + { 5, 10 }, + { 10, 15 }, + { 3, 5 }, + { 0, 0 } +}; +inline Value threatByMinor[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 15, 25 }, + { 15, 25 }, + { 25, 35 }, + { 35, 50 } +}; +inline Value threatByRook[7][2] = { + { 0, 0 }, + { 0, 0 }, + { 10, 15 }, + { 10, 15 }, + { 20, 25 }, + { 25, 35 } +}; inline Value hangingScore = 70; inline Value overloadScore = 25; inline Value threatByRankScore = 10; @@ -45,28 +140,5 @@ inline Value queenImWt = 50; inline Value rammedPawnPenalty = 10; inline Value rookOnSeventhBonus = 30; inline Value earlyQueenPenalty = 5; -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 } }; -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 } }; -inline Value kingTropismMg[7] = { 0, 0, 3, 2, 2, 5, 0 }; -inline Value kingTropismEg[7] = { 0, 0, 2, 2, 3, 4, 0 }; -inline Value passedBonusMg[7] = { 0, 5, 15, 40, 80, 140, 200 }; -inline Value passedBonusEg[7] = { 0, 10, 30, 70, 140, 230, 350 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -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 }; -inline Value outpostBonusKnight[2] = { 15, 30 }; -inline Value outpostBonusBishop[2] = { 10, 25 }; -inline Value kingProtector[6][2] = { { 0, 0 }, { 8, 12 }, { 5, 10 }, { 10, 15 }, { 3, 5 }, { 0, 0 } }; -inline Value threatByMinor[7][2] = { { 0, 0 }, { 0, 0 }, { 15, 25 }, { 15, 25 }, { 25, 35 }, { 35, 50 }, { 0, 0 } }; -inline Value threatByRook[7][2] = { { 0, 0 }, { 0, 0 }, { 10, 15 }, { 10, 15 }, { 20, 25 }, { 25, 35 }, { 0, 0 } }; } // namespace engine::eval #endif diff --git a/eval.cpp b/eval.cpp index 2ef14de..2c9d64a 100644 --- a/eval.cpp +++ b/eval.cpp @@ -32,16 +32,26 @@ Value *egPst[] = { nullptr, eg_pawn_table, eg_knight_table, eg_bishop_table, eg_ TUNE(SetRange(5, 30), tempo, - SetRange(80, 120), - PawnValue, - SetRange(280, 370), - KnightValue, - SetRange(300, 400), - BishopValue, - SetRange(450, 550), - RookValue, + SetRange(80, 150), + PawnValueMG, + SetRange(160, 260), + PawnValueEG, + SetRange(650, 850), + KnightValueMG, + SetRange(750, 950), + KnightValueEG, + SetRange(700, 900), + BishopValueMG, SetRange(800, 1000), - QueenValue); + BishopValueEG, + SetRange(1100, 1400), + RookValueMG, + SetRange(1200, 1500), + RookValueEG, + SetRange(2200, 2800), + QueenValueMG, + SetRange(2400, 3000), + QueenValueEG); TUNE(SetRange(-50, 70), mgMobilityCnt, egMobilityCnt); TUNE(SetRange(0, 30), fianchettoBonus, SetRange(0, 100), trappedBishopPenalty); TUNE(SetRange(-20, 20), kingTropismMg, kingTropismEg); @@ -281,8 +291,8 @@ EvalComponents eval_components(const chess::Position &board) { continue; mgScore += _sign * mgPst[pt][_sq]; egScore += _sign * egPst[pt][_sq]; - mgScore += _sign * piece_value(pt); - egScore += _sign * piece_value(pt); + mgScore += _sign * piece_value_mg(pt); + egScore += _sign * piece_value_eg(pt); if (pt == KNIGHT) phase += KnightPhase; else if (pt == BISHOP) @@ -715,18 +725,45 @@ EvalComponents eval_components(const chess::Position &board) { board.count() == 0 && board.count() == 0) return { 0, 0, 0 }; - phase = std::min((phase * 256 + TotalPhase / 2) / TotalPhase, 256); + phase = std::min((phase * 128 + TotalPhase / 2) / TotalPhase, 128); return { mgScore, egScore, phase }; } Value eval(const chess::Position &board) { - const int sign = board.side_to_move() == WHITE ? 1 : -1; auto [mg, eg, phase] = eval_components(board); - if (mg == 0 && eg == 0) + // Draw detected by eval_components (returned {0,0,0}) + if (mg == 0 && eg == 0 && phase == 0) return 0; - return (((mg * phase) + (eg * (256 - phase))) * sign) / 256 + engine::eval::tempo; + + // Scale factor (guide-based, simplified) + int sf = 64; + int total = popcount(board.occ()); + int pawns = board.count(); + if (total == 2 && pawns == 0) + return 0; // K vs K draw + if (total <= 4 && pawns == 0) + sf = 32; + eg = eg * sf / 64; + + // Tapered mix + int v = (mg * phase + eg * (128 - phase)) / 128; + + // Quantization to multiples of 16 (guide convention) + v = (v / 16) * 16; + + // 50-move rule scaling + int rule50 = std::min(static_cast(board.rule50_count()), 100); + v = v * (100 - rule50) / 100; + + // Convert to side-to-move perspective and add tempo + const int sign = board.side_to_move() == WHITE ? 1 : -1; + return v * sign + engine::eval::tempo; +} +Value piece_value_mg(PieceType pt) { + Value pieces[] = { 0, PawnValueMG, KnightValueMG, BishopValueMG, RookValueMG, QueenValueMG, 0 }; + return pieces[pt]; } -Value piece_value(PieceType pt) { - Value pieces[] = { 0, PawnValue, KnightValue, BishopValue, RookValue, QueenValue, 0 }; +Value piece_value_eg(PieceType pt) { + Value pieces[] = { 0, PawnValueEG, KnightValueEG, BishopValueEG, RookValueEG, QueenValueEG, 0 }; return pieces[pt]; } } // namespace engine::eval diff --git a/eval.h b/eval.h index aecdc5a..063c873 100644 --- a/eval.h +++ b/eval.h @@ -52,6 +52,7 @@ extern Value *egPst[]; Value eval(const chess::Position &board); EvalComponents eval_components(const chess::Position &board); -Value piece_value(chess::PieceType pt); +Value piece_value_mg(chess::PieceType pt); +Value piece_value_eg(chess::PieceType pt); } // namespace eval } // namespace engine diff --git a/movepick.cpp b/movepick.cpp index 4134810..6db55cc 100644 --- a/movepick.cpp +++ b/movepick.cpp @@ -3,7 +3,7 @@ #include "search.h" #include using namespace chess; -using engine::eval::piece_value; +using engine::eval::piece_value_mg; namespace engine::movepick { static Bitboard att(PieceType pt, Square sq, Bitboard occ) { @@ -66,7 +66,7 @@ Value see(Position &board, Move move) { Value gain[32]; PieceType attacker = board.at(move.from()); - gain[0] = piece_value(captured); + gain[0] = piece_value_mg(captured); Color stm = ~board.side_to_move(); int d = 0; @@ -74,7 +74,7 @@ Value see(Position &board, Move move) { while (++d < 32) { // Charge the piece that just captured. - gain[d] = piece_value(attacker) - gain[d - 1]; + gain[d] = piece_value_mg(attacker) - gain[d - 1]; if (gain[d] < 0) break; @@ -109,8 +109,8 @@ void orderMoves(Position &board, Movelist &moves, Move ttMove, int ply, const en scores[i] = 10000; else if (board.isCapture(move)) { Value s = see(board, move); - Value capturedVal = move.type_of() == EN_PASSANT ? piece_value(PAWN) : piece_value(board.at(move.to())); - Value attackerVal = piece_value(board.at(move.from())); + Value capturedVal = move.type_of() == EN_PASSANT ? piece_value_mg(PAWN) : piece_value_mg(board.at(move.to())); + Value attackerVal = piece_value_mg(board.at(move.from())); scores[i] = (s >= -50 ? 9000 : 4000) + std::max(s, Value(-50)) + (capturedVal * 10 - attackerVal) / 100; } else if (move == session.killerMoves[ply][0]) scores[i] = 8500; diff --git a/search.cpp b/search.cpp index 966f7ec..3b553b4 100644 --- a/search.cpp +++ b/search.cpp @@ -146,7 +146,7 @@ Value qsearch(Position &board, Value alpha, Value beta, search::Session &session continue; if (isCapture && !givesCheck && move.type_of() != PROMOTION) { Value capturedValue = - move.type_of() == EN_PASSANT ? eval::piece_value(PAWN) : eval::piece_value(board.at(move.to())); + move.type_of() == EN_PASSANT ? eval::piece_value_mg(PAWN) : eval::piece_value_mg(board.at(move.to())); if (standPat + capturedValue + 200 < alpha) continue; if (movepick::see(board, move) < 0) diff --git a/tune_cmd.cpp b/tune_cmd.cpp index 2db5c19..8b6e6f0 100644 --- a/tune_cmd.cpp +++ b/tune_cmd.cpp @@ -147,7 +147,7 @@ int compute_game_phase(const chess::Position &board) { else if (pt == chess::QUEEN) phase += QueenPhase; } - return (phase * 256 + TotalPhase / 2) / TotalPhase; + return std::min((phase * 128 + TotalPhase / 2) / TotalPhase, 128); } void accumulate_gradient(const chess::Position &board, @@ -203,28 +203,29 @@ void accumulate_gradient(const chess::Position &board, gradient[it_eg->second] += common_factor * eff * phase_eg; } - auto add_mat = [&](auto *addr) { - auto it = addr_to_idx.find(addr); - if (it != addr_to_idx.end()) { - gradient[it->second] += common_factor * eff * phase_mg; - gradient[it->second] += common_factor * eff * phase_eg; - } + auto add_mat = [&](auto *addr_mg, auto *addr_eg) { + auto it_mg = addr_to_idx.find(addr_mg); + auto it_eg = addr_to_idx.find(addr_eg); + if (it_mg != addr_to_idx.end()) + gradient[it_mg->second] += common_factor * eff * phase_mg; + if (it_eg != addr_to_idx.end()) + gradient[it_eg->second] += common_factor * eff * phase_eg; }; switch (pt) { case PAWN: - add_mat(&PawnValue); + add_mat(&PawnValueMG, &PawnValueEG); break; case KNIGHT: - add_mat(&KnightValue); + add_mat(&KnightValueMG, &KnightValueEG); break; case BISHOP: - add_mat(&BishopValue); + add_mat(&BishopValueMG, &BishopValueEG); break; case ROOK: - add_mat(&RookValue); + add_mat(&RookValueMG, &RookValueEG); break; case QUEEN: - add_mat(&QueenValue); + add_mat(&QueenValueMG, &QueenValueEG); break; default: break; @@ -742,8 +743,20 @@ void texel_tune(TuneData &all, pos.set_fen(fen); auto comp = eval::eval_components(pos); + int sf = 64; + int total = chess::popcount(pos.occ()); + int pawns = pos.count(); + if (total == 2 && pawns == 0) + sf = 0; + else if (total <= 4 && pawns == 0) + sf = 32; + int eg = sf ? comp.eg * sf / 64 : 0; + int v = sf ? (comp.mg * comp.phase + eg * (128 - comp.phase)) / 128 : 0; + v = (v / 16) * 16; + int rule50 = std::min(static_cast(pos.rule50_count()), 100); + v = v * (100 - rule50) / 100; const int sign = pos.side_to_move() == chess::WHITE ? 1 : -1; - Value score = (((comp.mg * comp.phase) + (comp.eg * (256 - comp.phase))) * sign) / 256 + eval::tempo; + Value score = v * sign + eval::tempo; double sig = sigmoid(score); double error = sig - all.result(idx); @@ -755,8 +768,8 @@ void texel_tune(TuneData &all, double sig_deriv = 0.004 * sig * (1.0 - sig); double common_factor = 2.0 * error * sig_deriv; - double phase_mg = comp.phase / 256.0; - double phase_eg = (256 - comp.phase) / 256.0; + double phase_mg = comp.phase / 128.0; + double phase_eg = (128 - comp.phase) / 128.0; double stm_sign_val = (pos.side_to_move() == chess::WHITE) ? 1.0 : -1.0; accumulate_gradient(pos, common_factor, addr_map, phase_mg, phase_eg, stm_sign_val, pg); From 572eb954e5333bb950768848d5ac5b025bbc7cf5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 17 Jul 2026 03:10:35 +0000 Subject: [PATCH 38/49] Apply clang-format --- eval.cpp | 2 +- movepick.cpp | 3 ++- search.cpp | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/eval.cpp b/eval.cpp index 2c9d64a..d70dfcd 100644 --- a/eval.cpp +++ b/eval.cpp @@ -739,7 +739,7 @@ Value eval(const chess::Position &board) { int total = popcount(board.occ()); int pawns = board.count(); if (total == 2 && pawns == 0) - return 0; // K vs K draw + return 0; // K vs K draw if (total <= 4 && pawns == 0) sf = 32; eg = eg * sf / 64; diff --git a/movepick.cpp b/movepick.cpp index 6db55cc..071402c 100644 --- a/movepick.cpp +++ b/movepick.cpp @@ -109,7 +109,8 @@ void orderMoves(Position &board, Movelist &moves, Move ttMove, int ply, const en scores[i] = 10000; else if (board.isCapture(move)) { Value s = see(board, move); - Value capturedVal = move.type_of() == EN_PASSANT ? piece_value_mg(PAWN) : piece_value_mg(board.at(move.to())); + Value capturedVal = + move.type_of() == EN_PASSANT ? piece_value_mg(PAWN) : piece_value_mg(board.at(move.to())); Value attackerVal = piece_value_mg(board.at(move.from())); scores[i] = (s >= -50 ? 9000 : 4000) + std::max(s, Value(-50)) + (capturedVal * 10 - attackerVal) / 100; } else if (move == session.killerMoves[ply][0]) diff --git a/search.cpp b/search.cpp index 3b553b4..8c4a6c8 100644 --- a/search.cpp +++ b/search.cpp @@ -145,8 +145,8 @@ Value qsearch(Position &board, Value alpha, Value beta, search::Session &session if (!isCapture && !givesCheck) continue; if (isCapture && !givesCheck && move.type_of() != PROMOTION) { - Value capturedValue = - move.type_of() == EN_PASSANT ? eval::piece_value_mg(PAWN) : eval::piece_value_mg(board.at(move.to())); + Value capturedValue = move.type_of() == EN_PASSANT ? eval::piece_value_mg(PAWN) + : eval::piece_value_mg(board.at(move.to())); if (standPat + capturedValue + 200 < alpha) continue; if (movepick::see(board, move) < 0) From aa1e56b2dda6994b80ecf542c1b0e5348bcc8c9c Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 25 Jul 2026 21:45:25 +0700 Subject: [PATCH 39/49] Update games.yml --- .github/workflows/games.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 86fa4ed..69a9ed5 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -110,9 +110,9 @@ jobs: test: needs: [build-new, build-base, prepare-tools] strategy: - fail-fast: false + fail-fast: true matrix: - shard: [0, 1, 2, 3,4,5,6,7] + shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] runs-on: ubuntu-latest @@ -125,6 +125,7 @@ jobs: ELO0: ${{ github.event.inputs.elo0 }} ELO1: ${{ github.event.inputs.elo1 }} run: | + set -eo pipefail chmod +x new-engine/engine chmod +x base-engine/$OUTPUT_EXEC chmod +x tools/fastchess From 6da4c8915c12895cf97ecec6c6c3139fb2796297 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sat, 25 Jul 2026 22:43:09 +0700 Subject: [PATCH 40/49] Update games.yml --- .github/workflows/games.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 69a9ed5..219743a 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -112,7 +112,7 @@ jobs: strategy: fail-fast: true matrix: - shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] + shard: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,20,21,22,23,24,25,26,27,28,29] runs-on: ubuntu-latest @@ -135,7 +135,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000\ - -rounds 375 -repeat -log level=err \ + -rounds 200 -repeat -log level=err \ -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ From 63134891ab0f4f676dd20911460d816f6f998b30 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:30:49 +0700 Subject: [PATCH 41/49] Update .github/workflows/games.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/games.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 219743a..f18df46 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -134,7 +134,7 @@ jobs: -engine cmd=new-engine/engine name=new \ -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ - -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000\ + -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000 \ -rounds 200 -repeat -log level=err \ -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ From 0d948f108d78e0a0eaec470daac4db1e96b07062 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:32:18 +0700 Subject: [PATCH 42/49] Update spsa.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- spsa.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spsa.py b/spsa.py index 06ee2f2..688f214 100644 --- a/spsa.py +++ b/spsa.py @@ -197,7 +197,8 @@ def load_params(path, engine_path): "a": float(a), "c": float(c), } - except Exception as e:print(e, row) + except (ValueError, IndexError) as e: + logger.debug("skipping unparseable row %r: %s", row, e) return params else: logger.info("%s not found, starting engine to capture parameters", path) From 6aa6720c2796bcca200ca0feda525eb535567dc6 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:32:30 +0700 Subject: [PATCH 43/49] Update spsa.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- spsa.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spsa.py b/spsa.py index 688f214..d61b3d6 100644 --- a/spsa.py +++ b/spsa.py @@ -243,11 +243,10 @@ def run_fastchess_match(plus_params, minus_params, args, iteration): try: result = subprocess.run(cmd, capture_output=True, text=True, check=True) except subprocess.CalledProcessError as e: - print("Return code:", e.returncode) - print("STDOUT:") - print(e.stdout) - print("STDERR:") - print(e.stderr) + logger.error("fastchess exited %s", e.returncode) + logger.debug("STDOUT:\n%s", e.stdout) + logger.debug("STDERR:\n%s", e.stderr) + return 0.5, 0.5 try: with open(temp_config_path, "r", encoding="utf-8") as f: output_config = json.load(f) From 981bfcef298d978eed14820587d06ea7152a4ade Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 26 Jul 2026 11:32:55 +0700 Subject: [PATCH 44/49] Update spsa.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- spsa.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spsa.py b/spsa.py index d61b3d6..ad450b4 100644 --- a/spsa.py +++ b/spsa.py @@ -346,7 +346,6 @@ def spsa_core(params, args): for k in range(args.iters): logger.info(f"=== iter: {k} ===") - deltas = {n: (1 if random.random() < 0.5 else -1) for n in params} ak = {n: p["a"] / (k + args.stable_offset) ** args.alpha for n, p in params.items()} ck = {n: p["c"] / (k + 1) ** args.gamma for n, p in params.items()} @@ -360,11 +359,6 @@ def spsa_core(params, args): minus_int = {n: int(round(v)) for n, v in minus.items()} if plus_int != minus_int: break - plus_int = {n: int(round(v)) for n, v in plus.items()} - minus_int = {n: int(round(v)) for n, v in minus.items()} - - if plus_int == minus_int: - continue f_plus, f_minus = run_fastchess_match(plus, minus, args, k) for n, p in params.items(): From bd143908781e31175d066799189e2d7c30752fa6 Mon Sep 17 00:00:00 2001 From: winapiadmin Date: Sun, 26 Jul 2026 14:24:11 +0700 Subject: [PATCH 45/49] issues fix --- .github/workflows/games.yml | 2 +- eval.cpp | 28 ++++++++++++---------------- eval.h | 1 + tune.cpp | 2 +- tune_cmd.cpp | 31 +++++++++++++++++++------------ 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index f18df46..9e3c135 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -135,7 +135,7 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000 \ - -rounds 200 -repeat -log level=err \ + -rounds $(( ${{ github.event.inputs.rounds }} / 30 )) -repeat -log level=err \ -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ diff --git a/eval.cpp b/eval.cpp index d70dfcd..84c28b4 100644 --- a/eval.cpp +++ b/eval.cpp @@ -728,36 +728,32 @@ EvalComponents eval_components(const chess::Position &board) { phase = std::min((phase * 128 + TotalPhase / 2) / TotalPhase, 128); return { mgScore, egScore, phase }; } -Value eval(const chess::Position &board) { - auto [mg, eg, phase] = eval_components(board); - // Draw detected by eval_components (returned {0,0,0}) - if (mg == 0 && eg == 0 && phase == 0) +Value score_from_components(const EvalComponents &comp, const chess::Position &board) { + if (comp.mg == 0 && comp.eg == 0 && comp.phase == 0) return 0; - // Scale factor (guide-based, simplified) int sf = 64; - int total = popcount(board.occ()); - int pawns = board.count(); + int total = chess::popcount(board.occ()); + int pawns = board.count(); if (total == 2 && pawns == 0) - return 0; // K vs K draw + return 0; if (total <= 4 && pawns == 0) sf = 32; - eg = eg * sf / 64; - - // Tapered mix - int v = (mg * phase + eg * (128 - phase)) / 128; + int eg = comp.eg * sf / 64; - // Quantization to multiples of 16 (guide convention) + int v = (comp.mg * comp.phase + eg * (128 - comp.phase)) / 128; v = (v / 16) * 16; - // 50-move rule scaling int rule50 = std::min(static_cast(board.rule50_count()), 100); v = v * (100 - rule50) / 100; - // Convert to side-to-move perspective and add tempo - const int sign = board.side_to_move() == WHITE ? 1 : -1; + const int sign = board.side_to_move() == chess::WHITE ? 1 : -1; return v * sign + engine::eval::tempo; } + +Value eval(const chess::Position &board) { + return score_from_components(eval_components(board), board); +} Value piece_value_mg(PieceType pt) { Value pieces[] = { 0, PawnValueMG, KnightValueMG, BishopValueMG, RookValueMG, QueenValueMG, 0 }; return pieces[pt]; diff --git a/eval.h b/eval.h index 063c873..c290bca 100644 --- a/eval.h +++ b/eval.h @@ -52,6 +52,7 @@ extern Value *egPst[]; Value eval(const chess::Position &board); EvalComponents eval_components(const chess::Position &board); +Value score_from_components(const EvalComponents &comp, const chess::Position &board); Value piece_value_mg(chess::PieceType pt); Value piece_value_eg(chess::PieceType pt); } // namespace eval diff --git a/tune.cpp b/tune.cpp index 5d38acf..92bd513 100644 --- a/tune.cpp +++ b/tune.cpp @@ -77,7 +77,7 @@ void Tune::make_option(OptionsMap *opts, const string &n, int v, const SetRange << a << "," // << b << "," // << (b - a) / 10.0 << "," // - << 0.2 << '\n'; + << (b - a) / 10.0 << '\n'; } string Tune::next(string &names, bool pop) { diff --git a/tune_cmd.cpp b/tune_cmd.cpp index 8b6e6f0..c097900 100644 --- a/tune_cmd.cpp +++ b/tune_cmd.cpp @@ -177,6 +177,18 @@ void accumulate_gradient(const chess::Position &board, } } + { + auto it = addr_to_idx.find(&developedMg); + if (it != addr_to_idx.end()) { + int devCount[2] = { 0, 0 }; + for (Color c : { WHITE, BLACK }) { + Bitboard backRank = c == WHITE ? attacks::MASK_RANK[0] : attacks::MASK_RANK[7]; + devCount[c] = popcount((board.pieces(KNIGHT, c) | board.pieces(BISHOP, c)) & backRank); + } + gradient[it->second] += common_factor * stm_sign * (devCount[BLACK] - devCount[WHITE]) * phase_mg; + } + } + { Bitboard pinMask = board.pin_mask(); Bitboard occ = board.occ(), occ2 = occ; @@ -655,18 +667,18 @@ void accumulate_gradient(const chess::Position &board, auto it_mg = addr_to_idx.find(&threatByMinor[pt][0]); auto it_eg = addr_to_idx.find(&threatByMinor[pt][1]); if (it_mg != addr_to_idx.end()) - gradient[it_mg->second] += common_factor * eff_threat; + gradient[it_mg->second] += common_factor * eff_threat * phase_mg; if (it_eg != addr_to_idx.end()) - gradient[it_eg->second] += common_factor * eff_threat; + gradient[it_eg->second] += common_factor * eff_threat * phase_eg; } if (attackedByRook) { auto it_mg = addr_to_idx.find(&threatByRook[pt][0]); auto it_eg = addr_to_idx.find(&threatByRook[pt][1]); if (it_mg != addr_to_idx.end()) - gradient[it_mg->second] += common_factor * eff_threat; + gradient[it_mg->second] += common_factor * eff_threat * phase_mg; if (it_eg != addr_to_idx.end()) - gradient[it_eg->second] += common_factor * eff_threat; + gradient[it_eg->second] += common_factor * eff_threat * phase_eg; } Rank relRank = relative_rank(c, sq); @@ -743,6 +755,8 @@ void texel_tune(TuneData &all, pos.set_fen(fen); auto comp = eval::eval_components(pos); + Value score = eval::score_from_components(comp, pos); + int sf = 64; int total = chess::popcount(pos.occ()); int pawns = pos.count(); @@ -750,13 +764,6 @@ void texel_tune(TuneData &all, sf = 0; else if (total <= 4 && pawns == 0) sf = 32; - int eg = sf ? comp.eg * sf / 64 : 0; - int v = sf ? (comp.mg * comp.phase + eg * (128 - comp.phase)) / 128 : 0; - v = (v / 16) * 16; - int rule50 = std::min(static_cast(pos.rule50_count()), 100); - v = v * (100 - rule50) / 100; - const int sign = pos.side_to_move() == chess::WHITE ? 1 : -1; - Value score = v * sign + eval::tempo; double sig = sigmoid(score); double error = sig - all.result(idx); @@ -769,7 +776,7 @@ void texel_tune(TuneData &all, double sig_deriv = 0.004 * sig * (1.0 - sig); double common_factor = 2.0 * error * sig_deriv; double phase_mg = comp.phase / 128.0; - double phase_eg = (128 - comp.phase) / 128.0; + double phase_eg = sf ? (128 - comp.phase) / 128.0 * sf / 64.0 : 0.0; double stm_sign_val = (pos.side_to_move() == chess::WHITE) ? 1.0 : -1.0; accumulate_gradient(pos, common_factor, addr_map, phase_mg, phase_eg, stm_sign_val, pg); From 4752c54e80d8e80430bd0b6c9fbbb9b756bcd1a7 Mon Sep 17 00:00:00 2001 From: winapiadmin <138602885+winapiadmin@users.noreply.github.com> Date: Sun, 26 Jul 2026 14:33:18 +0700 Subject: [PATCH 46/49] Update .github/workflows/games.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/games.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/games.yml b/.github/workflows/games.yml index 9e3c135..f3ef802 100644 --- a/.github/workflows/games.yml +++ b/.github/workflows/games.yml @@ -135,7 +135,16 @@ jobs: -engine cmd=base-engine/$OUTPUT_EXEC name=base \ -openings file=tools/UHO_Lichess_4852_v1.epd format=epd order=random \ -each tc=$TC -startup-ms 600000 -ucinewgame-ms 600000 -ping-ms 600000 \ - -rounds $(( ${{ github.event.inputs.rounds }} / 30 )) -repeat -log level=err \ + ROUNDS: ${{ github.event.inputs.rounds }} + run: | + set -eo pipefail + if [[ ! "$ROUNDS" =~ ^[0-9]+$ ]]; then + echo "rounds must be a decimal integer" >&2 + exit 1 + fi + rounds_value=$((10#$ROUNDS)) + shard_rounds=$((rounds_value / 30)) + -rounds "$shard_rounds" -repeat -log level=err \ -concurrency $(nproc) -testEnv -sprt elo0=$ELO0 elo1=$ELO1 alpha=0.05 beta=0.05 \ -pgnout notation=san nodes=true \ file=games_${{ matrix.shard }}.pgn \ From 145430f6e3a6d2275e00f22119c28b92c9df9065 Mon Sep 17 00:00:00 2001 From: winapiadmin Date: Sun, 26 Jul 2026 14:37:00 +0700 Subject: [PATCH 47/49] issues fix --- eval.cpp | 4 ++-- tune_cmd.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/eval.cpp b/eval.cpp index 84c28b4..41d7493 100644 --- a/eval.cpp +++ b/eval.cpp @@ -64,7 +64,7 @@ TUNE(SetRange(0, 30), SetRange(1, 30), spaceWeight); TUNE(SetRange(0, 50), bishopPairMg, SetRange(0, 50), bishopPairEg); -TUNE(SetRange(1, 20), developedMg, SetRange(1, 20), developedEg); +TUNE(SetRange(1, 20), developedMg); TUNE(SetRange(0, 30), rookOpenFileMg, SetRange(0, 30), @@ -266,7 +266,7 @@ EvalComponents eval_components(const chess::Position &board) { for (Color c : { WHITE, BLACK }) { int s = (c == WHITE) ? 1 : -1; Square qStart = c == WHITE ? SQ_D1 : SQ_D8; - if (!(board.pieces(QUEEN, c) & (1ULL << qStart))) { + if (board.pieces(QUEEN, c) && !(board.pieces(QUEEN, c) & (1ULL << qStart))) { Bitboard backRank = c == WHITE ? attacks::MASK_RANK[0] : attacks::MASK_RANK[7]; int undeveloped = popcount((board.pieces(KNIGHT, c) | board.pieces(BISHOP, c)) & backRank); if (undeveloped >= 2) { diff --git a/tune_cmd.cpp b/tune_cmd.cpp index c097900..1cfc879 100644 --- a/tune_cmd.cpp +++ b/tune_cmd.cpp @@ -166,7 +166,7 @@ void accumulate_gradient(const chess::Position &board, for (Color c : { WHITE, BLACK }) { double s = (c == WHITE) ? 1.0 : -1.0; Square qStart = c == WHITE ? SQ_D1 : SQ_D8; - if (!(board.pieces(QUEEN, c) & (1ULL << qStart))) { + if (board.pieces(QUEEN, c) && !(board.pieces(QUEEN, c) & (1ULL << qStart))) { Bitboard backRank = c == WHITE ? attacks::MASK_RANK[0] : attacks::MASK_RANK[7]; int undeveloped = popcount((board.pieces(KNIGHT, c) | board.pieces(BISHOP, c)) & backRank); if (undeveloped >= 2) { @@ -769,12 +769,23 @@ void texel_tune(TuneData &all, double error = sig - all.result(idx); ploss += error * error; + // Skip gradient accumulation for sentinel positions (forced-zero components) + if (comp.mg == 0 && comp.eg == 0 && comp.phase == 0) + continue; + // Avoid division by zero in gradient if (std::abs(error) < 1e-12) continue; double sig_deriv = 0.004 * sig * (1.0 - sig); double common_factor = 2.0 * error * sig_deriv; + + // Scale common_factor by rule-50 factor to match score_from_components + { + int rule50 = std::min(static_cast(pos.rule50_count()), 100); + common_factor = common_factor * (100 - rule50) / 100; + } + double phase_mg = comp.phase / 128.0; double phase_eg = sf ? (128 - comp.phase) / 128.0 * sf / 64.0 : 0.0; double stm_sign_val = (pos.side_to_move() == chess::WHITE) ? 1.0 : -1.0; From e1a38bea9f042ea70be943346e539dac08e2af48 Mon Sep 17 00:00:00 2001 From: winapiadmin Date: Sun, 26 Jul 2026 14:48:49 +0700 Subject: [PATCH 48/49] issues fix --- Weights.h | 1 - eval.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Weights.h b/Weights.h index ef917e9..3dafdd6 100644 --- a/Weights.h +++ b/Weights.h @@ -103,7 +103,6 @@ inline Value eg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 }; inline Value developedMg = 8; -inline Value developedEg = 4; inline Value outpostBonusKnight[2] = { 15, 30 }; inline Value outpostBonusBishop[2] = { 10, 25 }; inline Value kingProtector[6][2] = { diff --git a/eval.cpp b/eval.cpp index 41d7493..70e0b7b 100644 --- a/eval.cpp +++ b/eval.cpp @@ -260,7 +260,7 @@ EvalComponents eval_components(const chess::Position &board) { devCount[c] = popcount(knightsHome) + popcount(bishopsHome); } mgScore += (devCount[BLACK] - devCount[WHITE]) * developedMg; - // egScore += (devCount[BLACK] - devCount[WHITE]) * developedEg; + // EG development term intentionally disabled // Early queen development penalty: queen moved but minors still on back rank for (Color c : { WHITE, BLACK }) { From 1d654a87698167fcb1716dc3531678de4dc8214c Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sun, 26 Jul 2026 08:50:17 +0000 Subject: [PATCH 49/49] Apply clang-format --- eval.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/eval.cpp b/eval.cpp index 70e0b7b..171fa2b 100644 --- a/eval.cpp +++ b/eval.cpp @@ -751,9 +751,7 @@ Value score_from_components(const EvalComponents &comp, const chess::Position &b return v * sign + engine::eval::tempo; } -Value eval(const chess::Position &board) { - return score_from_components(eval_components(board), board); -} +Value eval(const chess::Position &board) { return score_from_components(eval_components(board), board); } Value piece_value_mg(PieceType pt) { Value pieces[] = { 0, PawnValueMG, KnightValueMG, BishopValueMG, RookValueMG, QueenValueMG, 0 }; return pieces[pt];