if (p.in_check())
phase = EVASIONS;
- else if (d >= DEPTH_QS_CHECKS)
+ else if (d > DEPTH_QS_NO_CHECKS)
phase = CAPTURES_AND_CHECKS;
- else if (d >= DEPTH_QS_RECAPTURES)
+ else if (d > DEPTH_QS_RECAPTURES)
{
phase = CAPTURES;
}
MovePicker::MovePicker(const Position& p, Move ttm, const History& h,
- PieceType parentCapture) : pos(p), H(h) {
+ PieceType pt) : pos(p), H(h), curMove(0), lastMove(0) {
- assert (!pos.in_check());
+ assert(!pos.in_check());
- // In ProbCut we consider only captures better than parent's move
- captureThreshold = PieceValueMidgame[Piece(parentCapture)];
- curMove = lastMove = 0;
phase = PROBCUT;
- if ( ttm != MOVE_NONE
- && (!pos.is_capture(ttm) || pos.see(ttm) <= captureThreshold))
+ // In ProbCut we generate only captures better than parent's captured piece
+ captureThreshold = PieceValueMidgame[pt];
+
+ if (ttm && (!pos.is_capture(ttm) || pos.see(ttm) <= captureThreshold))
ttm = MOVE_NONE;
ttMove = (ttm && pos.is_pseudo_legal(ttm) ? ttm : MOVE_NONE);
- type_of(pos.piece_moved(m));
if (is_promotion(m))
- cur->score += PieceValueMidgame[Piece(promotion_piece_type(m))];
+ cur->score += PieceValueMidgame[promotion_piece_type(m)];
}
}
lastMove = curMove + 1;
return;
- case CAPTURES_S1: case CAPTURES_S3: case CAPTURES_S4:
- case CAPTURES_S5: case CAPTURES_S6:
+ case CAPTURES_S1: case CAPTURES_S3: case CAPTURES_S4: case CAPTURES_S5: case CAPTURES_S6:
lastMove = generate<MV_CAPTURE>(pos, moves);
score_captures();
return;
return;
case EVASIONS_S2:
- assert(pos.in_check());
lastMove = generate<MV_EVASION>(pos, moves);
score_evasions();
return;
case TT_MOVE_S1: case TT_MOVE_S2: case TT_MOVE_S3: case TT_MOVE_S4: case TT_MOVE_S5:
curMove++;
return ttMove;
- break;
case CAPTURES_S1:
move = pick_best(curMove++, lastMove)->move;
return move;
case EVASIONS_S2:
- case CAPTURES_S3: case CAPTURES_S4:
+ case CAPTURES_S3:
+ case CAPTURES_S4:
move = pick_best(curMove++, lastMove)->move;
if (move != ttMove)
return move;
case CAPTURES_S5:
move = pick_best(curMove++, lastMove)->move;
- if ( move != ttMove
- && pos.see(move) > captureThreshold)
+ if (move != ttMove && pos.see(move) > captureThreshold)
return move;
break;
DEPTH_ZERO = 0 * ONE_PLY,
DEPTH_QS_CHECKS = -1 * ONE_PLY,
DEPTH_QS_NO_CHECKS = -2 * ONE_PLY,
- DEPTH_QS_RECAPTURES = -4 * ONE_PLY,
+ DEPTH_QS_RECAPTURES = -5 * ONE_PLY,
DEPTH_NONE = -127 * ONE_PLY
};
const Value QueenValueMidgame = Value(0x9D9);
const Value QueenValueEndgame = Value(0x9FE);
-extern const Value PieceValueMidgame[17];
+extern const Value PieceValueMidgame[17]; // Indexed by Piece or PieceType
extern const Value PieceValueEndgame[17];
extern int SquareDistance[64][64];