mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
movegen: Fix just introduced move counter bug
This is what happens when you don't tests your patches !! Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
34a515f20b
commit
c1257d45b2
1 changed files with 10 additions and 12 deletions
|
@ -40,7 +40,7 @@ namespace {
|
||||||
int generate_castle_moves(const Position&, MoveStack*, Color us);
|
int generate_castle_moves(const Position&, MoveStack*, Color us);
|
||||||
|
|
||||||
int generate_piece_checks(PieceType pce, const Position& pos, Bitboard target,
|
int generate_piece_checks(PieceType pce, const Position& pos, Bitboard target,
|
||||||
Bitboard dc, Square ksq, MoveStack* mlist);
|
Bitboard dc, Square ksq, MoveStack* mlist, int n);
|
||||||
|
|
||||||
inline Bitboard next_row_white(Bitboard b) { return b << 8; }
|
inline Bitboard next_row_white(Bitboard b) { return b << 8; }
|
||||||
inline Bitboard next_row_black(Bitboard b) { return b >> 8; }
|
inline Bitboard next_row_black(Bitboard b) { return b >> 8; }
|
||||||
|
@ -57,7 +57,7 @@ namespace {
|
||||||
const PawnOffsets BlackPawnOffsets = { Rank6BB, Rank1BB, DELTA_S, WHITE, &next_row_black };
|
const PawnOffsets BlackPawnOffsets = { Rank6BB, Rank1BB, DELTA_S, WHITE, &next_row_black };
|
||||||
|
|
||||||
int generate_pawn_checks(const PawnOffsets& ofs, const Position& pos, Bitboard dc,
|
int generate_pawn_checks(const PawnOffsets& ofs, const Position& pos, Bitboard dc,
|
||||||
Square ksq, MoveStack* mlist);
|
Square ksq, MoveStack* mlist, int n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,26 +134,26 @@ int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
|
||||||
|
|
||||||
// Pawn moves
|
// Pawn moves
|
||||||
if (us == WHITE)
|
if (us == WHITE)
|
||||||
n += generate_pawn_checks(WhitePawnOffsets, pos, dc, ksq, mlist);
|
n = generate_pawn_checks(WhitePawnOffsets, pos, dc, ksq, mlist, 0);
|
||||||
else
|
else
|
||||||
n += generate_pawn_checks(BlackPawnOffsets, pos, dc, ksq, mlist);
|
n = generate_pawn_checks(BlackPawnOffsets, pos, dc, ksq, mlist, 0);
|
||||||
|
|
||||||
// Pieces moves
|
// Pieces moves
|
||||||
Bitboard b = pos.knights(us);
|
Bitboard b = pos.knights(us);
|
||||||
if (b)
|
if (b)
|
||||||
n += generate_piece_checks(KNIGHT, pos, b, dc, ksq, mlist);
|
n = generate_piece_checks(KNIGHT, pos, b, dc, ksq, mlist, n);
|
||||||
|
|
||||||
b = pos.bishops(us);
|
b = pos.bishops(us);
|
||||||
if (b)
|
if (b)
|
||||||
n += generate_piece_checks(BISHOP, pos, b, dc, ksq, mlist);
|
n = generate_piece_checks(BISHOP, pos, b, dc, ksq, mlist, n);
|
||||||
|
|
||||||
b = pos.rooks(us);
|
b = pos.rooks(us);
|
||||||
if (b)
|
if (b)
|
||||||
n += generate_piece_checks(ROOK, pos, b, dc, ksq, mlist);
|
n = generate_piece_checks(ROOK, pos, b, dc, ksq, mlist, n);
|
||||||
|
|
||||||
b = pos.queens(us);
|
b = pos.queens(us);
|
||||||
if (b)
|
if (b)
|
||||||
n += generate_piece_checks(QUEEN, pos, b, dc, ksq, mlist);
|
n = generate_piece_checks(QUEEN, pos, b, dc, ksq, mlist, n);
|
||||||
|
|
||||||
// King moves
|
// King moves
|
||||||
Square from = pos.king_square(us);
|
Square from = pos.king_square(us);
|
||||||
|
@ -951,10 +951,9 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
int generate_piece_checks(PieceType pce, const Position& pos, Bitboard target,
|
int generate_piece_checks(PieceType pce, const Position& pos, Bitboard target,
|
||||||
Bitboard dc, Square ksq, MoveStack* mlist) {
|
Bitboard dc, Square ksq, MoveStack* mlist, int n) {
|
||||||
|
|
||||||
const Piece_attacks_fn mem_fn = piece_attacks_fn[pce];
|
const Piece_attacks_fn mem_fn = piece_attacks_fn[pce];
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
// Discovered checks
|
// Discovered checks
|
||||||
Bitboard b = target & dc;
|
Bitboard b = target & dc;
|
||||||
|
@ -985,12 +984,11 @@ namespace {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
int generate_pawn_checks(const PawnOffsets& ofs, const Position& pos, Bitboard dc, Square ksq, MoveStack* mlist)
|
int generate_pawn_checks(const PawnOffsets& ofs, const Position& pos, Bitboard dc, Square ksq, MoveStack* mlist, int n)
|
||||||
{
|
{
|
||||||
// Pawn moves which give discovered check. This is possible only if the
|
// Pawn moves which give discovered check. This is possible only if the
|
||||||
// pawn is not on the same file as the enemy king, because we don't
|
// pawn is not on the same file as the enemy king, because we don't
|
||||||
// generate captures.
|
// generate captures.
|
||||||
int n = 0;
|
|
||||||
Bitboard empty = pos.empty_squares();
|
Bitboard empty = pos.empty_squares();
|
||||||
|
|
||||||
// Find all friendly pawns not on the enemy king's file
|
// Find all friendly pawns not on the enemy king's file
|
||||||
|
|
Loading…
Add table
Reference in a new issue