stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
score.hpp (3869B)
0 #ifndef STELLAR_SCORE_H
1 #define STELLAR_SCORE_H
3 #define MAX_PLY 64
5 #define SCORE_INFINITY 32000
6 #define MATE_VALUE 31000
7 #define MATE_SCORE 30000
9 namespace score {
11 inline constexpr const uint16_t value[6] = {100, 300, 350, 500, 1000, 10000};
12 inline constexpr const uint16_t capture[6][6] = {
13 // clang-format off
14 {105, 205, 305, 405, 505, 605},
15 {104, 204, 304, 404, 504, 604},
16 {103, 203, 303, 403, 503, 603},
17 {102, 202, 302, 402, 502, 602},
18 {101, 201, 301, 401, 501, 601},
19 {100, 200, 300, 400, 500, 600},
20 // clang-format on
21 };
23 inline constexpr const int8_t position[6][64] = {
24 // clang-format off
25 {
26 0, 0, 0, 0, 0, 0, 0, 0,
27 0, 0, 0, -10, -10, 0, 0, 0,
28 0, 0, 0, 5, 5, 0, 0, 0,
29 5, 5, 10, 20, 20, 5, 5, 5,
30 10, 10, 10, 20, 20, 10, 10, 10,
31 20, 20, 20, 30, 30, 30, 20, 20,
32 30, 30, 30, 40, 40, 30, 30, 30,
33 90, 90, 90, 90, 90, 90, 90, 90
34 }, {
35 -5, -10 , 0, 0, 0, 0, -10, -5,
36 -5, 0, 0, 0, 0, 0, 0, -5,
37 -5, 5, 20, 10, 10, 20, 5, -5,
38 -5, 10, 20, 30, 30, 20, 10, -5,
39 -5, 10, 20, 30, 30, 20, 10, -5,
40 -5, 5, 20, 20, 20, 20, 5, -5,
41 -5, 0, 0, 10, 10, 0, 0, -5,
42 -5, 0, 0, 0, 0, 0, 0, -5
43 }, {
44 0, 0, -10, 0, 0, -10, 0, 0,
45 0, 30, 0, 0, 0, 0, 30, 0,
46 0, 10, 0, 0, 0, 0, 10, 0,
47 0, 0, 10, 20, 20, 10, 0, 0,
48 0, 0, 10, 20, 20, 10, 0, 0,
49 0, 0, 0, 10, 10, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 0, 0, 0, 0, 0, 0, 0
52 }, {
53 0, 0, 0, 20, 20, 0, 0, 0,
54 0, 0, 10, 20, 20, 10, 0, 0,
55 0, 0, 10, 20, 20, 10, 0, 0,
56 0, 0, 10, 20, 20, 10, 0, 0,
57 0, 0, 10, 20, 20, 10, 0, 0,
58 0, 0, 10, 20, 20, 10, 0, 0,
59 50, 50, 50, 50, 50, 50, 50, 50,
60 50, 50, 50, 50, 50, 50, 50, 50
61 }, {
62 0, 0, 0, 0, 0, 0, 0, 0,
63 0, 0, 0, 0, 0, 0, 0, 0,
64 0, 0, 0, 0, 0, 0, 0, 0,
65 0, 0, 0, 0, 0, 0, 0, 0,
66 0, 0, 0, 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0
70 }, {
71 0, 0, 5, 0, -15, 0, 10, 0,
72 0, 5, 5, -5, -5, 0, 5, 0,
73 0, 0, 5, 10, 10, 5, 0, 0,
74 0, 5, 10, 20, 20, 10, 5, 0,
75 0, 5, 10, 20, 20, 10, 5, 0,
76 0, 5, 5, 10, 10, 5, 5, 0,
77 0, 0, 5, 5, 5, 5, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0
79 },
80 // clang-format on
81 };
83 inline constexpr uint16_t get(const piece::Type piece) { return value[to_underlying(piece)]; }
84 inline constexpr uint16_t get(const piece::Type piece, const piece::Type captured) {
85 return capture[to_underlying(piece)][to_underlying(captured)];
86 }
88 inline constexpr int8_t get(const piece::Type type, const color::Color color, const square::Square square) {
89 uint8_t square_i = to_underlying(color == color::WHITE ? square : square::mirror(square));
90 return position[to_underlying(type)][square_i];
91 }
93 inline constexpr const uint8_t pawn_double = 10;
94 inline constexpr const uint8_t pawn_isolated = 10;
95 inline constexpr const std::array<std::array<int16_t, 8>, 2> pawn_passed = {
96 {{0, 10, 30, 50, 75, 100, 150, 200}, {200, 150, 100, 75, 50, 30, 10, 0}}};
98 inline constexpr const uint8_t score_open_semi = 10;
99 inline constexpr const uint8_t score_open = 15;
101 } // namespace score
103 #endif