#include "tbcore.cpp"
namespace Zobrist {
- extern Key psq[COLOR_NB][PIECE_TYPE_NB][SQUARE_NB];
+ extern Key psq[PIECE_NB][SQUARE_NB];
}
int Tablebases::MaxCardinality = 0;
color = !mirror ? WHITE : BLACK;
for (pt = PAWN; pt <= KING; ++pt)
for (i = popcount(pos.pieces(color, pt)); i > 0; i--)
- key ^= Zobrist::psq[WHITE][pt][i - 1];
+ key ^= Zobrist::psq[make_piece(WHITE, pt)][i - 1];
color = ~color;
for (pt = PAWN; pt <= KING; ++pt)
for (i = popcount(pos.pieces(color, pt)); i > 0; i--)
- key ^= Zobrist::psq[BLACK][pt][i - 1];
+ key ^= Zobrist::psq[make_piece(BLACK, pt)][i - 1];
return key;
}
color = !mirror ? 0 : 8;
for (pt = PAWN; pt <= KING; ++pt)
for (i = 0; i < pcs[color + pt]; i++)
- key ^= Zobrist::psq[WHITE][pt][i];
+ key ^= Zobrist::psq[make_piece(WHITE, pt)][i];
color ^= 8;
for (pt = PAWN; pt <= KING; ++pt)
for (i = 0; i < pcs[color + pt]; i++)
- key ^= Zobrist::psq[BLACK][pt][i];
+ key ^= Zobrist::psq[make_piece(BLACK, pt)][i];
return key;
}
key = pos.material_key();
// Test for KvK.
- if (key == (Zobrist::psq[WHITE][KING][0] ^ Zobrist::psq[BLACK][KING][0]))
+ if (key == (Zobrist::psq[W_KING][0] ^ Zobrist::psq[B_KING][0]))
return 0;
ptr2 = TB_hash[key >> (64 - TBHASHBITS)];
} else
end = generate<EVASIONS>(pos, stack);
- CheckInfo ci(pos);
-
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (!pos.capture(capture) || type_of(capture) == ENPASSANT
- || !pos.legal(capture, ci.pinned))
+ || !pos.legal(capture))
continue;
- pos.do_move(capture, st, 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;
else
end = generate<EVASIONS>(pos, stack);
- CheckInfo ci(pos);
-
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
- || !pos.legal(capture, ci.pinned))
+ || !pos.legal(capture))
continue;
- pos.do_move(capture, st, 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;
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) == ENPASSANT) continue;
- if (pos.legal(capture, ci.pinned)) break;
+ if (pos.legal(capture)) break;
}
if (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
- if (pos.legal(move, ci.pinned))
+ if (pos.legal(move))
break;
}
}
ExtMove stack[192];
ExtMove *moves, *end = NULL;
StateInfo st;
- CheckInfo ci(pos);
if (wdl > 0) {
// Generate at least all legal non-capturing pawn moves
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (type_of(pos.moved_piece(move)) != PAWN || pos.capture(move)
- || !pos.legal(move, ci.pinned))
+ || !pos.legal(move))
continue;
- pos.do_move(move, st, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move));
int v = -Tablebases::probe_wdl(pos, success);
pos.undo_move(move);
if (*success == 0) return 0;
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (pos.capture(move) || type_of(pos.moved_piece(move)) == PAWN
- || !pos.legal(move, ci.pinned))
+ || !pos.legal(move))
continue;
- pos.do_move(move, st, 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;
for (moves = stack; moves < end; moves++) {
int v;
Move move = moves->move;
- if (!pos.legal(move, ci.pinned))
+ if (!pos.legal(move))
continue;
- pos.do_move(move, st, pos.gives_check(move, ci));
+ pos.do_move(move, st, pos.gives_check(move));
if (st.rule50 == 0) {
if (wdl == -2) v = -1;
else {
end = generate<CAPTURES>(pos, stack);
else
end = generate<EVASIONS>(pos, stack);
- CheckInfo ci(pos);
for (moves = stack; moves < end; moves++) {
Move capture = moves->move;
if (type_of(capture) != ENPASSANT
- || !pos.legal(capture, ci.pinned))
+ || !pos.legal(capture))
continue;
- pos.do_move(capture, st, 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;
for (moves = stack; moves < end; moves++) {
Move move = moves->move;
if (type_of(move) == ENPASSANT) continue;
- if (pos.legal(move, ci.pinned)) break;
+ if (pos.legal(move)) break;
}
if (moves == end && !pos.checkers()) {
end = generate<QUIETS>(pos, end);
for (; moves < end; moves++) {
Move move = moves->move;
- if (pos.legal(move, ci.pinned))
+ if (pos.legal(move))
break;
}
}
if (!success) return false;
StateInfo st;
- CheckInfo ci(pos);
// Probe each move.
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));
+ pos.do_move(move, st, pos.gives_check(move));
int v = 0;
if (pos.checkers() && dtz > 0) {
ExtMove s[192];
score = wdl_to_Value[wdl + 2];
StateInfo st;
- CheckInfo ci(pos);
int best = -2;
// Probe each move.
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));
+ pos.do_move(move, st, pos.gives_check(move));
int v = -Tablebases::probe_wdl(pos, &success);
pos.undo_move(move);
if (!success) return false;