mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Remove sorting optimization for many zeroes
With negative history we don't have anymore a lot of zeroes to score, so just split moves in positives and non-positives sets. Speed up is almost zero, we cannot test speed directly because node count changed due to reorder, but I have verified sorting is correct. With a profiler I have seen we gain a little in sort_moves() and lose a little in insertion_sort(), so the net effect is almost zero, but code is simpler. No real change, just move reordering. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
321f6d1d19
commit
b0858877ae
1 changed files with 3 additions and 23 deletions
26
src/move.h
26
src/move.h
|
@ -86,8 +86,8 @@ inline void insertion_sort(T* firstMove, T* lastMove)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our dedicated sort in range [firstMove, lastMove), it is well
|
// Our dedicated sort in range [firstMove, lastMove), first splits
|
||||||
// tuned for non-captures where we have a lot of zero scored moves.
|
// positive scores from ramining then order seaprately the two sets.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline void sort_moves(T* firstMove, T* lastMove)
|
inline void sort_moves(T* firstMove, T* lastMove)
|
||||||
{
|
{
|
||||||
|
@ -114,28 +114,8 @@ inline void sort_moves(T* firstMove, T* lastMove)
|
||||||
|
|
||||||
} while (p != d);
|
} while (p != d);
|
||||||
|
|
||||||
// Sort positives
|
// Sort positives and non-positives separately
|
||||||
insertion_sort<T>(firstMove, p);
|
insertion_sort<T>(firstMove, p);
|
||||||
|
|
||||||
d = lastMove;
|
|
||||||
p--;
|
|
||||||
|
|
||||||
// Split zero vs negatives
|
|
||||||
do {
|
|
||||||
while ((++p)->score == 0);
|
|
||||||
|
|
||||||
if (p != d)
|
|
||||||
{
|
|
||||||
while (--d != p && d->score < 0);
|
|
||||||
|
|
||||||
tmp = *p;
|
|
||||||
*p = *d;
|
|
||||||
*d = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (p != d);
|
|
||||||
|
|
||||||
// Sort negatives
|
|
||||||
insertion_sort<T>(p, lastMove);
|
insertion_sort<T>(p, lastMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue