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