summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1b08887)
In MovePicker consider killer moves as a separate
phase from non-capture picking.
Note that this change guarantees that killer1 is always
tried before killer2. Until now, because scoring difference
of the two moves was just 1 point, if psqt tables of killer1
gave a lower value then killer2, the latter was tried as first.
After 999 games at 1+0 we have
Mod vs Orig: +245 =527 -227 +6 ELO
Not a lot but patch is anyhow something worth to have.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
assert(pinned == pos.pinned_pieces(pos.side_to_move()));
Color us = pos.side_to_move();
assert(pinned == pos.pinned_pieces(pos.side_to_move()));
Color us = pos.side_to_move();
- Color them = opposite_color(us);
Square from = move_from(m);
Piece pc = pos.piece_on(from);
Square from = move_from(m);
Piece pc = pos.piece_on(from);
if (color_of_piece(pc) != us)
return false;
if (color_of_piece(pc) != us)
return false;
+ Color them = opposite_color(us);
Square to = move_to(m);
// En passant moves
Square to = move_to(m);
// En passant moves
movesPicked = 0;
numOfMoves = 0;
numOfBadCaptures = 0;
movesPicked = 0;
numOfMoves = 0;
numOfBadCaptures = 0;
+ checkKillers = checkLegal = false;
if (p.is_check())
phaseIndex = EvasionsPhaseIndex;
if (p.is_check())
phaseIndex = EvasionsPhaseIndex;
score_captures();
std::sort(moves, moves + numOfMoves);
movesPicked = 0;
score_captures();
std::sort(moves, moves + numOfMoves);
movesPicked = 0;
- case PH_BAD_CAPTURES:
- // It's probably a good idea to use SEE move ordering here. FIXME
- movesPicked = 0;
+ case PH_KILLERS:
+ movesPicked = numOfMoves = 0;
+ checkLegal = false;
+ if (killer1 != MOVE_NONE && move_is_legal(pos, killer1, pinned) && !pos.move_is_capture(killer1))
+ moves[numOfMoves++].move = killer1;
+ if (killer2 != MOVE_NONE && move_is_legal(pos, killer2, pinned) && !pos.move_is_capture(killer2) )
+ moves[numOfMoves++].move = killer2;
break;
case PH_NONCAPTURES:
break;
case PH_NONCAPTURES:
+ checkKillers = (numOfMoves != 0); // previous phase is PH_KILLERS
numOfMoves = generate_noncaptures(pos, moves);
score_noncaptures();
std::sort(moves, moves + numOfMoves);
movesPicked = 0;
numOfMoves = generate_noncaptures(pos, moves);
score_noncaptures();
std::sort(moves, moves + numOfMoves);
movesPicked = 0;
+ checkLegal = true;
+ break;
+
+ case PH_BAD_CAPTURES:
+ // It's probably a good idea to use SEE move ordering here. FIXME
+ movesPicked = 0;
for (int i = 0; i < numOfMoves; i++)
{
m = moves[i].move;
for (int i = 0; i < numOfMoves; i++)
{
m = moves[i].move;
-
- if (m == killer1)
- hs = HistoryMax + 2;
- else if (m == killer2)
- hs = HistoryMax + 1;
- else
- hs = H.move_ordering_score(pos.piece_on(move_from(m)), move_to(m));
+ hs = H.move_ordering_score(pos.piece_on(move_from(m)), move_to(m));
// Ensure history is always preferred to pst
if (hs > 0)
// Ensure history is always preferred to pst
if (hs > 0)
switch (PhaseTable[phaseIndex]) {
case PH_GOOD_CAPTURES:
switch (PhaseTable[phaseIndex]) {
case PH_GOOD_CAPTURES:
case PH_NONCAPTURES:
while (movesPicked < numOfMoves)
{
Move move = moves[movesPicked++].move;
if ( move != ttMove
&& move != mateKiller
case PH_NONCAPTURES:
while (movesPicked < numOfMoves)
{
Move move = moves[movesPicked++].move;
if ( move != ttMove
&& move != mateKiller
- && pos.pl_move_is_legal(move, pinned))
+ && (!checkKillers || (move != killer1 && move != killer2))
+ && (!checkLegal || pos.pl_move_is_legal(move, pinned)))
PhaseTable[i++] = PH_TT_MOVE;
PhaseTable[i++] = PH_MATE_KILLER;
PhaseTable[i++] = PH_GOOD_CAPTURES;
PhaseTable[i++] = PH_TT_MOVE;
PhaseTable[i++] = PH_MATE_KILLER;
PhaseTable[i++] = PH_GOOD_CAPTURES;
- // PH_KILLER_1 and PH_KILLER_2 are not yet used.
- // PhaseTable[i++] = PH_KILLER_1;
- // PhaseTable[i++] = PH_KILLER_2;
+ PhaseTable[i++] = PH_KILLERS;
PhaseTable[i++] = PH_NONCAPTURES;
PhaseTable[i++] = PH_BAD_CAPTURES;
PhaseTable[i++] = PH_STOP;
PhaseTable[i++] = PH_NONCAPTURES;
PhaseTable[i++] = PH_BAD_CAPTURES;
PhaseTable[i++] = PH_STOP;
PH_TT_MOVE, // Transposition table move
PH_MATE_KILLER, // Mate killer from the current ply
PH_GOOD_CAPTURES, // Queen promotions and captures with SEE values >= 0
PH_TT_MOVE, // Transposition table move
PH_MATE_KILLER, // Mate killer from the current ply
PH_GOOD_CAPTURES, // Queen promotions and captures with SEE values >= 0
- PH_BAD_CAPTURES, // Queen promotions and captures with SEE values < 0
- PH_KILLER_1, // Killer move 1 from the current ply (not used yet).
- PH_KILLER_2, // Killer move 2 from the current ply (not used yet).
+ PH_KILLERS, // Killer moves from the current ply
PH_NONCAPTURES, // Non-captures and underpromotions
PH_NONCAPTURES, // Non-captures and underpromotions
+ PH_BAD_CAPTURES, // Queen promotions and captures with SEE values < 0
PH_EVASIONS, // Check evasions
PH_QCAPTURES, // Captures in quiescence search
PH_QCHECKS, // Non-capture checks in quiescence search
PH_EVASIONS, // Check evasions
PH_QCAPTURES, // Captures in quiescence search
PH_QCHECKS, // Non-capture checks in quiescence search
int phaseIndex;
int numOfMoves, numOfBadCaptures;
int movesPicked;
int phaseIndex;
int numOfMoves, numOfBadCaptures;
int movesPicked;
+ bool checkKillers, checkLegal;