To be more clear what is the underlying table.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
std::istringstream ss(fen);
clear();
std::istringstream ss(fen);
clear();
- ss >> token >> std::noskipws;
- while (!isspace(token))
+ while ((ss >> token) && !isspace(token))
{
if (token == '/')
sq -= Square(16); // Jump back of 2 rows
{
if (token == '/')
sq -= Square(16); // Jump back of 2 rows
put_piece(Piece(p), sq);
sq++;
}
put_piece(Piece(p), sq);
sq++;
}
Square sqA = relative_square(c, SQ_A1);
Square sqH = relative_square(c, SQ_H1);
Square sqA = relative_square(c, SQ_A1);
Square sqH = relative_square(c, SQ_H1);
Square rsq, ksq = king_square(c);
Square rsq, ksq = king_square(c);
token = toupper(token);
if (token == 'K')
token = toupper(token);
if (token == 'K')
st->pawnKey ^= zobrist[us][PAWN][to];
// Partially revert and update incremental scores
st->pawnKey ^= zobrist[us][PAWN][to];
// Partially revert and update incremental scores
- st->value -= pst(us, PAWN, to);
- st->value += pst(us, promotion, to);
+ st->value -= pst(make_piece(us, PAWN), to);
+ st->value += pst(make_piece(us, promotion), to);
// Update material
st->npMaterial[us] += PieceValueMidgame[promotion];
// Update material
st->npMaterial[us] += PieceValueMidgame[promotion];
key ^= zobrist[them][capture][capsq];
// Update incremental scores
key ^= zobrist[them][capture][capsq];
// Update incremental scores
- st->value -= pst(them, capture, capsq);
+ st->value -= pst(make_piece(them, capture), capsq);
// Update piece count
pieceCount[them][capture]--;
// Update piece count
pieceCount[them][capture]--;
st = &startState;
memset(st, 0, sizeof(StateInfo));
st->epSquare = SQ_NONE;
st = &startState;
memset(st, 0, sizeof(StateInfo));
st->epSquare = SQ_NONE;
- fullMoves = 1;
- nodes = 0;
memset(byColorBB, 0, sizeof(Bitboard) * 2);
memset(byTypeBB, 0, sizeof(Bitboard) * 8);
memset(pieceCount, 0, sizeof(int) * 2 * 8);
memset(index, 0, sizeof(int) * 64);
memset(byColorBB, 0, sizeof(Bitboard) * 2);
memset(byTypeBB, 0, sizeof(Bitboard) * 8);
memset(pieceCount, 0, sizeof(int) * 2 * 8);
memset(index, 0, sizeof(int) * 64);
- for (int i = 0; i < 64; i++)
- board[i] = PIECE_NONE;
-
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
for (int i = 0; i < 8; i++)
for (int j = 0; j < 16; j++)
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
+ {
+ board[sq] = PIECE_NONE;
castleRightsMask[sq] = ALL_CASTLES;
castleRightsMask[sq] = ALL_CASTLES;
+ fullMoves = 1;
+ nodes = 0;
index[s] = pieceCount[c][pt]++;
pieceList[c][pt][index[s]] = s;
index[s] = pieceCount[c][pt]++;
pieceList[c][pt][index[s]] = s;
- set_bit(&(byTypeBB[pt]), s);
- set_bit(&(byColorBB[c]), s);
- set_bit(&(byTypeBB[0]), s); // HACK: byTypeBB[0] contains all occupied squares.
+ set_bit(&byTypeBB[pt], s);
+ set_bit(&byColorBB[c], s);
+ set_bit(&byTypeBB[0], s); // HACK: byTypeBB[0] contains all occupied squares.
{
b = pieces(pt, c);
while (b)
{
b = pieces(pt, c);
while (b)
- result += pst(c, pt, pop_1st_bit(&b));
+ result += pst(make_piece(c, pt), pop_1st_bit(&b));
}
result += (side_to_move() == WHITE ? TempoValue / 2 : -TempoValue / 2);
}
result += (side_to_move() == WHITE ? TempoValue / 2 : -TempoValue / 2);
Key compute_material_key() const;
// Computing incremental evaluation scores and material counts
Key compute_material_key() const;
// Computing incremental evaluation scores and material counts
- static Score pst(Color c, PieceType pt, Square s);
+ static Score pst(Piece p, Square s);
Score compute_value() const;
Value compute_non_pawn_material(Color c) const;
Score compute_value() const;
Value compute_non_pawn_material(Color c) const;
return st->materialKey;
}
return st->materialKey;
}
-inline Score Position::pst(Color c, PieceType pt, Square s) {
- return PieceSquareTable[make_piece(c, pt)][s];
+inline Score Position::pst(Piece p, Square s) {
+ return PieceSquareTable[p][s];
}
inline Score Position::pst_delta(Piece piece, Square from, Square to) {
}
inline Score Position::pst_delta(Piece piece, Square from, Square to) {