ExtMove* make_promotions(ExtMove* moveList, Square to, Square ksq) {
if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
+ {
*moveList++ = make<PROMOTION>(to - D, to, QUEEN);
+ if (attacks_bb<KNIGHT>(to) & ksq)
+ *moveList++ = make<PROMOTION>(to - D, to, KNIGHT);
+ }
if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
{
*moveList++ = make<PROMOTION>(to - D, to, ROOK);
*moveList++ = make<PROMOTION>(to - D, to, BISHOP);
- *moveList++ = make<PROMOTION>(to - D, to, KNIGHT);
+ if (!(attacks_bb<KNIGHT>(to) & ksq))
+ *moveList++ = make<PROMOTION>(to - D, to, KNIGHT);
}
- // Knight promotion is the only promotion that can give a direct check
- // that's not already included in the queen promotion.
- if (Type == QUIET_CHECKS && (attacks_bb<KNIGHT>(to) & ksq))
- *moveList++ = make<PROMOTION>(to - D, to, KNIGHT);
- else
- (void)ksq; // Silence a warning under MSVC
-
return moveList;
}
} // namespace
-/// <CAPTURES> Generates all pseudo-legal captures and queen promotions
-/// <QUIETS> Generates all pseudo-legal non-captures and underpromotions
+/// <CAPTURES> Generates all pseudo-legal captures plus queen and checking knight promotions
+/// <QUIETS> Generates all pseudo-legal non-captures and underpromotions(except checking knight)
/// <NON_EVASIONS> Generates all pseudo-legal captures and non-captures
///
/// Returns a pointer to the end of the move list.
template ExtMove* generate<NON_EVASIONS>(const Position&, ExtMove*);
-/// generate<QUIET_CHECKS> generates all pseudo-legal non-captures and knight
-/// underpromotions that give check. Returns a pointer to the end of the move list.
+/// generate<QUIET_CHECKS> generates all pseudo-legal non-captures.
+/// Returns a pointer to the end of the move list.
template<>
ExtMove* generate<QUIET_CHECKS>(const Position& pos, ExtMove* moveList) {
// Initialize a MovePicker object for the current position, and prepare
// to search the moves. Because the depth is <= 0 here, only captures,
- // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
- // be generated.
+ // queen and checking knight promotions, and other checks(only if depth >= DEPTH_QS_CHECKS)
+ // will be generated.
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
&thisThread->captureHistory,
contHist,