- // In main search we want to push captures with negative SEE values to
- // badCaptures[] array, but instead of doing it now we delay till when
- // the move has been picked up in pick_move_from_list(), this way we save
- // some SEE calls in case we get a cutoff (idea from Pablo Vazquez).
- Move m;
-
- for (MoveStack* cur = moves; cur != lastMove; cur++)
- {
- m = cur->move;
- cur->score = PieceValueMidgame[pos.piece_on(to_sq(m))]
- - type_of(pos.piece_moved(m));
-
- if (is_promotion(m))
- cur->score += PieceValueMidgame[promotion_piece_type(m)];
- }
+ // In main search we want to push captures with negative SEE values to the
+ // badCaptures[] array, but instead of doing it now we delay until the move
+ // has been picked up in pick_move_from_list(). This way we save some SEE
+ // calls in case we get a cutoff.
+ for (auto& m : *this)
+ if (type_of(m) == ENPASSANT)
+ m.value = PieceValue[MG][PAWN] - Value(PAWN);
+
+ else if (type_of(m) == PROMOTION)
+ m.value = PieceValue[MG][pos.piece_on(to_sq(m))] - Value(PAWN)
+ + PieceValue[MG][promotion_type(m)] - PieceValue[MG][PAWN];
+ else
+ m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
+ - Value(type_of(pos.moved_piece(m)));