2008-08-31 23:59:13 -06:00
|
|
|
/*
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
|
|
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
2016-01-02 02:43:25 -07:00
|
|
|
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
|
2020-01-07 13:35:47 -07:00
|
|
|
Copyright (C) 2015-2020 Marco Costalba, Joona Kiiski, Gary Linscott, Tord Romstad
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
2008-08-31 23:59:13 -06:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2008-10-25 08:28:24 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
2008-08-31 23:59:13 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-10-25 08:28:24 -06:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include "movepick.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2013-07-21 01:54:56 -06:00
|
|
|
enum Stages {
|
2018-03-20 18:48:31 -06:00
|
|
|
MAIN_TT, CAPTURE_INIT, GOOD_CAPTURE, REFUTATION, QUIET_INIT, QUIET, BAD_CAPTURE,
|
2018-03-18 17:56:19 -06:00
|
|
|
EVASION_TT, EVASION_INIT, EVASION,
|
|
|
|
PROBCUT_TT, PROBCUT_INIT, PROBCUT,
|
|
|
|
QSEARCH_TT, QCAPTURE_INIT, QCAPTURE, QCHECK_INIT, QCHECK
|
2009-08-31 06:28:11 -06:00
|
|
|
};
|
|
|
|
|
2017-04-22 01:03:17 -06:00
|
|
|
// partial_insertion_sort() sorts moves in descending order up to and including
|
|
|
|
// a given limit. The order of moves smaller than the limit is left unspecified.
|
|
|
|
void partial_insertion_sort(ExtMove* begin, ExtMove* end, int limit) {
|
|
|
|
|
2017-05-07 21:14:23 -06:00
|
|
|
for (ExtMove *sortedEnd = begin, *p = begin + 1; p < end; ++p)
|
2017-04-20 12:15:48 -06:00
|
|
|
if (p->value >= limit)
|
|
|
|
{
|
|
|
|
ExtMove tmp = *p, *q;
|
2017-05-07 21:14:23 -06:00
|
|
|
*p = *++sortedEnd;
|
|
|
|
for (q = sortedEnd; q != begin && *(q - 1) < tmp; --q)
|
|
|
|
*q = *(q - 1);
|
2017-04-20 12:15:48 -06:00
|
|
|
*q = tmp;
|
|
|
|
}
|
2013-02-10 11:10:01 -07:00
|
|
|
}
|
|
|
|
|
2014-11-01 14:35:10 -06:00
|
|
|
} // namespace
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-01-21 15:32:48 -07:00
|
|
|
|
|
|
|
/// Constructors of the MovePicker class. As arguments we pass information
|
2013-12-04 23:18:12 -07:00
|
|
|
/// to help it to return the (presumably) good moves first, to decide which
|
2008-08-31 23:59:13 -06:00
|
|
|
/// moves to return (in the quiescence search, for instance, we only want to
|
2016-01-16 14:34:29 -07:00
|
|
|
/// search captures, promotions, and some checks) and how important good move
|
2013-12-04 23:18:12 -07:00
|
|
|
/// ordering is at the current node.
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2017-08-21 10:59:24 -06:00
|
|
|
/// MovePicker constructor for the main search
|
Improve move order near the root
Current move histories are known to work well near the leaves, whilst at
higher depths they aren't very helpful. To address this problem this
patch introduces a table dedicated for what's happening at plies 0-3.
It's structured like mainHistory with ply index instead of color.
It get cleared with each new search and is filled during iterative
deepening at higher depths when recording successful quiet moves near
the root or traversing nodes which were in the principal variation
(ttPv).
Medium TC (20+0.2):
https://tests.stockfishchess.org/tests/view/5e4d358790a0a02810d096dc
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 100910 W: 16682 L: 16376 D: 67852
Ptnml(0-2): 1177, 10983, 25883, 11181, 1231
LTC:
https://tests.stockfishchess.org/tests/view/5e4e2cb790a0a02810d09714
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 80444 W: 10495 L: 10095 D: 59854
Ptnml(0-2): 551, 7479, 23803, 7797, 592
closes https://github.com/official-stockfish/Stockfish/pull/2557
Bench: 4705960
2020-02-21 06:01:59 -07:00
|
|
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
|
|
|
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, Move* killers, int pl)
|
|
|
|
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
2020-03-30 14:45:35 -06:00
|
|
|
refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
2009-08-31 06:28:11 -06:00
|
|
|
|
2019-09-28 14:27:23 -06:00
|
|
|
assert(d > 0);
|
2011-01-23 14:59:05 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
stage = pos.checkers() ? EVASION_TT : MAIN_TT;
|
2018-12-06 07:00:38 -07:00
|
|
|
ttMove = ttm && pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
|
2016-09-10 13:37:36 -06:00
|
|
|
stage += (ttMove == MOVE_NONE);
|
2011-01-23 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2017-08-21 10:59:24 -06:00
|
|
|
/// MovePicker constructor for quiescence search
|
2018-03-18 17:56:19 -06:00
|
|
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
2018-07-19 10:26:05 -06:00
|
|
|
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
|
|
|
|
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), recaptureSquare(rs), depth(d) {
|
2011-01-23 14:59:05 -07:00
|
|
|
|
2019-09-28 14:27:23 -06:00
|
|
|
assert(d <= 0);
|
2011-01-23 14:59:05 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
stage = pos.checkers() ? EVASION_TT : QSEARCH_TT;
|
2019-01-01 06:13:08 -07:00
|
|
|
ttMove = ttm
|
|
|
|
&& (depth > DEPTH_QS_RECAPTURES || to_sq(ttm) == recaptureSquare)
|
|
|
|
&& pos.pseudo_legal(ttm) ? ttm : MOVE_NONE;
|
2016-09-10 13:37:36 -06:00
|
|
|
stage += (ttMove == MOVE_NONE);
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2018-03-27 08:44:47 -06:00
|
|
|
/// MovePicker constructor for ProbCut: we generate captures with SEE greater
|
2017-08-21 10:59:24 -06:00
|
|
|
/// than or equal to the given threshold.
|
2017-11-03 05:37:11 -06:00
|
|
|
MovePicker::MovePicker(const Position& p, Move ttm, Value th, const CapturePieceToHistory* cph)
|
|
|
|
: pos(p), captureHistory(cph), threshold(th) {
|
2011-05-21 10:17:11 -06:00
|
|
|
|
2012-12-25 09:59:35 -07:00
|
|
|
assert(!pos.checkers());
|
2011-05-21 10:17:11 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
stage = PROBCUT_TT;
|
2018-12-06 07:00:38 -07:00
|
|
|
ttMove = ttm
|
2015-07-19 03:25:14 -06:00
|
|
|
&& pos.capture(ttm)
|
2019-01-01 06:13:08 -07:00
|
|
|
&& pos.pseudo_legal(ttm)
|
2017-04-22 01:03:17 -06:00
|
|
|
&& pos.see_ge(ttm, threshold) ? ttm : MOVE_NONE;
|
2016-09-10 13:37:36 -06:00
|
|
|
stage += (ttMove == MOVE_NONE);
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
/// MovePicker::score() assigns a numerical value to each move in a list, used
|
|
|
|
/// for sorting. Captures are ordered by Most Valuable Victim (MVV), preferring
|
|
|
|
/// captures with a good history. Quiets moves are ordered using the histories.
|
2017-08-21 10:59:24 -06:00
|
|
|
template<GenType Type>
|
2017-08-09 06:04:59 -06:00
|
|
|
void MovePicker::score() {
|
2008-10-25 08:28:24 -06:00
|
|
|
|
2017-08-21 10:59:24 -06:00
|
|
|
static_assert(Type == CAPTURES || Type == QUIETS || Type == EVASIONS, "Wrong type");
|
|
|
|
|
2015-05-01 18:36:39 -06:00
|
|
|
for (auto& m : *this)
|
2017-08-21 10:59:24 -06:00
|
|
|
if (Type == CAPTURES)
|
2019-07-10 17:59:33 -06:00
|
|
|
m.value = int(PieceValue[MG][pos.piece_on(to_sq(m))]) * 6
|
|
|
|
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))];
|
2017-08-21 10:59:24 -06:00
|
|
|
|
|
|
|
else if (Type == QUIETS)
|
2019-10-05 08:42:36 -06:00
|
|
|
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
|
|
|
+ 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
|
|
|
+ 2 * (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
|
|
|
+ 2 * (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
Improve move order near the root
Current move histories are known to work well near the leaves, whilst at
higher depths they aren't very helpful. To address this problem this
patch introduces a table dedicated for what's happening at plies 0-3.
It's structured like mainHistory with ply index instead of color.
It get cleared with each new search and is filled during iterative
deepening at higher depths when recording successful quiet moves near
the root or traversing nodes which were in the principal variation
(ttPv).
Medium TC (20+0.2):
https://tests.stockfishchess.org/tests/view/5e4d358790a0a02810d096dc
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 100910 W: 16682 L: 16376 D: 67852
Ptnml(0-2): 1177, 10983, 25883, 11181, 1231
LTC:
https://tests.stockfishchess.org/tests/view/5e4e2cb790a0a02810d09714
LLR: 2.95 (-2.94,2.94) {0.25,1.75}
Total: 80444 W: 10495 L: 10095 D: 59854
Ptnml(0-2): 551, 7479, 23803, 7797, 592
closes https://github.com/official-stockfish/Stockfish/pull/2557
Bench: 4705960
2020-02-21 06:01:59 -07:00
|
|
|
+ (*continuationHistory[5])[pos.moved_piece(m)][to_sq(m)]
|
|
|
|
+ (ply < MAX_LPH ? 4 * (*lowPlyHistory)[ply][from_to(m)] : 0);
|
2017-08-09 06:04:59 -06:00
|
|
|
|
2017-08-21 10:59:24 -06:00
|
|
|
else // Type == EVASIONS
|
|
|
|
{
|
|
|
|
if (pos.capture(m))
|
|
|
|
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
|
|
|
|
- Value(type_of(pos.moved_piece(m)));
|
|
|
|
else
|
2018-07-19 10:26:05 -06:00
|
|
|
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
|
|
|
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
|
|
|
- (1 << 28);
|
2017-08-21 10:59:24 -06:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2018-03-27 08:44:47 -06:00
|
|
|
/// MovePicker::select() returns the next move satisfying a predicate function.
|
2018-03-20 18:48:31 -06:00
|
|
|
/// It never returns the TT move.
|
2018-03-27 08:44:47 -06:00
|
|
|
template<MovePicker::PickType T, typename Pred>
|
|
|
|
Move MovePicker::select(Pred filter) {
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
while (cur < endMoves)
|
|
|
|
{
|
2018-03-27 08:44:47 -06:00
|
|
|
if (T == Best)
|
2018-03-18 17:56:19 -06:00
|
|
|
std::swap(*cur, *std::max_element(cur, endMoves));
|
2008-10-16 06:25:56 -06:00
|
|
|
|
2019-04-17 13:13:39 -06:00
|
|
|
if (*cur != ttMove && filter())
|
|
|
|
return *cur++;
|
2009-08-30 02:42:55 -06:00
|
|
|
|
2019-04-17 13:13:39 -06:00
|
|
|
cur++;
|
2018-03-18 17:56:19 -06:00
|
|
|
}
|
2019-04-17 13:13:39 -06:00
|
|
|
return MOVE_NONE;
|
2018-03-18 17:56:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/// MovePicker::next_move() is the most important method of the MovePicker class. It
|
2018-03-20 18:48:31 -06:00
|
|
|
/// returns a new pseudo legal move every time it is called until there are no more
|
|
|
|
/// moves left, picking the move with the highest score from a list of generated moves.
|
2018-03-18 17:56:19 -06:00
|
|
|
Move MovePicker::next_move(bool skipQuiets) {
|
2018-03-11 19:47:35 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
top:
|
2016-09-10 13:37:36 -06:00
|
|
|
switch (stage) {
|
2010-02-05 10:17:52 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case MAIN_TT:
|
|
|
|
case EVASION_TT:
|
|
|
|
case QSEARCH_TT:
|
|
|
|
case PROBCUT_TT:
|
2016-09-10 13:37:36 -06:00
|
|
|
++stage;
|
|
|
|
return ttMove;
|
2010-02-05 10:17:52 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case CAPTURE_INIT:
|
|
|
|
case PROBCUT_INIT:
|
|
|
|
case QCAPTURE_INIT:
|
2018-03-27 08:44:47 -06:00
|
|
|
cur = endBadCaptures = moves;
|
2016-09-10 13:37:36 -06:00
|
|
|
endMoves = generate<CAPTURES>(pos, cur);
|
2018-03-27 08:44:47 -06:00
|
|
|
|
2016-09-10 13:37:36 -06:00
|
|
|
score<CAPTURES>();
|
|
|
|
++stage;
|
2018-03-18 17:56:19 -06:00
|
|
|
goto top;
|
2018-02-25 04:49:03 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case GOOD_CAPTURE:
|
2018-03-27 08:44:47 -06:00
|
|
|
if (select<Best>([&](){
|
2019-04-17 13:13:39 -06:00
|
|
|
return pos.see_ge(*cur, Value(-55 * cur->value / 1024)) ?
|
2018-03-27 08:44:47 -06:00
|
|
|
// Move losing capture to endBadCaptures to be tried later
|
2019-04-17 13:13:39 -06:00
|
|
|
true : (*endBadCaptures++ = *cur, false); }))
|
|
|
|
return *(cur - 1);
|
2018-03-11 19:47:35 -06:00
|
|
|
|
2018-03-20 18:48:31 -06:00
|
|
|
// Prepare the pointers to loop over the refutations array
|
2018-03-27 08:44:47 -06:00
|
|
|
cur = std::begin(refutations);
|
|
|
|
endMoves = std::end(refutations);
|
2018-03-20 18:48:31 -06:00
|
|
|
|
2018-03-11 19:47:35 -06:00
|
|
|
// If the countermove is the same as a killer, skip it
|
2018-03-20 18:48:31 -06:00
|
|
|
if ( refutations[0].move == refutations[2].move
|
|
|
|
|| refutations[1].move == refutations[2].move)
|
|
|
|
--endMoves;
|
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2016-09-10 13:37:36 -06:00
|
|
|
|
2018-03-20 18:48:31 -06:00
|
|
|
case REFUTATION:
|
2019-04-17 13:13:39 -06:00
|
|
|
if (select<Next>([&](){ return *cur != MOVE_NONE
|
|
|
|
&& !pos.capture(*cur)
|
|
|
|
&& pos.pseudo_legal(*cur); }))
|
|
|
|
return *(cur - 1);
|
2018-03-20 18:48:31 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2016-09-10 13:37:36 -06:00
|
|
|
|
|
|
|
case QUIET_INIT:
|
2019-06-17 15:35:03 -06:00
|
|
|
if (!skipQuiets)
|
|
|
|
{
|
|
|
|
cur = endBadCaptures;
|
|
|
|
endMoves = generate<QUIETS>(pos, cur);
|
2018-03-27 08:44:47 -06:00
|
|
|
|
2019-06-17 15:35:03 -06:00
|
|
|
score<QUIETS>();
|
2019-10-05 08:42:36 -06:00
|
|
|
partial_insertion_sort(cur, endMoves, -3000 * depth);
|
2019-06-17 15:35:03 -06:00
|
|
|
}
|
Bonus for double attacks on unsupported pawns
This is a functional change that rewards double attacks on an unsupported pawns.
STC (non-functional difference)
LLR: 2.96 (-2.94,2.94) [0.50,4.50]
Total: 83276 W: 18981 L: 18398 D: 45897
http://tests.stockfishchess.org/tests/view/5d0970500ebc5925cf0a77d4
LTC (incomplete looping version)
LLR: 0.50 (-2.94,2.94) [0.00,3.50]
Total: 82999 W: 14244 L: 13978 D: 54777
http://tests.stockfishchess.org/tests/view/5d0a8d480ebc5925cf0a8d58
LTC (completed non-looping version).
LLR: 2.96 (-2.94,2.94) [0.00,3.50]
Total: 223381 W: 38323 L: 37512 D: 147546
http://tests.stockfishchess.org/tests/view/5d0e80510ebc5925cf0ad320
Closes https://github.com/official-stockfish/Stockfish/pull/2205
Bench 3633546
----------------------------------
Comments by Alain SAVARD:
interesting result ! I would have expected that search would resolve such positions
correctly on the very next move. This is not a very common pattern, and when it happens,
it will quickly disappear. So I'm quite surprised that it passed LTC.
I would be even more surprised if this would resist a simplification.
Anyway, let's try to imagine a few cases.
a) If you have White d5 f5 against Black e6, and White to move
last move by Black was probably a capture on e6 and White is about to recapture on e6
b) If you have White d5 f5 against e6, and Black to move
last move by White was possibly a capture on d5 or f5
or the pawn on e6 was pinned or could not move for some reason.
and white wants to blast open the position and just pushed d4-d5 or f4-f5
Some possible follow-ups
a) Motif is so rare that the popcount() can be safely replaced with a bool()
But this would not pass a SPRT[0,4],
So try a simplification with bool() and also without the & ~theirAttacks
b) If it works, we probably can simply have this in the loop
if (lever) score += S(0, 20);
c) remove all this and tweak something in search for pawn captures (priority, SEE, extension,..)
2019-06-27 01:45:53 -06:00
|
|
|
|
2016-09-10 13:37:36 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2011-04-16 04:24:30 -06:00
|
|
|
|
2016-09-10 13:37:36 -06:00
|
|
|
case QUIET:
|
2018-03-18 17:56:19 -06:00
|
|
|
if ( !skipQuiets
|
2019-04-17 13:13:39 -06:00
|
|
|
&& select<Next>([&](){return *cur != refutations[0].move
|
|
|
|
&& *cur != refutations[1].move
|
|
|
|
&& *cur != refutations[2].move;}))
|
|
|
|
return *(cur - 1);
|
2018-03-18 17:56:19 -06:00
|
|
|
|
2018-03-20 18:48:31 -06:00
|
|
|
// Prepare the pointers to loop over the bad captures
|
2018-03-27 08:44:47 -06:00
|
|
|
cur = moves;
|
|
|
|
endMoves = endBadCaptures;
|
|
|
|
|
2016-09-10 13:37:36 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2009-08-30 02:42:55 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case BAD_CAPTURE:
|
2019-01-01 05:36:56 -07:00
|
|
|
return select<Next>([](){ return true; });
|
2016-09-10 13:37:36 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case EVASION_INIT:
|
2016-09-10 13:37:36 -06:00
|
|
|
cur = moves;
|
|
|
|
endMoves = generate<EVASIONS>(pos, cur);
|
2018-03-27 08:44:47 -06:00
|
|
|
|
2016-10-16 07:20:05 -06:00
|
|
|
score<EVASIONS>();
|
2016-09-10 13:37:36 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2009-10-20 04:38:20 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case EVASION:
|
2019-01-01 05:36:56 -07:00
|
|
|
return select<Best>([](){ return true; });
|
2016-09-15 00:38:20 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case PROBCUT:
|
2019-04-17 13:13:39 -06:00
|
|
|
return select<Best>([&](){ return pos.see_ge(*cur, threshold); });
|
2012-01-21 15:32:48 -07:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case QCAPTURE:
|
2018-03-27 08:44:47 -06:00
|
|
|
if (select<Best>([&](){ return depth > DEPTH_QS_RECAPTURES
|
2019-04-17 13:13:39 -06:00
|
|
|
|| to_sq(*cur) == recaptureSquare; }))
|
|
|
|
return *(cur - 1);
|
2018-03-18 17:56:19 -06:00
|
|
|
|
|
|
|
// If we did not find any move and we do not try checks, we have finished
|
|
|
|
if (depth != DEPTH_QS_CHECKS)
|
|
|
|
return MOVE_NONE;
|
|
|
|
|
|
|
|
++stage;
|
|
|
|
/* fallthrough */
|
|
|
|
|
|
|
|
case QCHECK_INIT:
|
2016-09-15 00:38:20 -06:00
|
|
|
cur = moves;
|
|
|
|
endMoves = generate<QUIET_CHECKS>(pos, cur);
|
2018-03-27 08:44:47 -06:00
|
|
|
|
2016-09-15 00:38:20 -06:00
|
|
|
++stage;
|
2017-04-28 09:30:14 -06:00
|
|
|
/* fallthrough */
|
2016-09-15 00:38:20 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
case QCHECK:
|
2019-01-01 05:36:56 -07:00
|
|
|
return select<Next>([](){ return true; });
|
2009-08-27 01:12:51 -06:00
|
|
|
}
|
2016-09-10 13:37:36 -06:00
|
|
|
|
2018-03-18 17:56:19 -06:00
|
|
|
assert(false);
|
|
|
|
return MOVE_NONE; // Silence warning
|
2009-08-27 01:12:51 -06:00
|
|
|
}
|