stellarUCI Chess engine written in C++20 |
git clone git://git.dimitrijedobrota.com/stellar.git |
Log | Files | Refs | README | LICENSE |
commit | 983476a7948c7dc9e50234854e6e1b8a2714e2ee |
parent | d26899b9c7d9382a76489e893907a2e4be8aac7b |
author | Dimitrije Dobrota <mail@dimitrijedobrota.com> |
date | Sat, 23 Sep 2023 23:14:29 +0000 |
Better interpolation, different ttable
Diffstat:M | CMakeLists.txt | | | +- |
M | src/engine/engine.cpp | | | +- |
M | src/engine/evaluate.cpp | | | ++++++++++++++++--------- |
M | src/engine/score.hpp | | | ++++++--- |
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(
Stellar
VERSION 9.0.0
VERSION 9.0.2
DESCRIPTION "Chess engine written in C++"
HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git
LANGUAGES CXX
diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp
@@ -389,7 +389,7 @@ Move search_position(const uci::Settings &settingsr) {
settings = &settingsr;
if (settings->newgame) {
ttable = TTable(C64(0x1000000));
ttable = TTable(C64(0x2FB4377));
}
rtable.clear();
diff --git a/src/engine/evaluate.cpp b/src/engine/evaluate.cpp
@@ -71,8 +71,8 @@ using piece::Type::PAWN;
using piece::Type::QUEEN;
using piece::Type::ROOK;
using score::Phase::OPENING;
using score::Phase::ENDGAME;
using score::Phase::OPENING;
uint16_t score_game_phase(const Board &board) {
int16_t total = 0;
@@ -86,10 +86,7 @@ uint16_t score_game_phase(const Board &board) {
int16_t score_position_side(const Board &board, const color::Color side, const uint16_t phase_score) {
U64 bitboard;
int16_t total = 0;
int16_t opening = 0;
int16_t endgame = 0;
int16_t total = 0, opening = 0, endgame = 0;
int8_t square_i;
const uint8_t side_i = to_underlying(side);
@@ -105,8 +102,16 @@ int16_t score_position_side(const Board &board, const color::Color side, const u
// check isolated, doubled and passed pawns
const uint8_t file = square::file(square), rank = square::rank(square);
if (!(mask_isolated[file] & pawnsS)) total -= score::pawn_isolated;
if (bit::count(pawnsS & mask_file[file]) > 1) total -= score::pawn_double;
if (!(mask_isolated[file] & pawnsS)) {
opening -= score::pawn_isolated_opening;
endgame -= score::pawn_isolated_endgame;
}
if (bit::count(pawnsS & mask_file[file]) > 1) {
opening -= score::pawn_double_opening;
endgame -= score::pawn_double_endgame;
}
if (!(pawnsO & mask_passed[side_i][square_i])) total += score::pawn_passed[side_i][rank];
}
@@ -155,8 +160,10 @@ int16_t score_position_side(const Board &board, const color::Color side, const u
if (!(pawnsS & mask_file[file])) total -= score::file_open_semi;
}
total = score::interpolate(phase_score, opening, endgame);
return total;
opening += total, endgame += total;
if (phase_score > score::phase_opening) return opening;
if (phase_score < score::phase_endgame) return endgame;
return score::interpolate(phase_score, opening, endgame);
}
int16_t score_position(const Board &board) {
diff --git a/src/engine/score.hpp b/src/engine/score.hpp
@@ -150,13 +150,16 @@ inline constexpr int16_t get(const piece::Type piece, const Phase phase = OPENIN
}
inline constexpr int16_t get(const piece::Type piece, const color::Color color, const square::Square square,
const Phase phase = ENDGAME) {
const Phase phase = ENDGAME) {
uint8_t square_i = to_underlying(color == color::WHITE ? square : square::mirror(square));
return position[to_underlying(phase)][to_underlying(piece)][square_i];
}
inline constexpr const uint8_t pawn_double = 10;
inline constexpr const uint8_t pawn_isolated = 10;
inline constexpr const uint8_t pawn_double_opening = 5;
inline constexpr const uint8_t pawn_double_endgame = 10;
inline constexpr const uint8_t pawn_isolated_opening = 5;
inline constexpr const uint8_t pawn_isolated_endgame = 10;
inline constexpr const std::array<std::array<int16_t, 8>, 2> pawn_passed = {
{{0, 10, 30, 50, 75, 100, 150, 200}, {200, 150, 100, 75, 50, 30, 10, 0}}};