mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Adding LowestElo and HighestElo constants
These values represent the lowest Elo rating in the skill level calculation, and the highest one, but it's not clear from the code where these values come from other than the comment. This should improve code readability and maintainability. It makes the purpose of the values clear and allows for easy modification if the Elo range for skill level calculation changes in the future. Moved the Skill struct definition from search.cpp to search.h header file to define the Search::Skill struct, making it accessible from other files. closes https://github.com/official-stockfish/Stockfish/pull/5508 No functional change
This commit is contained in:
parent
a2ba3e3362
commit
986173264f
3 changed files with 32 additions and 26 deletions
|
@ -91,7 +91,9 @@ Engine::Engine(std::string path) :
|
|||
options["nodestime"] << Option(0, 0, 10000);
|
||||
options["UCI_Chess960"] << Option(false);
|
||||
options["UCI_LimitStrength"] << Option(false);
|
||||
options["UCI_Elo"] << Option(1320, 1320, 3190);
|
||||
options["UCI_Elo"] << Option(Stockfish::Search::Skill::LowestElo,
|
||||
Stockfish::Search::Skill::LowestElo,
|
||||
Stockfish::Search::Skill::HighestElo);
|
||||
options["UCI_ShowWDL"] << Option(false);
|
||||
options["SyzygyPath"] << Option("", [](const Option& o) {
|
||||
Tablebases::init(o);
|
||||
|
|
|
@ -94,31 +94,6 @@ int stat_malus(Depth d) { return std::min(736 * d - 268, 2044); }
|
|||
|
||||
// Add a small random component to draw evaluations to avoid 3-fold blindness
|
||||
Value value_draw(size_t nodes) { return VALUE_DRAW - 1 + Value(nodes & 0x2); }
|
||||
|
||||
// Skill structure is used to implement strength limit. If we have a UCI_Elo,
|
||||
// we convert it to an appropriate skill level, anchored to the Stash engine.
|
||||
// This method is based on a fit of the Elo results for games played between
|
||||
// Stockfish at various skill levels and various versions of the Stash engine.
|
||||
// Skill 0 .. 19 now covers CCRL Blitz Elo from 1320 to 3190, approximately
|
||||
// Reference: https://github.com/vondele/Stockfish/commit/a08b8d4e9711c2
|
||||
struct Skill {
|
||||
Skill(int skill_level, int uci_elo) {
|
||||
if (uci_elo)
|
||||
{
|
||||
double e = double(uci_elo - 1320) / (3190 - 1320);
|
||||
level = std::clamp((((37.2473 * e - 40.8525) * e + 22.2943) * e - 0.311438), 0.0, 19.0);
|
||||
}
|
||||
else
|
||||
level = double(skill_level);
|
||||
}
|
||||
bool enabled() const { return level < 20.0; }
|
||||
bool time_to_pick(Depth depth) const { return depth == 1 + int(level); }
|
||||
Move pick_best(const RootMoves&, size_t multiPV);
|
||||
|
||||
double level;
|
||||
Move best = Move::none();
|
||||
};
|
||||
|
||||
Value value_to_tt(Value v, int ply);
|
||||
Value value_from_tt(Value v, int ply, int r50c);
|
||||
void update_pv(Move* pv, Move move, const Move* childPv);
|
||||
|
|
29
src/search.h
29
src/search.h
|
@ -19,6 +19,7 @@
|
|||
#ifndef SEARCH_H_INCLUDED
|
||||
#define SEARCH_H_INCLUDED
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
@ -180,6 +181,34 @@ struct InfoIteration {
|
|||
size_t currmovenumber;
|
||||
};
|
||||
|
||||
// Skill structure is used to implement strength limit. If we have a UCI_Elo,
|
||||
// we convert it to an appropriate skill level, anchored to the Stash engine.
|
||||
// This method is based on a fit of the Elo results for games played between
|
||||
// Stockfish at various skill levels and various versions of the Stash engine.
|
||||
// Skill 0 .. 19 now covers CCRL Blitz Elo from 1320 to 3190, approximately
|
||||
// Reference: https://github.com/vondele/Stockfish/commit/a08b8d4e9711c2
|
||||
struct Skill {
|
||||
// Lowest and highest Elo ratings used in the skill level calculation
|
||||
constexpr static int LowestElo = 1320;
|
||||
constexpr static int HighestElo = 3190;
|
||||
|
||||
Skill(int skill_level, int uci_elo) {
|
||||
if (uci_elo)
|
||||
{
|
||||
double e = double(uci_elo - LowestElo) / (HighestElo - LowestElo);
|
||||
level = std::clamp((((37.2473 * e - 40.8525) * e + 22.2943) * e - 0.311438), 0.0, 19.0);
|
||||
}
|
||||
else
|
||||
level = double(skill_level);
|
||||
}
|
||||
bool enabled() const { return level < 20.0; }
|
||||
bool time_to_pick(Depth depth) const { return depth == 1 + int(level); }
|
||||
Move pick_best(const RootMoves&, size_t multiPV);
|
||||
|
||||
double level;
|
||||
Move best = Move::none();
|
||||
};
|
||||
|
||||
// SearchManager manages the search from the main thread. It is responsible for
|
||||
// keeping track of the time, and storing data strictly related to the main thread.
|
||||
class SearchManager: public ISearchManager {
|
||||
|
|
Loading…
Add table
Reference in a new issue