@@ -870,10 +870,12 @@ namespace {
870870moves_loop: // When in check search starts from here
871871
872872 Square prevSq = to_sq ((ss-1 )->currentMove );
873+ Square ownPrevSq = to_sq ((ss-2 )->currentMove );
873874 Move cm = thisThread->counterMoves [pos.piece_on (prevSq)][prevSq];
874875 const CounterMoveStats& cmh = CounterMoveHistory[pos.piece_on (prevSq)][prevSq];
876+ const CounterMoveStats& fmh = CounterMoveHistory[pos.piece_on (ownPrevSq)][ownPrevSq];
875877
876- MovePicker mp (pos, ttMove, depth, thisThread->history , cmh, cm, ss);
878+ MovePicker mp (pos, ttMove, depth, thisThread->history , cmh, fmh, cm, ss);
877879 CheckInfo ci (pos);
878880 value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
879881 improving = ss->staticEval >= (ss-2 )->staticEval
@@ -1442,7 +1444,9 @@ namespace {
14421444 Value bonus = Value ((depth / ONE_PLY) * (depth / ONE_PLY) + depth / ONE_PLY - 1 );
14431445
14441446 Square prevSq = to_sq ((ss-1 )->currentMove );
1447+ Square ownPrevSq = to_sq ((ss-2 )->currentMove );
14451448 CounterMoveStats& cmh = CounterMoveHistory[pos.piece_on (prevSq)][prevSq];
1449+ CounterMoveStats& fmh = CounterMoveHistory[pos.piece_on (ownPrevSq)][ownPrevSq];
14461450 Thread* thisThread = pos.this_thread ();
14471451
14481452 thisThread->history .update (pos.moved_piece (move), to_sq (move), bonus);
@@ -1453,13 +1457,19 @@ namespace {
14531457 cmh.update (pos.moved_piece (move), to_sq (move), bonus);
14541458 }
14551459
1460+ if (is_ok ((ss-2 )->currentMove ))
1461+ fmh.update (pos.moved_piece (move), to_sq (move), bonus);
1462+
14561463 // Decrease all the other played quiet moves
14571464 for (int i = 0 ; i < quietsCnt; ++i)
14581465 {
14591466 thisThread->history .update (pos.moved_piece (quiets[i]), to_sq (quiets[i]), -bonus);
14601467
14611468 if (is_ok ((ss-1 )->currentMove ))
14621469 cmh.update (pos.moved_piece (quiets[i]), to_sq (quiets[i]), -bonus);
1470+
1471+ if (is_ok ((ss-2 )->currentMove ))
1472+ fmh.update (pos.moved_piece (quiets[i]), to_sq (quiets[i]), -bonus);
14631473 }
14641474
14651475 // Extra penalty for a quiet TT move in previous ply when it gets refuted
0 commit comments