X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=36db8d2b65200a9bb5e2f829d35a0ae0722ef253;hp=45be5df3203b26a0c4fe5ffccb25468033692ba0;hb=b82c3021fa4523242c05bc88426c8a794b71167e;hpb=f637ddc1e87c9e825ce63f66974348347439f493 diff --git a/src/position.cpp b/src/position.cpp index 45be5df3..36db8d2b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -190,7 +190,7 @@ void Position::from_fen(const std::string& fen) { i++; // En passant square - if ( i < fen.length() - 2 + if ( i <= fen.length() - 2 && (fen[i] >= 'a' && fen[i] <= 'h') && (fen[i+1] == '3' || fen[i+1] == '6')) st->epSquare = square_from_string(fen.substr(i, 2)); @@ -1854,15 +1854,14 @@ Value Position::compute_value() const { Value Position::compute_non_pawn_material(Color c) const { Value result = Value(0); - Square s; for (PieceType pt = KNIGHT; pt <= QUEEN; pt++) { Bitboard b = pieces_of_color_and_type(c, pt); - while(b) + while (b) { - s = pop_1st_bit(&b); - assert(piece_on(s) == piece_of_color_and_type(c, pt)); + assert(piece_on(first_1(b)) == piece_of_color_and_type(c, pt)); + pop_1st_bit(&b); result += piece_value_midgame(pt); } }