Skip to content

Commit 2168635

Browse files
committed
Apply clang-format
1 parent 748a851 commit 2168635

4 files changed

Lines changed: 81 additions & 25 deletions

File tree

‎Weights.h‎

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,70 @@ Value kqkEdgeWeight = 18;
3333
Value krkDistWeight = 1;
3434
Value krkEdgeWeight = 9;
3535
Value kpkWeight = 15;
36-
Value mgMobilityCnt[7][8] = { { 4, -1, 5, -1, -5, 3, 0, -3 }, { -7, -10, 7, -4, -7, 1, -5, -2 }, { -1, -8, -6, -3, 2, -2, 1, 7 }, { -10, -6, 5, -3, 3, 5, -7, 10 }, { -8, -8, -10, -1, -2, 0, 6, 8 }, { -9, -1, -7, 2, -2, -7, -5, 2 }, { -4, -5, -9, -5, -3, -6, 5, -3 } };
37-
Value egMobilityCnt[7][8] = { { -8, -2, -3, 7, -4, 2, -1, -4 }, { -7, -8, -8, 3, -4, -3, 2, -9 }, { 3, -3, -10, -5, -2, -10, -4, 7 }, { -5, -7, -2, 1, -2, 7, -3, 8 }, { -4, -9, 3, 0, 0, -6, 6, 4 }, { -10, -2, -10, -2, -5, -3, 0, 0 }, { -10, 8, 7, 5, 5, 3, -1, 1 } };
36+
Value mgMobilityCnt[7][8] = {
37+
{ 4, -1, 5, -1, -5, 3, 0, -3 },
38+
{ -7, -10, 7, -4, -7, 1, -5, -2 },
39+
{ -1, -8, -6, -3, 2, -2, 1, 7 },
40+
{ -10, -6, 5, -3, 3, 5, -7, 10 },
41+
{ -8, -8, -10, -1, -2, 0, 6, 8 },
42+
{ -9, -1, -7, 2, -2, -7, -5, 2 },
43+
{ -4, -5, -9, -5, -3, -6, 5, -3 }
44+
};
45+
Value egMobilityCnt[7][8] = {
46+
{ -8, -2, -3, 7, -4, 2, -1, -4 },
47+
{ -7, -8, -8, 3, -4, -3, 2, -9 },
48+
{ 3, -3, -10, -5, -2, -10, -4, 7 },
49+
{ -5, -7, -2, 1, -2, 7, -3, 8 },
50+
{ -4, -9, 3, 0, 0, -6, 6, 4 },
51+
{ -10, -2, -10, -2, -5, -3, 0, 0 },
52+
{ -10, 8, 7, 5, 5, 3, -1, 1 }
53+
};
3854
Value kingTropismMg[7] = { 13, 14, 6, -5, 5, 12, 6 };
3955
Value kingTropismEg[7] = { -9, -13, 3, 5, -2, 19, 4 };
4056
Value passedBonusMg[7] = { 0, 4, 13, 73, 131, 165, 39 };
4157
Value passedBonusEg[7] = { 0, 66, 59, 96, 158, 185, 22 };
42-
Value mg_knight_table[64] = { 1, -5, 8, -21, -11, -2, -24, -2, 23, 21, 13, 2, 4, -17, -7, 4, -5, -15, -8, 14, 19, -2, 2, -25, -13, 15, -1, -1, 5, -18, 5, 6, -1, -13, 1, 17, -24, -13, 14, 19, -10, 6, 1, 16, -13, -18, 8, 24, 14, -21, -8, -21, -15, -1, -1, 8, -17, 22, -18, 6, -11, -4, -9, -7 };
43-
Value mg_bishop_table[64] = { 3, 21, -23, 16, 5, -20, 7, -4, 14, -15, 21, -11, 7, 2, -4, 19, -5, -4, 22, 11, 15, 25, 20, -9, -3, -4, 20, 21, 10, 11, -4, -21, 9, 9, 10, 5, -3, 0, 16, 23, -1, 5, -10, -12, 9, -24, -9, -10, 5, -17, -8, 5, 4, -3, 6, -4, 1, 2, 20, -4, 9, 3, -20, -22 };
44-
Value mg_rook_table[64] = { -10, 20, -13, 18, 12, -3, 13, -25, -11, 3, 10, -4, 7, 13, -24, 5, -3, -7, -19, -3, 4, -6, 13, 13, 11, 20, 16, -6, 14, -15, -16, -15, 3, 7, 14, -10, -7, 20, -15, 10, 25, 1, 3, -14, 22, 5, 1, -12, -20, -13, 22, -9, 11, -2, -15, -11, 22, -14, -10, 5, 0, 9, -20, -13 };
45-
Value mg_king_table[64] = { 11, -12, -10, -19, 5, -6, -2, -10, 19, 13, -7, -3, -7, 8, -21, -24, -5, 16, 19, 2, -21, -14, 11, -16, -12, -13, -18, 14, -23, -14, 16, -5, -16, 0, -21, -12, -2, 14, -16, 17, 11, -10, 21, 14, -5, -15, 19, 13, 8, -21, -13, 4, 1, 1, 16, 13, -8, 13, 6, -20, -4, 3, 8, -2 };
46-
Value mg_queen_table[64] = { -2, -2, 4, 11, 9, -2, 0, -5, 14, -2, -11, 14, -13, -11, -3, -21, 7, -14, -4, -6, -3, -16, -4, -11, -2, 9, -16, 6, -6, -12, -14, -7, -4, -22, -12, 6, 21, -4, -6, -5, -6, -7, -4, 2, 13, 11, -8, 14, 18, -5, -25, 22, -14, 18, -3, 9, -13, 21, 15, -21, 13, 7, -9, 3 };
47-
Value eg_knight_table[64] = { -13, 25, -3, 3, -7, 18, -21, 3, -1, 15, -13, 3, -16, 15, -5, 8, -11, -12, 22, 14, 10, 20, 9, -6, -10, 2, -13, -7, -17, 2, 18, -19, 7, 12, -23, 17, -5, 17, 10, -7, -18, -2, -10, -14, 20, 15, -13, 18, 9, -8, -13, 12, 20, 17, 16, 25, 18, 20, 5, 10, -10, 2, 0, 8 };
48-
Value eg_bishop_table[64] = { -19, -12, -9, -5, 9, -14, -11, 6, -10, -10, 6, -3, 13, -18, -6, 2, 25, 4, 9, -16, -3, -9, 1, 7, 3, -20, -3, 9, -20, -3, 21, 3, -8, 10, 4, -11, -8, -18, -13, 0, 10, 17, 14, -18, 21, 11, 18, 0, -16, 4, 3, 17, -9, -16, -25, -2, -17, -5, -5, 19, 12, -3, -11, -13 };
49-
Value eg_rook_table[64] = { -21, -24, 12, -12, -11, 15, -17, -22, -14, -22, -18, -5, -9, -7, 23, -2, -1, 9, 18, 3, 4, -19, 20, -21, -15, -21, 9, -11, -2, 4, -8, 15, -6, 13, -6, -10, -3, 12, 16, -18, -19, -19, 23, 3, -14, -23, 3, 15, 18, -6, -24, 21, 18, 3, -2, 17, 8, 13, -11, -13, 0, -16, -4, -10 };
50-
Value eg_king_table[64] = { -14, 17, 13, -10, -15, 3, -8, -3, 19, 19, -2, 6, -2, 7, -7, -7, 21, 10, 17, -21, 0, 15, -6, -9, -7, 24, 8, 0, 17, 12, -4, -6, 8, -16, 19, 0, 9, 20, 18, 12, -12, -2, -4, -14, 21, 2, -6, -5, 17, -2, -3, -9, -1, -23, 7, -14, 9, 2, 22, -20, 3, 22, -10, 2 };
51-
Value eg_queen_table[64] = { -7, -3, 13, 11, 2, 17, 2, -19, 12, -5, -2, -11, 2, -7, 19, 2, -1, 15, 19, 1, 15, 8, -19, -6, -14, -25, -8, 22, 4, -22, -10, 20, 3, -1, -3, -17, 12, -3, -4, -4, -7, 16, -18, -22, -2, -11, 4, -14, -7, -15, -8, 9, 20, 8, -2, -1, 8, 18, 20, -23, -12, -8, 6, -11 };
52-
Value mg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, -16, 4, 6, -22, -16, -20, 4, -13, 2, -24, -12, -7, -3, -11, -5, 6, -15, -9, 2, -14, 2, -18, -7, -10, 1, 15, -7, -6, 22, -13, -6, 2, -16, -9, 14, -2, 23, -18, 8, 6, -2, -8, -1, -4, -10, -1, 18, -12 };
53-
Value eg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, -4, 1, -2, -5, -20, 13, -17, -2, 2, 24, 12, -14, -4, 2, -17, -4, 15, -9, 8, 11, -24, -4, -14, -10, -13, -11, -6, -17, -4, 17, -14, -3, -17, -19, -10, -19, -23, 9, 13, -3, -7, -5, -9, 21, 8, -17, 7, 13 };
58+
Value mg_knight_table[64] = { 1, -5, 8, -21, -11, -2, -24, -2, 23, 21, 13, 2, 4, -17, -7, 4,
59+
-5, -15, -8, 14, 19, -2, 2, -25, -13, 15, -1, -1, 5, -18, 5, 6,
60+
-1, -13, 1, 17, -24, -13, 14, 19, -10, 6, 1, 16, -13, -18, 8, 24,
61+
14, -21, -8, -21, -15, -1, -1, 8, -17, 22, -18, 6, -11, -4, -9, -7 };
62+
Value mg_bishop_table[64] = { 3, 21, -23, 16, 5, -20, 7, -4, 14, -15, 21, -11, 7, 2, -4, 19, -5, -4, 22, 11, 15, 25,
63+
20, -9, -3, -4, 20, 21, 10, 11, -4, -21, 9, 9, 10, 5, -3, 0, 16, 23, -1, 5, -10, -12,
64+
9, -24, -9, -10, 5, -17, -8, 5, 4, -3, 6, -4, 1, 2, 20, -4, 9, 3, -20, -22 };
65+
Value mg_rook_table[64] = { -10, 20, -13, 18, 12, -3, 13, -25, -11, 3, 10, -4, 7, 13, -24, 5,
66+
-3, -7, -19, -3, 4, -6, 13, 13, 11, 20, 16, -6, 14, -15, -16, -15,
67+
3, 7, 14, -10, -7, 20, -15, 10, 25, 1, 3, -14, 22, 5, 1, -12,
68+
-20, -13, 22, -9, 11, -2, -15, -11, 22, -14, -10, 5, 0, 9, -20, -13 };
69+
Value mg_king_table[64] = { 11, -12, -10, -19, 5, -6, -2, -10, 19, 13, -7, -3, -7, 8, -21, -24,
70+
-5, 16, 19, 2, -21, -14, 11, -16, -12, -13, -18, 14, -23, -14, 16, -5,
71+
-16, 0, -21, -12, -2, 14, -16, 17, 11, -10, 21, 14, -5, -15, 19, 13,
72+
8, -21, -13, 4, 1, 1, 16, 13, -8, 13, 6, -20, -4, 3, 8, -2 };
73+
Value mg_queen_table[64] = { -2, -2, 4, 11, 9, -2, 0, -5, 14, -2, -11, 14, -13, -11, -3, -21, 7, -14, -4, -6, -3, -16,
74+
-4, -11, -2, 9, -16, 6, -6, -12, -14, -7, -4, -22, -12, 6, 21, -4, -6, -5, -6, -7, -4, 2,
75+
13, 11, -8, 14, 18, -5, -25, 22, -14, 18, -3, 9, -13, 21, 15, -21, 13, 7, -9, 3 };
76+
Value eg_knight_table[64] = { -13, 25, -3, 3, -7, 18, -21, 3, -1, 15, -13, 3, -16, 15, -5, 8,
77+
-11, -12, 22, 14, 10, 20, 9, -6, -10, 2, -13, -7, -17, 2, 18, -19,
78+
7, 12, -23, 17, -5, 17, 10, -7, -18, -2, -10, -14, 20, 15, -13, 18,
79+
9, -8, -13, 12, 20, 17, 16, 25, 18, 20, 5, 10, -10, 2, 0, 8 };
80+
Value eg_bishop_table[64] = { -19, -12, -9, -5, 9, -14, -11, 6, -10, -10, 6, -3, 13, -18, -6, 2,
81+
25, 4, 9, -16, -3, -9, 1, 7, 3, -20, -3, 9, -20, -3, 21, 3,
82+
-8, 10, 4, -11, -8, -18, -13, 0, 10, 17, 14, -18, 21, 11, 18, 0,
83+
-16, 4, 3, 17, -9, -16, -25, -2, -17, -5, -5, 19, 12, -3, -11, -13 };
84+
Value eg_rook_table[64] = { -21, -24, 12, -12, -11, 15, -17, -22, -14, -22, -18, -5, -9, -7, 23, -2,
85+
-1, 9, 18, 3, 4, -19, 20, -21, -15, -21, 9, -11, -2, 4, -8, 15,
86+
-6, 13, -6, -10, -3, 12, 16, -18, -19, -19, 23, 3, -14, -23, 3, 15,
87+
18, -6, -24, 21, 18, 3, -2, 17, 8, 13, -11, -13, 0, -16, -4, -10 };
88+
Value eg_king_table[64] = { -14, 17, 13, -10, -15, 3, -8, -3, 19, 19, -2, 6, -2, 7, -7, -7, 21, 10, 17, -21, 0, 15,
89+
-6, -9, -7, 24, 8, 0, 17, 12, -4, -6, 8, -16, 19, 0, 9, 20, 18, 12, -12, -2, -4, -14,
90+
21, 2, -6, -5, 17, -2, -3, -9, -1, -23, 7, -14, 9, 2, 22, -20, 3, 22, -10, 2 };
91+
Value eg_queen_table[64] = { -7, -3, 13, 11, 2, 17, 2, -19, 12, -5, -2, -11, 2, -7, 19, 2,
92+
-1, 15, 19, 1, 15, 8, -19, -6, -14, -25, -8, 22, 4, -22, -10, 20,
93+
3, -1, -3, -17, 12, -3, -4, -4, -7, 16, -18, -22, -2, -11, 4, -14,
94+
-7, -15, -8, 9, 20, 8, -2, -1, 8, 18, 20, -23, -12, -8, 6, -11 };
95+
Value mg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, -16, 4, 6, -22, -16, -20, 4, -13, 2, -24, -12,
96+
-7, -3, -11, -5, 6, -15, -9, 2, -14, 2, -18, -7, -10, 1, 15, -7, -6, 22, -13,
97+
-6, 2, -16, -9, 14, -2, 23, -18, 8, 6, -2, -8, -1, -4, -10, -1, 18, -12 };
98+
Value eg_pawn_table[56] = { 0, 0, 0, 0, 0, 0, 0, 0, -4, 1, -2, -5, -20, 13, -17, -2, 2, 24, 12,
99+
-14, -4, 2, -17, -4, 15, -9, 8, 11, -24, -4, -14, -10, -13, -11, -6, -17, -4, 17,
100+
-14, -3, -17, -19, -10, -19, -23, 9, 13, -3, -7, -5, -9, 21, 8, -17, 7, 13 };
54101
} // namespace engine::eval
55102
#endif

‎eval.cpp‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,19 @@ TUNE(SetRange(0, 30),
6969
isolatedPawnMg,
7070
SetRange(0, 40),
7171
isolatedPawnEg);
72-
TUNE(SetRange(0, 200), passedBonusMg[1],passedBonusMg[2],passedBonusMg[3],passedBonusMg[4],passedBonusMg[5],passedBonusMg[6], passedBonusEg[1],passedBonusEg[2],passedBonusEg[3],passedBonusEg[4],passedBonusEg[5],passedBonusEg[6]);
72+
TUNE(SetRange(0, 200),
73+
passedBonusMg[1],
74+
passedBonusMg[2],
75+
passedBonusMg[3],
76+
passedBonusMg[4],
77+
passedBonusMg[5],
78+
passedBonusMg[6],
79+
passedBonusEg[1],
80+
passedBonusEg[2],
81+
passedBonusEg[3],
82+
passedBonusEg[4],
83+
passedBonusEg[5],
84+
passedBonusEg[6]);
7385
TUNE(SetRange(1, 30),
7486
kingShelterBaseMg,
7587
SetRange(1, 30),

‎eval.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
2-
#include <fwd_decl.h>
32
#include <cassert>
3+
#include <fwd_decl.h>
44
using Value = int;
55
namespace engine {
66

‎search.cpp‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ void update_pv(Move *pv, Move move, const Move *childPv) {
2727
// The function is called before storing a value in the transposition table.
2828
Value value_to_tt(Value v, int ply) { return is_win(v) ? v + ply : is_loss(v) ? v - ply : v; }
2929

30-
3130
// Inverse of value_to_tt(): it adjusts a mate or TB score from the transposition
3231
// table (which refers to the plies to mate/be mated from current position) to
3332
// "plies to mate/be mated (TB win/loss) from the root". However, to avoid
@@ -39,8 +38,7 @@ Value value_from_tt(Value v, int ply, int r50c) {
3938
return VALUE_NONE;
4039

4140
// handle TB win or better
42-
if (is_win(v))
43-
{
41+
if (is_win(v)) {
4442
// Downgrade a potentially false mate score
4543
if (is_mate(v) && VALUE_MATE - v > 100 - r50c)
4644
return VALUE_TB_WIN_IN_MAX_PLY - 1;
@@ -53,8 +51,7 @@ Value value_from_tt(Value v, int ply, int r50c) {
5351
}
5452

5553
// handle TB loss or worse
56-
if (is_loss(v))
57-
{
54+
if (is_loss(v)) {
5855
// Downgrade a potentially false mate score.
5956
if (is_mated(v) && VALUE_MATE + v > 100 - r50c)
6057
return VALUE_TB_LOSS_IN_MAX_PLY + 1;
@@ -256,7 +253,7 @@ Value doSearch(
256253

257254
// Null move pruning (skip when a mate threat is possible)
258255
if (depth >= 3 && !inCheck && ply > 0 && staticEval >= beta && !is_win(beta)) {
259-
int R = 2 + depth / 6;// + std::min(2, depth / 10);
256+
int R = 2 + depth / 6; // + std::min(2, depth / 10);
260257
board.doNullMove();
261258
Value score = doSearch(board, depth - 1 - R, -beta, -beta + 1, session, ply + 1, Move::none());
262259
board.undoMove();
@@ -319,8 +316,9 @@ Value doSearch(
319316
// Internal Iterative Deepening (IID): get a TT move when we don't have one
320317
if (depth >= 8 && ttMove == Move::none() && !inCheck && alpha != beta - 1) {
321318
int d = std::max(2, depth - 2 - depth / 4);
322-
Value v=doSearch(board, d, alpha, beta, session, ply, prevMove);
323-
if (v==VALUE_NONE) return VALUE_NONE;
319+
Value v = doSearch(board, d, alpha, beta, session, ply, prevMove);
320+
if (v == VALUE_NONE)
321+
return VALUE_NONE;
324322
if (TTEntry *e = search::tt.lookup(hash))
325323
ttMove = Move(e->getMove());
326324
}
@@ -359,7 +357,6 @@ Value doSearch(
359357
}
360358
}
361359

362-
363360
Value maxScore = -VALUE_INFINITE;
364361
int movesSearched = 0;
365362

0 commit comments

Comments
 (0)