mirror of
https://github.com/sockspls/badfish
synced 2025-06-28 00:19:50 +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:
parent
713000c517
commit
1f9404434d
3 changed files with 12 additions and 25 deletions
1
AUTHORS
1
AUTHORS
|
@ -45,6 +45,7 @@ Bruno de Melo Costa (BM123499)
|
||||||
Bruno Pellanda (pellanda)
|
Bruno Pellanda (pellanda)
|
||||||
Bryan Cross (crossbr)
|
Bryan Cross (crossbr)
|
||||||
candirufish
|
candirufish
|
||||||
|
Carlos Esparza Sánchez (ces42)
|
||||||
Chess13234
|
Chess13234
|
||||||
Chris Cain (ceebo)
|
Chris Cain (ceebo)
|
||||||
Ciekce
|
Ciekce
|
||||||
|
|
|
@ -18,11 +18,9 @@
|
||||||
|
|
||||||
#include "movepick.h"
|
#include "movepick.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "bitboard.h"
|
#include "bitboard.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
@ -199,19 +197,13 @@ void MovePicker::score() {
|
||||||
|
|
||||||
// Returns the next move satisfying a predicate function.
|
// Returns the next move satisfying a predicate function.
|
||||||
// This never returns the TT move, as it was emitted before.
|
// 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) {
|
Move MovePicker::select(Pred filter) {
|
||||||
|
|
||||||
while (cur < endMoves)
|
for (; cur < endMoves; ++cur)
|
||||||
{
|
|
||||||
if constexpr (T == Best)
|
|
||||||
std::swap(*cur, *std::max_element(cur, endMoves));
|
|
||||||
|
|
||||||
if (*cur != ttMove && filter())
|
if (*cur != ttMove && filter())
|
||||||
return *cur++;
|
return *cur++;
|
||||||
|
|
||||||
cur++;
|
|
||||||
}
|
|
||||||
return Move::none();
|
return Move::none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +237,7 @@ top:
|
||||||
goto top;
|
goto top;
|
||||||
|
|
||||||
case GOOD_CAPTURE :
|
case GOOD_CAPTURE :
|
||||||
if (select<Next>([&]() {
|
if (select([&]() {
|
||||||
// Move losing capture to endBadCaptures to be tried later
|
// Move losing capture to endBadCaptures to be tried later
|
||||||
return pos.see_ge(*cur, -cur->value / 18) ? true
|
return pos.see_ge(*cur, -cur->value / 18) ? true
|
||||||
: (*endBadCaptures++ = *cur, false);
|
: (*endBadCaptures++ = *cur, false);
|
||||||
|
@ -269,7 +261,7 @@ top:
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
case GOOD_QUIET :
|
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))
|
if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth))
|
||||||
return *(cur - 1);
|
return *(cur - 1);
|
||||||
|
@ -286,7 +278,7 @@ top:
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
case BAD_CAPTURE :
|
case BAD_CAPTURE :
|
||||||
if (select<Next>([]() { return true; }))
|
if (select([]() { return true; }))
|
||||||
return *(cur - 1);
|
return *(cur - 1);
|
||||||
|
|
||||||
// Prepare the pointers to loop over the bad quiets
|
// Prepare the pointers to loop over the bad quiets
|
||||||
|
@ -298,7 +290,7 @@ top:
|
||||||
|
|
||||||
case BAD_QUIET :
|
case BAD_QUIET :
|
||||||
if (!skipQuiets)
|
if (!skipQuiets)
|
||||||
return select<Next>([]() { return true; });
|
return select([]() { return true; });
|
||||||
|
|
||||||
return Move::none();
|
return Move::none();
|
||||||
|
|
||||||
|
@ -307,17 +299,16 @@ top:
|
||||||
endMoves = generate<EVASIONS>(pos, cur);
|
endMoves = generate<EVASIONS>(pos, cur);
|
||||||
|
|
||||||
score<EVASIONS>();
|
score<EVASIONS>();
|
||||||
|
partial_insertion_sort(cur, endMoves, std::numeric_limits<int>::min());
|
||||||
++stage;
|
++stage;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
|
|
||||||
case EVASION :
|
case EVASION :
|
||||||
return select<Best>([]() { return true; });
|
case QCAPTURE :
|
||||||
|
return select([]() { return true; });
|
||||||
|
|
||||||
case PROBCUT :
|
case PROBCUT :
|
||||||
return select<Next>([&]() { return pos.see_ge(*cur, threshold); });
|
return select([&]() { return pos.see_ge(*cur, threshold); });
|
||||||
|
|
||||||
case QCAPTURE :
|
|
||||||
return select<Next>([]() { return true; });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
|
@ -35,11 +35,6 @@ class Position;
|
||||||
// a cut-off first.
|
// a cut-off first.
|
||||||
class MovePicker {
|
class MovePicker {
|
||||||
|
|
||||||
enum PickType {
|
|
||||||
Next,
|
|
||||||
Best
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MovePicker(const MovePicker&) = delete;
|
MovePicker(const MovePicker&) = delete;
|
||||||
MovePicker& operator=(const MovePicker&) = delete;
|
MovePicker& operator=(const MovePicker&) = delete;
|
||||||
|
@ -57,7 +52,7 @@ class MovePicker {
|
||||||
void skip_quiet_moves();
|
void skip_quiet_moves();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<PickType T, typename Pred>
|
template<typename Pred>
|
||||||
Move select(Pred);
|
Move select(Pred);
|
||||||
template<GenType>
|
template<GenType>
|
||||||
void score();
|
void score();
|
||||||
|
|
Loading…
Add table
Reference in a new issue