+ void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt) {
+
+ if (ss->killers[0] != move)
+ {
+ ss->killers[1] = ss->killers[0];
+ ss->killers[0] = move;
+ }
+
+ // Increase history value of the cut-off move and decrease all the other
+ // played quiet moves.
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
+ History.update(pos.moved_piece(move), to_sq(move), bonus);
+ for (int i = 0; i < quietsCnt; ++i)
+ {
+ Move m = quiets[i];
+ History.update(pos.moved_piece(m), to_sq(m), -bonus);
+ }
+
+ if (is_ok((ss-1)->currentMove))
+ {
+ Square prevMoveSq = to_sq((ss-1)->currentMove);
+ Countermoves.update(pos.piece_on(prevMoveSq), prevMoveSq, move);
+ }
+
+ if (is_ok((ss-2)->currentMove) && (ss-1)->currentMove == (ss-1)->ttMove)
+ {
+ Square prevOwnMoveSq = to_sq((ss-2)->currentMove);
+ Followupmoves.update(pos.piece_on(prevOwnMoveSq), prevOwnMoveSq, move);
+ }
+ }
+
+
+ // When playing with a strength handicap, choose best move among the first 'candidates'
+ // RootMoves using a statistical rule dependent on 'level'. Idea by Heinz van Saanen.
+
+ Move Skill::pick_move() {
+
+ // PRNG sequence should be non-deterministic, so we seed it with the time at init
+ static PRNG rng(Time::now());