+ struct Skill {
+ Skill(int l) : level(l), best(MOVE_NONE) {}
+ ~Skill() {
+ if (enabled()) // Swap best PV line with the sub-optimal one
+ std::swap(RootMoves[0], *std::find(RootMoves.begin(),
+ RootMoves.end(), best ? best : pick_move()));
+ }
+
+ bool enabled() const { return level < 20; }
+ bool time_to_pick(int depth) const { return depth == 1 + level; }
+ Move pick_move();
+
+ int level;
+ Move best;
+ };
+