+
+ // slowdown() simply wastes CPU cycles doing nothing useful. It's used
+ // in strength handicap mode.
+
+ void slowdown(const Position &pos) {
+ int i, n;
+ n = Slowdown;
+ for (i = 0; i < n; i++) {
+ Square s = Square(i&63);
+ if (count_1s(pos.attacks_to(s)) > 63)
+ std::cout << "This can't happen, but I put this string here anyway, in order to prevent the compiler from optimizing away the useless computation." << std::endl;
+ }
+ }
+
+
+ // build_pv() extends a PV by adding moves from the transposition table at
+ // the end. This should ensure that the PV is almost always at least two
+ // plies long, which is important, because otherwise we will often get
+ // single-move PVs when the search stops while failing high, and a
+ // single-move PV means that we don't have a ponder move.
+
+ void build_pv(const Position& pos, Move pv[]) {
+ int ply;
+ Position p(pos);
+ StateInfo st[100];
+
+ for (ply = 0; pv[ply] != MOVE_NONE; ply++)
+ p.do_move(pv[ply], st[ply]);
+
+ bool stop;
+ const TTEntry* tte;
+ for (stop = false, tte = TT.retrieve(p.get_key());
+ tte && tte->move() != MOVE_NONE && !stop;
+ tte = TT.retrieve(p.get_key()), ply++)
+ {
+ if (!move_is_legal(p, tte->move(), p.pinned_pieces(p.side_to_move())))
+ break;
+ pv[ply] = tte->move();
+ p.do_move(pv[ply], st[ply]);
+ for (int j = 0; j < ply; j++)
+ if (st[j].key == p.get_key()) stop = true;
+ }
+ pv[ply] = MOVE_NONE;
+ }
+
+