stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE | |
commit | c16369677bc656d2d9b17038f4697b2610dc8156 |
parent | 1ff71a3e91b2e585290398b06794a5c5414d4a8a |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Mon, 20 May 2024 17:49:51 +0200 |
Fix constexpr issue with older compiler
Diffstat:M | CMakeLists.txt | | | +- |
M | src/board/board.hpp | | | ++++++------ |
M | src/board/zobrist.hpp | | | +++++----- |
M | src/utils/utils_ui.hpp | | | ++++---- |
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
Stellar
VERSION 1.4.0
VERSION 1.4.1
DESCRIPTION "Chess engine written in C++"
HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git
LANGUAGES CXX
diff --git a/src/board/board.hpp b/src/board/board.hpp
@@ -52,9 +52,9 @@ class Board {
inline constexpr void xor_hash(U64 op);
inline constexpr void xor_hash_pawn(U32 op);
inline constexpr void switch_side();
inline constexpr void and_castle(uint8_t right);
inline constexpr void set_enpassant(Square target);
inline void switch_side();
inline void and_castle(uint8_t right);
inline void set_enpassant(Square target);
inline constexpr void pop_bitboard_color(Color color, Square square);
inline constexpr void set_bitboard_color(Color color, Square square);
@@ -123,18 +123,18 @@ constexpr Type Board::get_square_piece_type(Square square) const {
constexpr void Board::xor_hash(U64 op) { hash ^= op; }
constexpr void Board::xor_hash_pawn(U32 op) { hash_pawn ^= op; }
constexpr void Board::and_castle(uint8_t right) {
void Board::and_castle(uint8_t right) {
hash ^= zobrist::key_castle(castle);
castle &= right;
hash ^= zobrist::key_castle(castle);
}
constexpr void Board::switch_side() {
void Board::switch_side() {
side = other(side);
hash ^= zobrist::key_side();
}
constexpr void Board::set_enpassant(Square target) {
void Board::set_enpassant(Square target) {
if (enpassant != Square::no_sq) hash ^= zobrist::key_enpassant(enpassant);
if (target != Square::no_sq) hash ^= zobrist::key_enpassant(target);
enpassant = target;
diff --git a/src/board/zobrist.hpp b/src/board/zobrist.hpp
@@ -48,11 +48,11 @@ inline void init() {
inline U64 hash(const Board &board);
inline U32 hash_pawn(const Board &board);
inline constexpr U64 key_side() { return keys_side; }
inline constexpr U64 key_castle(int exp) { return keys_castle[exp]; }
inline constexpr U64 key_enpassant(Square square) { return keys_enpassant[square]; }
inline constexpr U64 key_pawn(Color color, Square square) { return keys_pawn[color][square]; }
inline constexpr U64 key_piece(Type type, Color color, Square square) {
inline U64 key_side() { return keys_side; }
inline U64 key_castle(int exp) { return keys_castle[exp]; }
inline U64 key_enpassant(Square square) { return keys_enpassant[square]; }
inline U64 key_pawn(Color color, Square square) { return keys_pawn[color][square]; }
inline U64 key_piece(Type type, Color color, Square square) {
return keys_piece[color][type][square];
}
diff --git a/src/utils/utils_ui.hpp b/src/utils/utils_ui.hpp
@@ -7,13 +7,13 @@
/* Color */
constexpr const std::string to_string(const Color color) {
static const std::string to_string(const Color color) {
return std::string(color == WHITE ? "white" : "black");
}
/* Square */
constexpr const char *coordinates_array[] = {
static const char *coordinates_array[] = {
// clang-format off
"a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1",
"a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2",
@@ -26,9 +26,9 @@ constexpr const char *coordinates_array[] = {
// clang-format on
};
constexpr const std::string to_coordinates(const Square square) { return coordinates_array[square]; }
static const std::string to_coordinates(const Square square) { return coordinates_array[square]; }
constexpr Square from_coordinates(const std::string &cord) {
static Square from_coordinates(const std::string &cord) {
return static_cast<Square>((cord[1] - '1') * 8 + (cord[0] - 'a'));
}