mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 07:27:46 +00:00
Fix issue #1268
If the search is quit before skill.pick_best is called, skill.best_move might be MOVE_NONE. Ensure skill.best is always assigned anyhow. Also retire the tricky best_move() and let the underlying semantic to be clear and explicit. No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
43c186c645
commit
9d79138682
+4
-5
@@ -87,10 +87,9 @@ namespace {
|
|||||||
|
|
||||||
// Skill structure is used to implement strength limit
|
// Skill structure is used to implement strength limit
|
||||||
struct Skill {
|
struct Skill {
|
||||||
Skill(int l) : level(l) {}
|
explicit Skill(int l) : level(l) {}
|
||||||
bool enabled() const { return level < 20; }
|
bool enabled() const { return level < 20; }
|
||||||
bool time_to_pick(Depth depth) const { return depth / ONE_PLY == 1 + level; }
|
bool time_to_pick(Depth depth) const { return depth / ONE_PLY == 1 + level; }
|
||||||
Move best_move(size_t multiPV) { return best ? best : pick_best(multiPV); }
|
|
||||||
Move pick_best(size_t multiPV);
|
Move pick_best(size_t multiPV);
|
||||||
|
|
||||||
int level;
|
int level;
|
||||||
@@ -514,8 +513,8 @@ void Thread::search() {
|
|||||||
|
|
||||||
// If skill level is enabled, swap best PV line with the sub-optimal one
|
// If skill level is enabled, swap best PV line with the sub-optimal one
|
||||||
if (skill.enabled())
|
if (skill.enabled())
|
||||||
std::swap(rootMoves[0], *std::find(rootMoves.begin(),
|
std::swap(rootMoves[0], *std::find(rootMoves.begin(), rootMoves.end(),
|
||||||
rootMoves.end(), skill.best_move(multiPV)));
|
skill.best ? skill.best : skill.pick_best(multiPV)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1451,7 +1450,7 @@ moves_loop: // When in check search starts from here
|
|||||||
int push = ( weakness * int(topScore - rootMoves[i].score)
|
int push = ( weakness * int(topScore - rootMoves[i].score)
|
||||||
+ delta * (rng.rand<unsigned>() % weakness)) / 128;
|
+ delta * (rng.rand<unsigned>() % weakness)) / 128;
|
||||||
|
|
||||||
if (rootMoves[i].score + push > maxScore)
|
if (rootMoves[i].score + push >= maxScore)
|
||||||
{
|
{
|
||||||
maxScore = rootMoves[i].score + push;
|
maxScore = rootMoves[i].score + push;
|
||||||
best = rootMoves[i].pv[0];
|
best = rootMoves[i].pv[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user