mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
MovePicker: simplify move swapping
We don't need a full swap here because once found and returned the best move will not be used again. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -335,10 +335,8 @@ Move MovePicker::pick_move_from_list() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bestIndex != -1) { // Found a good capture
|
if(bestIndex != -1) { // Found a good capture
|
||||||
MoveStack tmp = moves[movesPicked];
|
move = moves[bestIndex].move;
|
||||||
moves[movesPicked] = moves[bestIndex];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
moves[bestIndex] = tmp;
|
|
||||||
move = moves[movesPicked++].move;
|
|
||||||
if(move != ttMove && move != mateKiller &&
|
if(move != ttMove && move != mateKiller &&
|
||||||
pos->move_is_legal(move, pinned))
|
pos->move_is_legal(move, pinned))
|
||||||
return move;
|
return move;
|
||||||
@@ -368,10 +366,8 @@ Move MovePicker::pick_move_from_list() {
|
|||||||
bestIndex = movesPicked;
|
bestIndex = movesPicked;
|
||||||
|
|
||||||
if(bestIndex != -1) {
|
if(bestIndex != -1) {
|
||||||
MoveStack tmp = moves[movesPicked];
|
move = moves[bestIndex].move;
|
||||||
moves[movesPicked] = moves[bestIndex];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
moves[bestIndex] = tmp;
|
|
||||||
move = moves[movesPicked++].move;
|
|
||||||
if(move != ttMove && move != mateKiller &&
|
if(move != ttMove && move != mateKiller &&
|
||||||
pos->move_is_legal(move, pinned))
|
pos->move_is_legal(move, pinned))
|
||||||
return move;
|
return move;
|
||||||
@@ -392,10 +388,8 @@ Move MovePicker::pick_move_from_list() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(bestIndex != -1) {
|
if(bestIndex != -1) {
|
||||||
MoveStack tmp = moves[movesPicked];
|
move = moves[bestIndex].move;
|
||||||
moves[movesPicked] = moves[bestIndex];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
moves[bestIndex] = tmp;
|
|
||||||
move = moves[movesPicked++].move;
|
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,11 +425,8 @@ Move MovePicker::pick_move_from_list() {
|
|||||||
bestIndex = movesPicked;
|
bestIndex = movesPicked;
|
||||||
|
|
||||||
if(bestIndex != -1) {
|
if(bestIndex != -1) {
|
||||||
MoveStack tmp = moves[movesPicked];
|
move = moves[bestIndex].move;
|
||||||
moves[movesPicked] = moves[bestIndex];
|
moves[bestIndex] = moves[movesPicked++];
|
||||||
moves[bestIndex] = tmp;
|
|
||||||
|
|
||||||
move = moves[movesPicked++].move;
|
|
||||||
// Remember to change the line below if we decide to hash the qsearch!
|
// Remember to change the line below if we decide to hash the qsearch!
|
||||||
// Maybe also postpone the legality check until after futility pruning?
|
// Maybe also postpone the legality check until after futility pruning?
|
||||||
if(/* move != ttMove && */ pos->move_is_legal(move, pinned))
|
if(/* move != ttMove && */ pos->move_is_legal(move, pinned))
|
||||||
|
|||||||
Reference in New Issue
Block a user