// 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
- for (i = popcount<Max15>(pos.pieces(color, pt)); i > 0; i--)
- key ^= Zobrist::psq[WHITE][pt][i - 1];
+ for (i = popcount(pos.pieces(color, pt)); i > 0; i--)
+ key ^= Zobrist::psq[make_piece(WHITE, pt)][i - 1];
- for (i = popcount<Max15>(pos.pieces(color, pt)); i > 0; i--)
- key ^= Zobrist::psq[BLACK][pt][i - 1];
+ for (i = popcount(pos.pieces(color, pt)); i > 0; i--)
+ key ^= Zobrist::psq[make_piece(BLACK, pt)][i - 1];
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (!pos.capture(capture) || type_of(capture) == ENPASSANT
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (!pos.capture(capture) || type_of(capture) == ENPASSANT
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture));
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;
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture));
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;
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) == ENPASSANT) continue;
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) == ENPASSANT) continue;
}
if (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
}
if (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (type_of(pos.moved_piece(move)) != PAWN || pos.capture(move)
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (type_of(pos.moved_piece(move)) != PAWN || pos.capture(move)
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
- int v = -probe_ab(pos, -2, -wdl + 1, success);
+ pos.do_move(move, st, pos.gives_check(move));
+ int v = -Tablebases::probe_wdl(pos, success);
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN
- pos.do_move(move, st, ci, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move));
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));
end = generate<CAPTURES>(pos, stack);
else
end = generate<EVASIONS>(pos, stack);
end = generate<CAPTURES>(pos, stack);
else
end = generate<EVASIONS>(pos, stack);
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
- pos.do_move(capture, st, ci, pos.gives_check(capture, ci));
+ pos.do_move(capture, st, pos.gives_check(capture));
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 (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
}
if (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
//
// 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));
// 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));
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];