So I try this pick next function based on std::min_element (yes my MoveSortOperator is reversed)
Code: Select all
const Move * MoveSorter::pickNext(MoveList & moves, size_t & begin){
if ( moves.begin()+begin == moves.end()) return nullptr;
START_TIMER
auto it = std::min_element(moves.begin()+begin,moves.end(),MoveSortOperator());
std::iter_swap(moves.begin()+begin,it);
STOP_AND_SUM_TIMER(MoveSorting)
return &*(moves.begin()+(begin++)); // increment begin !
}
So, instead of
Code: Select all
generate(moves)
score(moves)
sort(moves)
for(auto it = moves.begin() ; it != moves.end() ++it){
...
}
Code: Select all
generate(moves)
score(moves)
int count = 0;
while ( (it = pickNext(moves,count)) ){
...
}
So it is better ???
Answer seems to be yes in terms of nps, maybe around a 3% or 5% increase. A test is in progress to verify that Elo-wise.