1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-06-27 16:09:52 +00:00

Simplify picking of evasion moves

Sort evasions before we start returning them in next_move() (just like
every other kind of move) instead of looking for the biggest element on
every call to next_move(). The bench number changes because the old
method is not equivalent to a stable sort.

Passed STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 132064 W: 34318 L: 34204 D: 63542
Ptnml(0-2): 392, 15522, 34106, 15604, 408
https://tests.stockfishchess.org/tests/view/6743fee086d5ee47d953f9ca

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 97542 W: 24899 L: 24757 D: 47886
Ptnml(0-2): 63, 10646, 27193, 10824, 45
https://tests.stockfishchess.org/tests/view/674509cd86d5ee47d953fb96

closes https://github.com/official-stockfish/Stockfish/pull/5700

Bench: 1094825
This commit is contained in:
Carlos Esparza 2024-11-24 16:17:42 -08:00 committed by Disservin
parent 713000c517
commit 1f9404434d
3 changed files with 12 additions and 25 deletions

View file

@ -45,6 +45,7 @@ Bruno de Melo Costa (BM123499)
Bruno Pellanda (pellanda)
Bryan Cross (crossbr)
candirufish
Carlos Esparza Sánchez (ces42)
Chess13234
Chris Cain (ceebo)
Ciekce

View file

@ -18,11 +18,9 @@
#include "movepick.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <limits>
#include <utility>
#include "bitboard.h"
#include "position.h"
@ -199,19 +197,13 @@ void MovePicker::score() {
// Returns the next move satisfying a predicate function.
// This never returns the TT move, as it was emitted before.
template<MovePicker::PickType T, typename Pred>
template<typename Pred>
Move MovePicker::select(Pred filter) {
while (cur < endMoves)
{
if constexpr (T == Best)
std::swap(*cur, *std::max_element(cur, endMoves));
for (; cur < endMoves; ++cur)
if (*cur != ttMove && filter())
return *cur++;
cur++;
}
return Move::none();
}
@ -245,7 +237,7 @@ top:
goto top;
case GOOD_CAPTURE :
if (select<Next>([&]() {
if (select([&]() {
// Move losing capture to endBadCaptures to be tried later
return pos.see_ge(*cur, -cur->value / 18) ? true
: (*endBadCaptures++ = *cur, false);
@ -269,7 +261,7 @@ top:
[[fallthrough]];
case GOOD_QUIET :
if (!skipQuiets && select<Next>([]() { return true; }))
if (!skipQuiets && select([]() { return true; }))
{
if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth))
return *(cur - 1);
@ -286,7 +278,7 @@ top:
[[fallthrough]];
case BAD_CAPTURE :
if (select<Next>([]() { return true; }))
if (select([]() { return true; }))
return *(cur - 1);
// Prepare the pointers to loop over the bad quiets
@ -298,7 +290,7 @@ top:
case BAD_QUIET :
if (!skipQuiets)
return select<Next>([]() { return true; });
return select([]() { return true; });
return Move::none();
@ -307,17 +299,16 @@ top:
endMoves = generate<EVASIONS>(pos, cur);
score<EVASIONS>();
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
++stage;
[[fallthrough]];
case EVASION :
return select<Best>([]() { return true; });
case QCAPTURE :
return select([]() { return true; });
case PROBCUT :
return select<Next>([&]() { return pos.see_ge(*cur, threshold); });
case QCAPTURE :
return select<Next>([]() { return true; });
return select([&]() { return pos.see_ge(*cur, threshold); });
}
assert(false);

View file

@ -35,11 +35,6 @@ class Position;
// a cut-off first.
class MovePicker {
enum PickType {
Next,
Best
};
public:
MovePicker(const MovePicker&) = delete;
MovePicker& operator=(const MovePicker&) = delete;
@ -57,7 +52,7 @@ class MovePicker {
void skip_quiet_moves();
private:
template<PickType T, typename Pred>
template<typename Pred>
Move select(Pred);
template<GenType>
void score();