mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 09:47:46 +00:00
Sort moves just after scoring
Instead of a delayed selection sort so that the highest score move is picked up from the list when needed, sort all the moves up front just after score them. Selection sort is O(n*n) while std::sort is O(n*log n), it is true that delayed selection allows us to just pick the move until a cut off occurs or up to a given limit (12), but with an average of 30 non capture-moves delayed pick become slower just after 5-6 moves and we now pick up to 12. Profiling seem to prove this idea and movepick.cpp is now 10% faster. Also tests seem to confirm this: After 700 games at 1+0: Mod vs Orig +178 -160 =362 +9 ELO Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -62,6 +62,9 @@ struct MoveStack {
|
||||
int score;
|
||||
};
|
||||
|
||||
// Note that operator< is set up such that std::sort() will sort in descending order
|
||||
inline bool operator<(const MoveStack& f, const MoveStack& s) { return s.score < f.score; }
|
||||
|
||||
|
||||
////
|
||||
//// Inline functions
|
||||
|
||||
Reference in New Issue
Block a user