mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Move smallnet threshold logic into a function
Now that the smallnet threshold is no longer a constant, use a function to organize it with other eval code. Passed non-regression STC: https://tests.stockfishchess.org/tests/view/66459fa093ce6da3e93b5ba2 LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 217600 W: 56281 L: 56260 D: 105059 Ptnml(0-2): 756, 23787, 59729, 23736, 792 closes https://github.com/official-stockfish/Stockfish/pull/5255 No functional change
This commit is contained in:
parent
1b7dea3f85
commit
d92d1f3180
3 changed files with 7 additions and 6 deletions
|
@ -44,6 +44,10 @@ int Eval::simple_eval(const Position& pos, Color c) {
|
||||||
+ (pos.non_pawn_material(c) - pos.non_pawn_material(~c));
|
+ (pos.non_pawn_material(c) - pos.non_pawn_material(~c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Eval::use_smallnet(const Position& pos) {
|
||||||
|
int simpleEval = simple_eval(pos, pos.side_to_move());
|
||||||
|
return std::abs(simpleEval) > 1126 + 6 * pos.count<PAWN>();
|
||||||
|
}
|
||||||
|
|
||||||
// Evaluate is the evaluator for the outer world. It returns a static evaluation
|
// Evaluate is the evaluator for the outer world. It returns a static evaluation
|
||||||
// of the position from the point of view of the side to move.
|
// of the position from the point of view of the side to move.
|
||||||
|
@ -55,7 +59,7 @@ Value Eval::evaluate(const Eval::NNUE::Networks& networks,
|
||||||
assert(!pos.checkers());
|
assert(!pos.checkers());
|
||||||
|
|
||||||
int simpleEval = simple_eval(pos, pos.side_to_move());
|
int simpleEval = simple_eval(pos, pos.side_to_move());
|
||||||
bool smallNet = std::abs(simpleEval) > SmallNetThreshold + 6 * pos.count<PAWN>();
|
bool smallNet = use_smallnet(pos);
|
||||||
int nnueComplexity;
|
int nnueComplexity;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,6 @@ class Position;
|
||||||
|
|
||||||
namespace Eval {
|
namespace Eval {
|
||||||
|
|
||||||
constexpr inline int SmallNetThreshold = 1126;
|
|
||||||
|
|
||||||
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
|
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
|
||||||
// for the build process (profile-build and fishtest) to work. Do not change the
|
// for the build process (profile-build and fishtest) to work. Do not change the
|
||||||
// name of the macro or the location where this macro is defined, as it is used
|
// name of the macro or the location where this macro is defined, as it is used
|
||||||
|
@ -46,6 +44,7 @@ struct AccumulatorCaches;
|
||||||
std::string trace(Position& pos, const Eval::NNUE::Networks& networks);
|
std::string trace(Position& pos, const Eval::NNUE::Networks& networks);
|
||||||
|
|
||||||
int simple_eval(const Position& pos, Color c);
|
int simple_eval(const Position& pos, Color c);
|
||||||
|
bool use_smallnet(const Position& pos);
|
||||||
Value evaluate(const NNUE::Networks& networks,
|
Value evaluate(const NNUE::Networks& networks,
|
||||||
const Position& pos,
|
const Position& pos,
|
||||||
Eval::NNUE::AccumulatorCaches& caches,
|
Eval::NNUE::AccumulatorCaches& caches,
|
||||||
|
|
|
@ -45,9 +45,7 @@ constexpr std::string_view PieceToChar(" PNBRQK pnbrqk");
|
||||||
void hint_common_parent_position(const Position& pos,
|
void hint_common_parent_position(const Position& pos,
|
||||||
const Networks& networks,
|
const Networks& networks,
|
||||||
AccumulatorCaches& caches) {
|
AccumulatorCaches& caches) {
|
||||||
|
if (Eval::use_smallnet(pos))
|
||||||
int simpleEvalAbs = std::abs(simple_eval(pos, pos.side_to_move()));
|
|
||||||
if (simpleEvalAbs > Eval::SmallNetThreshold + 6 * pos.count<PAWN>())
|
|
||||||
networks.small.hint_common_access(pos, &caches.small);
|
networks.small.hint_common_access(pos, &caches.small);
|
||||||
else
|
else
|
||||||
networks.big.hint_common_access(pos, &caches.big);
|
networks.big.hint_common_access(pos, &caches.big);
|
||||||
|
|
Loading…
Add table
Reference in a new issue