X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovegen.cpp;h=9a6b902bb3efc8b66d2b08a52f63bbad7419a0d5;hp=dff9e8c3b4624056f0642b29e152ffac3e9e12eb;hb=46bb6c6dc300bc5a8b819d690734ddcb1f1e4e14;hpb=24485c96ec7dcb743c1dac8cf0cccc96456893d9 diff --git a/src/movegen.cpp b/src/movegen.cpp index dff9e8c3..9a6b902b 100644 --- a/src/movegen.cpp +++ b/src/movegen.cpp @@ -176,10 +176,10 @@ int generate_noncaptures(const Position& pos, MoveStack* mlist) { } -/// generate_checks() generates all pseudo-legal non-capturing, non-promoting -/// checks. It returns the number of generated moves. +/// generate_non_capture_checks() generates all pseudo-legal non-capturing, +/// non-promoting checks. It returns the number of generated moves. -int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc) { +int generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) { assert(pos.is_ok()); assert(!pos.is_check()); @@ -496,6 +496,11 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) { // Proceed according to the type of the moving piece. if (type_of_piece(pc) == PAWN) { + // Move direction must be compatible with pawn color + int direction = to - from; + if ((us == WHITE) != (direction > 0)) + return false; + // If the destination square is on the 8/1th rank, the move must // be a promotion. if ( ( (square_rank(to) == RANK_8 && us == WHITE) @@ -505,7 +510,7 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) { // Proceed according to the square delta between the source and // destionation squares. - switch (to - from) + switch (direction) { case DELTA_NW: case DELTA_NE: