- template <bool PvNode> inline Depth reduction(bool i, Depth d, int mn) {
- return (Depth) Reductions[PvNode][i][std::min(int(d), 63)][std::min(mn, 63)];
- }
+ int level;
+ Move best = MOVE_NONE;
+ };
+
+ struct FastMove {
+ FastMove() { clear(); }
+
+ inline void clear() {
+ expectedPosKey = 0;
+ pv3[0] = pv3[1] = pv3[2] = MOVE_NONE;
+ stableCnt = 0;
+ }
+
+ void update(Position& pos) {
+ // Keep track how many times in a row the PV stays stable 3 ply deep.
+ const std::vector<Move>& RMpv = RootMoves[0].pv;
+ if (RMpv.size() >= 3)
+ {
+ if (pv3[2] == RMpv[2])
+ stableCnt++;
+ else
+ stableCnt = 0, pv3[2] = RMpv[2];
+
+ if (!expectedPosKey || pv3[0] != RMpv[0] || pv3[1] != RMpv[1])
+ {
+ pv3[0] = RMpv[0], pv3[1] = RMpv[1];
+ StateInfo st[2];
+ pos.do_move(RMpv[0], st[0], pos.gives_check(RMpv[0], CheckInfo(pos)));
+ pos.do_move(RMpv[1], st[1], pos.gives_check(RMpv[1], CheckInfo(pos)));
+ expectedPosKey = pos.key();
+ pos.undo_move(RMpv[1]);
+ pos.undo_move(RMpv[0]);
+ }
+ }
+ else
+ clear();
+ }
+
+ Key expectedPosKey;
+ Move pv3[3];
+ int stableCnt;
+ } FM;