summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
43c186c)
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.
// Skill structure is used to implement strength limit
struct Skill {
// Skill structure is used to implement strength limit
struct Skill {
- Skill(int l) : level(l) {}
+ explicit Skill(int l) : level(l) {}
bool enabled() const { return level < 20; }
bool time_to_pick(Depth depth) const { return depth / ONE_PLY == 1 + level; }
bool enabled() const { return level < 20; }
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);
int level;
Move pick_best(size_t multiPV);
int level;
// If skill level is enabled, swap best PV line with the sub-optimal one
if (skill.enabled())
// If skill level is enabled, swap best PV line with the sub-optimal one
if (skill.enabled())
- std::swap(rootMoves[0], *std::find(rootMoves.begin(),
- rootMoves.end(), skill.best_move(multiPV)));
+ std::swap(rootMoves[0], *std::find(rootMoves.begin(), rootMoves.end(),
+ skill.best ? skill.best : skill.pick_best(multiPV)));
int push = ( weakness * int(topScore - rootMoves[i].score)
+ delta * (rng.rand<unsigned>() % weakness)) / 128;
int push = ( weakness * int(topScore - rootMoves[i].score)
+ delta * (rng.rand<unsigned>() % weakness)) / 128;
- if (rootMoves[i].score + push > maxScore)
+ if (rootMoves[i].score + push >= maxScore)
{
maxScore = rootMoves[i].score + push;
best = rootMoves[i].pv[0];
{
maxScore = rootMoves[i].score + push;
best = rootMoves[i].pv[0];