Small speed-up of 3% in perft.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
FORCE_INLINE MoveStack* generate_piece_moves(const Position& p, MoveStack* m, Color us, Bitboard t) {
assert(Pt == PAWN);
FORCE_INLINE MoveStack* generate_piece_moves(const Position& p, MoveStack* m, Color us, Bitboard t) {
assert(Pt == PAWN);
- assert(Type == MV_CAPTURE || Type == MV_NON_CAPTURE || Type == MV_EVASION);
-
return (us == WHITE ? generate_pawn_moves<WHITE, Type>(p, m, t, SQ_NONE)
: generate_pawn_moves<BLACK, Type>(p, m, t, SQ_NONE));
}
return (us == WHITE ? generate_pawn_moves<WHITE, Type>(p, m, t, SQ_NONE)
: generate_pawn_moves<BLACK, Type>(p, m, t, SQ_NONE));
}
template<MoveType Type>
MoveStack* generate(const Position& pos, MoveStack* mlist) {
template<MoveType Type>
MoveStack* generate(const Position& pos, MoveStack* mlist) {
+ assert(Type == MV_CAPTURE || Type == MV_NON_CAPTURE || Type == MV_NON_EVASION);
assert(!pos.in_check());
Color us = pos.side_to_move();
Bitboard target;
assert(!pos.in_check());
Color us = pos.side_to_move();
Bitboard target;
- if (Type == MV_CAPTURE || Type == MV_NON_EVASION)
+ if (Type == MV_CAPTURE)
target = pos.pieces(flip(us));
target = pos.pieces(flip(us));
else if (Type == MV_NON_CAPTURE)
target = pos.empty_squares();
else if (Type == MV_NON_CAPTURE)
target = pos.empty_squares();
- if (Type == MV_NON_EVASION)
- {
- mlist = generate_piece_moves<PAWN, MV_CAPTURE>(pos, mlist, us, target);
- mlist = generate_piece_moves<PAWN, MV_NON_CAPTURE>(pos, mlist, us, pos.empty_squares());
- target |= pos.empty_squares();
- }
- else
- mlist = generate_piece_moves<PAWN, Type>(pos, mlist, us, target);
+ else if (Type == MV_NON_EVASION)
+ target = pos.pieces(flip(us)) | pos.empty_squares();
+ mlist = generate_piece_moves<PAWN, Type>(pos, mlist, us, target);
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, target);
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, target);
mlist = generate_piece_moves<ROOK>(pos, mlist, us, target);
mlist = generate_piece_moves<KNIGHT>(pos, mlist, us, target);
mlist = generate_piece_moves<BISHOP>(pos, mlist, us, target);
mlist = generate_piece_moves<ROOK>(pos, mlist, us, target);
Delta == DELTA_NW ? p << 7 : Delta == DELTA_SW ? p >> 9 : p;
}
Delta == DELTA_NW ? p << 7 : Delta == DELTA_SW ? p >> 9 : p;
}
- template<MoveType Type, Square Delta>
inline MoveStack* generate_pawn_captures(MoveStack* mlist, Bitboard pawns, Bitboard target) {
const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
inline MoveStack* generate_pawn_captures(MoveStack* mlist, Bitboard pawns, Bitboard target) {
const Bitboard TFileABB = (Delta == DELTA_NE || Delta == DELTA_SE ? FileABB : FileHBB);
- if (Type == MV_CAPTURE || Type == MV_EVASION)
+ if (Type == MV_CAPTURE || Type == MV_EVASION || Type == MV_NON_EVASION)
(*mlist++).move = make_promotion(to - Delta, to, QUEEN);
(*mlist++).move = make_promotion(to - Delta, to, QUEEN);
- if (Type == MV_NON_CAPTURE || Type == MV_EVASION)
+ if (Type == MV_NON_CAPTURE || Type == MV_EVASION || Type == MV_NON_EVASION)
{
(*mlist++).move = make_promotion(to - Delta, to, ROOK);
(*mlist++).move = make_promotion(to - Delta, to, BISHOP);
{
(*mlist++).move = make_promotion(to - Delta, to, ROOK);
(*mlist++).move = make_promotion(to - Delta, to, BISHOP);
- if (Type == MV_CAPTURE || Type == MV_EVASION)
+ if (Type == MV_CAPTURE || Type == MV_EVASION || Type == MV_NON_EVASION)
- mlist = generate_pawn_captures<Type, RIGHT_UP>(mlist, pawns, enemyPieces);
- mlist = generate_pawn_captures<Type, LEFT_UP>(mlist, pawns, enemyPieces);
+ mlist = generate_pawn_captures<RIGHT_UP>(mlist, pawns, enemyPieces);
+ mlist = generate_pawn_captures<LEFT_UP>(mlist, pawns, enemyPieces);
}
// Single and double pawn pushes
}
// Single and double pawn pushes
- if ((Type == MV_CAPTURE || Type == MV_EVASION) && pos.ep_square() != SQ_NONE)
+ if ( (Type == MV_CAPTURE || Type == MV_EVASION || Type == MV_NON_EVASION)
+ && pos.ep_square() != SQ_NONE)
{
assert(Us != WHITE || rank_of(pos.ep_square()) == RANK_6);
assert(Us != BLACK || rank_of(pos.ep_square()) == RANK_3);
{
assert(Us != WHITE || rank_of(pos.ep_square()) == RANK_6);
assert(Us != BLACK || rank_of(pos.ep_square()) == RANK_3);