X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmovepick.cpp;h=bff6ac46f0e029fa3c7ba80cde72e8873877ed45;hp=95bbddba670788af7d2b937a72ddb4c28a791a31;hb=c97104e8540b72ee2c6c9c13d3773d2c0f9ec32f;hpb=32934c0c8d75fe63e08046f6ba7dd546de67dc01 diff --git a/src/movepick.cpp b/src/movepick.cpp index 95bbddba..bff6ac46 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -228,29 +228,18 @@ void MovePicker::score_captures() { // to the badCaptures[] array. Move m; int seeValue; - Square from, to; for (int i = 0; i < numOfMoves; i++) { m = moves[i].move; - from = move_from(m); - to = move_to(m); - - bool hxl = ( int(pos.midgame_value_of_piece_on(from)) - -int(pos.midgame_value_of_piece_on(to)) > 0) - || pos.type_of_piece_on(from) == KING; - - // Avoid calling see() for LxH and equal captures because - // SEE is always >= 0 and we order for MVV/LVA anyway. - seeValue = (hxl ? pos.see(m) : 0); - + seeValue = pos.see(m); if (seeValue >= 0) { if (move_promotion(m)) moves[i].score = QueenValueMidgame; else - moves[i].score = int(pos.midgame_value_of_piece_on(to)) - -int(pos.type_of_piece_on(from)); + moves[i].score = int(pos.midgame_value_of_piece_on(move_to(m))) + -int(pos.type_of_piece_on(move_from(m))); } else { @@ -321,10 +310,10 @@ void MovePicker::score_qcaptures() { } -/// find_best_index() loops across the moves and returns index of -/// the highest scored one. There is also a second version that -/// lowers the priority of moves that attack the same square, -/// so that if the best move that attack a square fails the next +/// find_best_index() loops across the moves and returns index of +/// the highest scored one. There is also a second version that +/// lowers the priority of moves that attack the same square, +/// so that if the best move that attack a square fails the next /// move picked attacks a different square if any, not the same one. int MovePicker::find_best_index() { @@ -340,41 +329,41 @@ int MovePicker::find_best_index() { return bestIndex; } -int MovePicker::find_best_index(Bitboard* squares, int values[]) { - - int hs; - Move m; - Square to; - int bestScore = -10000000, bestIndex = -1; - - for (int i = movesPicked; i < numOfMoves; i++) - { - m = moves[i].move; - to = move_to(m); - - if (!bit_is_set(*squares, to)) - { - // Init at first use - set_bit(squares, to); - values[to] = 0; - } - - hs = moves[i].score - values[to]; - if (hs > bestScore) - { - bestIndex = i; - bestScore = hs; - } - } - - if (bestIndex != -1) - { - // Raise value of the picked square, so next attack - // to the same square will get low priority. - to = move_to(moves[bestIndex].move); - values[to] += 0xB00; - } - return bestIndex; +int MovePicker::find_best_index(Bitboard* squares, int values[]) { + + int hs; + Move m; + Square to; + int bestScore = -10000000, bestIndex = -1; + + for (int i = movesPicked; i < numOfMoves; i++) + { + m = moves[i].move; + to = move_to(m); + + if (!bit_is_set(*squares, to)) + { + // Init at first use + set_bit(squares, to); + values[to] = 0; + } + + hs = moves[i].score - values[to]; + if (hs > bestScore) + { + bestIndex = i; + bestScore = hs; + } + } + + if (bestIndex != -1) + { + // Raise value of the picked square, so next attack + // to the same square will get low priority. + to = move_to(moves[bestIndex].move); + values[to] += 0xB00; + } + return bestIndex; }