From: Marco Costalba Date: Tue, 28 Jun 2011 12:59:33 +0000 (+0200) Subject: Change Position::pst() signature X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=8094b2add88cd681f3cdc7896990633b54c6ff48 Change Position::pst() signature To be more clear what is the underlying table. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/position.cpp b/src/position.cpp index bc94fe82..c9da8d8b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -164,10 +164,10 @@ void Position::from_fen(const string& fen, bool isChess960) { std::istringstream ss(fen); clear(); - ss >> token >> std::noskipws; + ss >> std::noskipws; // 1. Piece placement - while (!isspace(token)) + while ((ss >> token) && !isspace(token)) { if (token == '/') 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); sq++; } - - ss >> token; } // 2. Active color @@ -245,8 +243,8 @@ void Position::set_castling_rights(char token) { Square sqA = relative_square(c, SQ_A1); Square sqH = relative_square(c, SQ_H1); - Square rsq, ksq = king_square(c); + token = toupper(token); 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]; // 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]; @@ -1077,7 +1075,7 @@ void Position::do_capture_move(Key& key, PieceType capture, Color them, Square t 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]--; @@ -1559,25 +1557,24 @@ void Position::clear() { 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); - 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++) + { + board[sq] = PIECE_NONE; castleRightsMask[sq] = ALL_CASTLES; - + } sideToMove = WHITE; + fullMoves = 1; + nodes = 0; } @@ -1593,9 +1590,9 @@ void Position::put_piece(Piece p, Square 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. } @@ -1676,7 +1673,7 @@ Score Position::compute_value() const { { 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); diff --git a/src/position.h b/src/position.h index 406dca5a..b30b1ffe 100644 --- a/src/position.h +++ b/src/position.h @@ -268,7 +268,7 @@ private: 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; @@ -447,8 +447,8 @@ inline Key Position::get_material_key() const { 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) {