mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Change Position::pst() signature
To be more clear what is the underlying table. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ffb638995d
commit
8094b2add8
2 changed files with 18 additions and 21 deletions
|
@ -164,10 +164,10 @@ void Position::from_fen(const string& fen, bool isChess960) {
|
||||||
std::istringstream ss(fen);
|
std::istringstream ss(fen);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
ss >> token >> std::noskipws;
|
ss >> std::noskipws;
|
||||||
|
|
||||||
// 1. Piece placement
|
// 1. Piece placement
|
||||||
while (!isspace(token))
|
while ((ss >> token) && !isspace(token))
|
||||||
{
|
{
|
||||||
if (token == '/')
|
if (token == '/')
|
||||||
sq -= Square(16); // Jump back of 2 rows
|
sq -= Square(16); // Jump back of 2 rows
|
||||||
|
@ -180,8 +180,6 @@ void Position::from_fen(const string& fen, bool isChess960) {
|
||||||
put_piece(Piece(p), sq);
|
put_piece(Piece(p), sq);
|
||||||
sq++;
|
sq++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ss >> token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Active color
|
// 2. Active color
|
||||||
|
@ -245,8 +243,8 @@ void Position::set_castling_rights(char token) {
|
||||||
|
|
||||||
Square sqA = relative_square(c, SQ_A1);
|
Square sqA = relative_square(c, SQ_A1);
|
||||||
Square sqH = relative_square(c, SQ_H1);
|
Square sqH = relative_square(c, SQ_H1);
|
||||||
|
|
||||||
Square rsq, ksq = king_square(c);
|
Square rsq, ksq = king_square(c);
|
||||||
|
|
||||||
token = toupper(token);
|
token = toupper(token);
|
||||||
|
|
||||||
if (token == 'K')
|
if (token == 'K')
|
||||||
|
@ -985,8 +983,8 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
st->pawnKey ^= zobrist[us][PAWN][to];
|
st->pawnKey ^= zobrist[us][PAWN][to];
|
||||||
|
|
||||||
// Partially revert and update incremental scores
|
// Partially revert and update incremental scores
|
||||||
st->value -= pst(us, PAWN, to);
|
st->value -= pst(make_piece(us, PAWN), to);
|
||||||
st->value += pst(us, promotion, to);
|
st->value += pst(make_piece(us, promotion), to);
|
||||||
|
|
||||||
// Update material
|
// Update material
|
||||||
st->npMaterial[us] += PieceValueMidgame[promotion];
|
st->npMaterial[us] += PieceValueMidgame[promotion];
|
||||||
|
@ -1077,7 +1075,7 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t
|
||||||
key ^= zobrist[them][capture][capsq];
|
key ^= zobrist[them][capture][capsq];
|
||||||
|
|
||||||
// Update incremental scores
|
// Update incremental scores
|
||||||
st->value -= pst(them, capture, capsq);
|
st->value -= pst(make_piece(them, capture), capsq);
|
||||||
|
|
||||||
// Update piece count
|
// Update piece count
|
||||||
pieceCount[them][capture]--;
|
pieceCount[them][capture]--;
|
||||||
|
@ -1559,25 +1557,24 @@ void Position::clear() {
|
||||||
st = &startState;
|
st = &startState;
|
||||||
memset(st, 0, sizeof(StateInfo));
|
memset(st, 0, sizeof(StateInfo));
|
||||||
st->epSquare = SQ_NONE;
|
st->epSquare = SQ_NONE;
|
||||||
fullMoves = 1;
|
|
||||||
nodes = 0;
|
|
||||||
|
|
||||||
memset(byColorBB, 0, sizeof(Bitboard) * 2);
|
memset(byColorBB, 0, sizeof(Bitboard) * 2);
|
||||||
memset(byTypeBB, 0, sizeof(Bitboard) * 8);
|
memset(byTypeBB, 0, sizeof(Bitboard) * 8);
|
||||||
memset(pieceCount, 0, sizeof(int) * 2 * 8);
|
memset(pieceCount, 0, sizeof(int) * 2 * 8);
|
||||||
memset(index, 0, sizeof(int) * 64);
|
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 i = 0; i < 8; i++)
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++)
|
||||||
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
|
pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE;
|
||||||
|
|
||||||
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
|
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
|
||||||
|
{
|
||||||
|
board[sq] = PIECE_NONE;
|
||||||
castleRightsMask[sq] = ALL_CASTLES;
|
castleRightsMask[sq] = ALL_CASTLES;
|
||||||
|
}
|
||||||
sideToMove = WHITE;
|
sideToMove = WHITE;
|
||||||
|
fullMoves = 1;
|
||||||
|
nodes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1593,9 +1590,9 @@ void Position::put_piece(Piece p, Square s) {
|
||||||
index[s] = pieceCount[c][pt]++;
|
index[s] = pieceCount[c][pt]++;
|
||||||
pieceList[c][pt][index[s]] = s;
|
pieceList[c][pt][index[s]] = s;
|
||||||
|
|
||||||
set_bit(&(byTypeBB[pt]), s);
|
set_bit(&byTypeBB[pt], s);
|
||||||
set_bit(&(byColorBB[c]), s);
|
set_bit(&byColorBB[c], s);
|
||||||
set_bit(&(byTypeBB[0]), s); // HACK: byTypeBB[0] contains all occupied squares.
|
set_bit(&byTypeBB[0], s); // HACK: byTypeBB[0] contains all occupied squares.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1676,7 +1673,7 @@ Score Position::compute_value() const {
|
||||||
{
|
{
|
||||||
b = pieces(pt, c);
|
b = pieces(pt, c);
|
||||||
while (b)
|
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);
|
||||||
|
|
|
@ -268,7 +268,7 @@ private:
|
||||||
Key compute_material_key() const;
|
Key compute_material_key() const;
|
||||||
|
|
||||||
// Computing incremental evaluation scores and material counts
|
// 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;
|
Score compute_value() const;
|
||||||
Value compute_non_pawn_material(Color c) const;
|
Value compute_non_pawn_material(Color c) const;
|
||||||
|
|
||||||
|
@ -447,8 +447,8 @@ inline Key Position::get_material_key() const {
|
||||||
return st->materialKey;
|
return st->materialKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Score Position::pst(Color c, PieceType pt, Square s) {
|
inline Score Position::pst(Piece p, Square s) {
|
||||||
return PieceSquareTable[make_piece(c, pt)][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) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue