1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Merge branch 'master' into master

This commit is contained in:
nodchip 2020-06-28 11:42:23 +09:00 committed by GitHub
commit 123dd68452
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 27 deletions

View file

@ -160,8 +160,8 @@ endif
ifeq ($(ARCH),armv8) ifeq ($(ARCH),armv8)
arch = armv8-a arch = armv8-a
bits = 64
prefetch = yes prefetch = yes
popcnt = yes
endif endif
ifeq ($(ARCH),ppc-32) ifeq ($(ARCH),ppc-32)
@ -370,8 +370,8 @@ endif
### 3.6 popcnt ### 3.6 popcnt
ifeq ($(popcnt),yes) ifeq ($(popcnt),yes)
ifeq ($(arch),ppc64) ifeq ($(arch),$(filter $(arch),ppc64 armv8-a))
CXXFLAGS += -DUSE_POPCNT -DUSE_SSE2 CXXFLAGS += -DUSE_POPCNT
else ifeq ($(comp),icc) else ifeq ($(comp),icc)
CXXFLAGS += -msse3 -DUSE_POPCNT -DUSE_SSE2 CXXFLAGS += -msse3 -DUSE_POPCNT -DUSE_SSE2
else else
@ -399,10 +399,20 @@ endif
### needs access to the optimization flags. ### needs access to the optimization flags.
ifeq ($(optimize),yes) ifeq ($(optimize),yes)
ifeq ($(debug), no) ifeq ($(debug), no)
ifeq ($(comp),$(filter $(comp),gcc clang mingw)) ifeq ($(comp),$(filter $(comp),gcc clang))
CXXFLAGS += -flto CXXFLAGS += -flto
LDFLAGS += $(CXXFLAGS) LDFLAGS += $(CXXFLAGS)
endif endif
# To use LTO and static linking on windows, the tool chain requires a recent gcc:
# gcc version 10.1 in msys2 or TDM-GCC version 9.2 are know to work, older might not.
# So, only enable it for a cross from Linux by default.
ifeq ($(comp),mingw)
ifeq ($(KERNEL),Linux)
CXXFLAGS += -flto
LDFLAGS += $(CXXFLAGS)
endif
endif
endif endif
endif endif

View file

@ -7,6 +7,8 @@
#if defined(USE_AVX2) #if defined(USE_AVX2)
#include <immintrin.h> #include <immintrin.h>
#elif defined(USE_SSE41)
#include <smmintrin.h>
#elif defined(USE_SSE2) #elif defined(USE_SSE2)
#include <emmintrin.h> #include <emmintrin.h>
#endif #endif

View file

@ -1028,24 +1028,10 @@ double sigmoid(double x)
// A function that converts the evaluation value to the winning rate [0,1] // A function that converts the evaluation value to the winning rate [0,1]
double winning_percentage(double value) double winning_percentage(double value)
{ {
// In Maxima, // 1/(1+10^(-Eval/4))
// load("C:/maxima-5.44.0/cform.lisp"); // = 1/(1+e^(-Eval/4*ln(10))
// PawnValueEg = 206; // = sigmoid(Eval/4*ln(10))
// cform(1.0 / (1.0 + 10.0 ^ (-value / PawnValueEg / 4.0))); return sigmoid(value / PawnValueEg / 4.0 * log(10.0));
constexpr double PawnValue = PawnValueEg;
return 1.0 * pow(pow(10.0, -0.25 * pow(PawnValue, -1) * value) + 1.0, -1);
}
double delta_winning_percentage(double value)
{
// In Maxima,
// load("C:/maxima-5.44.0/cform.lisp");
// PawnValueEg = 206;
// cform(diff(1.0/(1.0+10.0^(-value/PawnValue/4.0)),value));
constexpr double PawnValue = PawnValueEg;
return
0.5756462732485115 * pow(PawnValue, -1) * pow(10.0, -0.25 * pow(PawnValue, -1) * value) *
pow(pow(10.0, -0.25 * pow(PawnValue, -1) * value) + 1.0, -2);
} }
double dsigmoid(double x) double dsigmoid(double x)
{ {
@ -1143,7 +1129,6 @@ double calc_grad(Value deep, Value shallow , const PackedSfenValue& psv)
const double q = winning_percentage(shallow); const double q = winning_percentage(shallow);
const double p = winning_percentage(deep); const double p = winning_percentage(deep);
const double dq = delta_winning_percentage(shallow);
// Use 1 as the correction term if the expected win rate is 1, 0 if you lose, and 0.5 if you draw. // Use 1 as the correction term if the expected win rate is 1, 0 if you lose, and 0.5 if you draw.
// game_result = 1,0,-1 so add 1 and divide by 2. // game_result = 1,0,-1 so add 1 and divide by 2.
@ -1154,9 +1139,7 @@ double calc_grad(Value deep, Value shallow , const PackedSfenValue& psv)
// Use the actual win rate as a correction term. // Use the actual win rate as a correction term.
// This is the idea of elmo (WCSC27), modern O-parts. // This is the idea of elmo (WCSC27), modern O-parts.
const double pp = (q - p) * dq / q / (1.0 - q); const double grad = lambda * (q - p) + (1.0 - lambda) * (q - t);
const double tt = (q - t) * dq / q / (1.0 - q);
const double grad = lambda * pp + (1.0 - lambda) * tt;
return grad; return grad;
} }

View file

@ -92,7 +92,7 @@ struct LimitsType {
} }
bool use_time_management() const { bool use_time_management() const {
return !(mate | movetime | depth | nodes | perft | infinite); return time[WHITE] || time[BLACK];
} }
std::vector<Move> searchmoves; std::vector<Move> searchmoves;