case PH_NONCAPTURES:
lastMove = generate_noncaptures(pos, moves);
score_noncaptures();
- sort_moves(moves, lastMove);
+ sort_moves(moves, lastMove, &lastGoodNonCapture);
return;
case PH_BAD_CAPTURES:
piece = pos.piece_on(from);
hs = H.move_ordering_score(piece, to);
- // Ensure history is always preferred to pst
+ // Ensure history has always highest priority
if (hs > 0)
- hs += 1000;
+ hs += 10000;
- // pst based scoring
- cur->score = hs + mg_value(pos.pst_delta(piece, from, to));
+ // Gain table based scoring
+ cur->score = hs + 16 * H.gain(piece, to);
}
}
{
m = cur->move;
if ((seeScore = pos.see_sign(m)) < 0)
- cur->score = seeScore;
+ cur->score = seeScore - HistoryMax; // Be sure are at the bottom
else if (pos.move_is_capture(m))
cur->score = pos.midgame_value_of_piece_on(move_to(m))
- pos.type_of_piece_on(move_from(m)) + HistoryMax;
break;
case PH_NONCAPTURES:
+
+ // Sort negative scored moves only when we get there
+ if (curMove == lastGoodNonCapture)
+ insertion_sort(lastGoodNonCapture, lastMove);
+
move = (curMove++)->move;
if ( move != ttMoves[0].move
&& move != ttMoves[1].move