// Given a position with 6 or fewer pieces, produce a text string
// of the form KQPvKRP, where "KQP" represents the white pieces if
// Given a position with 6 or fewer pieces, produce a text string
// of the form KQPvKRP, where "KQP" represents the white pieces if
color = !mirror ? WHITE : BLACK;
for (pt = KING; pt >= PAWN; --pt)
for (i = popcount<Max15>(pos.pieces(color, pt)); i > 0; i--)
color = !mirror ? WHITE : BLACK;
for (pt = KING; pt >= PAWN; --pt)
for (i = popcount<Max15>(pos.pieces(color, pt)); i > 0; i--)
if (!pos.capture(capture) || type_of(capture) == ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
if (!pos.capture(capture) || type_of(capture) == ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture, ci));
v = -probe_ab(pos, -beta, -alpha, success);
pos.undo_move(capture);
if (*success == 0) return 0;
v = -probe_ab(pos, -beta, -alpha, success);
pos.undo_move(capture);
if (*success == 0) return 0;
if (type_of(capture) != ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
if (type_of(capture) != ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture, ci));
int v0 = -probe_ab(pos, -2, 2, success);
pos.undo_move(capture);
if (*success == 0) return 0;
int v0 = -probe_ab(pos, -2, 2, success);
pos.undo_move(capture);
if (*success == 0) return 0;
if (type_of(pos.moved_piece(move)) != PAWN || pos.capture(move)
|| !pos.legal(move, ci.pinned))
continue;
if (type_of(pos.moved_piece(move)) != PAWN || pos.capture(move)
|| !pos.legal(move, ci.pinned))
continue;
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move, ci));
int v = -probe_ab(pos, -2, -wdl + 1, success);
pos.undo_move(move);
if (*success == 0) return 0;
int v = -probe_ab(pos, -2, -wdl + 1, success);
pos.undo_move(move);
if (*success == 0) return 0;
if (pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN
|| !pos.legal(move, ci.pinned))
continue;
if (pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN
|| !pos.legal(move, ci.pinned))
continue;
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move, ci));
int v = -Tablebases::probe_dtz(pos, success);
pos.undo_move(move);
if (*success == 0) return 0;
int v = -Tablebases::probe_dtz(pos, success);
pos.undo_move(move);
if (*success == 0) return 0;
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move, ci));
if (type_of(capture) != ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
if (type_of(capture) != ENPASSANT
|| !pos.legal(capture, ci.pinned))
continue;
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture, ci));
int v0 = -probe_ab(pos, -2, 2, success);
pos.undo_move(capture);
if (*success == 0) return 0;
int v0 = -probe_ab(pos, -2, 2, success);
pos.undo_move(capture);
if (*success == 0) return 0;
//
// A return value false indicates that not all probes were successful and that
// no moves were filtered out.
//
// A return value false indicates that not all probes were successful and that
// no moves were filtered out.
- for (size_t i = 0; i < Search::RootMoves.size(); i++) {
- Move move = Search::RootMoves[i].pv[0];
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ for (size_t i = 0; i < rootMoves.size(); i++) {
+ Move move = rootMoves[i].pv[0];
+ pos.do_move(move, st, pos.gives_check(move, ci));
// If the position is winning or losing, but too few moves left, adjust the
// score to show how close it is to winning or losing.
// NOTE: int(PawnValueEg) is used as scaling factor in score_to_uci().
if (wdl == 1 && dtz <= 100)
// If the position is winning or losing, but too few moves left, adjust the
// score to show how close it is to winning or losing.
// NOTE: int(PawnValueEg) is used as scaling factor in score_to_uci().
if (wdl == 1 && dtz <= 100)
// that stay safely within the 50-move budget, if there are any.
if (!has_repeated(st.previous) && best + cnt50 <= 99)
max = 99 - cnt50;
// that stay safely within the 50-move budget, if there are any.
if (!has_repeated(st.previous) && best + cnt50 <= 99)
max = 99 - cnt50;
if (v < best)
best = v;
}
// Try all moves, unless we approach or have a 50-move rule draw.
if (-best * 2 + cnt50 < 100)
return true;
if (v < best)
best = v;
}
// Try all moves, unless we approach or have a 50-move rule draw.
if (-best * 2 + cnt50 < 100)
return true;
- for (size_t i = 0; i < Search::RootMoves.size(); i++) {
- if (Search::RootMoves[i].score == best)
- Search::RootMoves[j++] = Search::RootMoves[i];
+ for (size_t i = 0; i < rootMoves.size(); i++) {
+ if (rootMoves[i].score == best)
+ rootMoves[j++] = rootMoves[i];
- for (size_t i = 0; i < Search::RootMoves.size(); i++) {
- if (Search::RootMoves[i].score == 0)
- Search::RootMoves[j++] = Search::RootMoves[i];
+ for (size_t i = 0; i < rootMoves.size(); i++) {
+ if (rootMoves[i].score == 0)
+ rootMoves[j++] = rootMoves[i];
//
// A return value false indicates that not all probes were successful and that
// no moves were filtered out.
//
// A return value false indicates that not all probes were successful and that
// no moves were filtered out.
{
int success;
int wdl = Tablebases::probe_wdl(pos, &success);
if (!success) return false;
{
int success;
int wdl = Tablebases::probe_wdl(pos, &success);
if (!success) return false;
- for (size_t i = 0; i < Search::RootMoves.size(); i++) {
- Move move = Search::RootMoves[i].pv[0];
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ for (size_t i = 0; i < rootMoves.size(); i++) {
+ Move move = rootMoves[i].pv[0];
+ pos.do_move(move, st, pos.gives_check(move, ci));
int v = -Tablebases::probe_wdl(pos, &success);
pos.undo_move(move);
if (!success) return false;
int v = -Tablebases::probe_wdl(pos, &success);
pos.undo_move(move);
if (!success) return false;
- for (size_t i = 0; i < Search::RootMoves.size(); i++) {
- if (Search::RootMoves[i].score == best)
- Search::RootMoves[j++] = Search::RootMoves[i];
+ for (size_t i = 0; i < rootMoves.size(); i++) {
+ if (rootMoves[i].score == best)
+ rootMoves[j++] = rootMoves[i];