X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=0be426ab659b969b8073b0bb5c8c528f911a2451;hp=486fec0fbe3177f0e871723f7be8872488ed1b8f;hb=673bc5526fa3d352f823ad144fb521b5dc98f45c;hpb=662d1859bde420b2cc87891fa23c6702a11dbc11 diff --git a/src/movepick.cpp b/src/movepick.cpp index 486fec0f..0be426ab 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -64,7 +64,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const History& h, captureThreshold = 0; curMove = lastMove = moves; - badCaptures = moves + MAX_MOVES; + lastBadCapture = moves + MAX_MOVES - 1; if (p.in_check()) phase = EVASION; @@ -167,20 +167,18 @@ void MovePicker::score_captures() { - type_of(pos.piece_moved(m)); if (is_promotion(m)) - cur->score += PieceValueMidgame[promotion_piece_type(m)]; + cur->score += PieceValueMidgame[promotion_type(m)]; } } void MovePicker::score_noncaptures() { Move m; - Square from; for (MoveStack* cur = moves; cur != lastMove; cur++) { m = cur->move; - from = from_sq(m); - cur->score = H.value(pos.piece_on(from), to_sq(m)); + cur->score = H.value(pos.piece_moved(m), to_sq(m)); } } @@ -242,10 +240,9 @@ void MovePicker::generate_next() { return; case BAD_CAPTURES_S1: - // Bad captures SEE value is already calculated so just pick them in order - // to get SEE move ordering. - curMove = badCaptures; - lastMove = moves + MAX_MOVES; + // Just pick them in reverse order to get MVV/LVA ordering + curMove = moves + MAX_MOVES - 1; + lastMove = lastBadCapture; return; case EVASIONS_S2: @@ -297,13 +294,11 @@ Move MovePicker::next_move() { { assert(captureThreshold <= 0); // Otherwise we cannot use see_sign() - int seeScore = pos.see_sign(move); - if (seeScore >= captureThreshold) + if (pos.see_sign(move) >= captureThreshold) return move; // Losing capture, move it to the tail of the array - (--badCaptures)->move = move; - badCaptures->score = seeScore; + (lastBadCapture--)->move = move; } break; @@ -325,8 +320,7 @@ Move MovePicker::next_move() { break; case BAD_CAPTURES_S1: - move = pick_best(curMove++, lastMove)->move; - return move; + return (curMove--)->move; case EVASIONS_S2: case CAPTURES_S3: case CAPTURES_S4: move = pick_best(curMove++, lastMove)->move;