]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Remove duplicated enum Phase definition
[stockfish] / src / position.cpp
index 8a902502acbee50006dfdd4016272b7a4f4fd032..690ca59bb4789319d53cce58b573ae01e6f159ac 100644 (file)
@@ -42,7 +42,7 @@ Key Position::zobCastle[16];
 Key Position::zobSideToMove;
 Key Position::zobExclusion;
 
-Score Position::PieceSquareTable[16][64];
+Score Position::pieceSquareTable[16][64];
 
 // Material values arrays, indexed by Piece
 const Value PieceValueMidgame[17] = {
@@ -207,7 +207,7 @@ void Position::from_fen(const string& fen, bool isChess960) {
 
   // Various initialisations
   chess960 = isChess960;
-  find_checkers();
+  st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(opposite_color(sideToMove));
 
   st->key = compute_key();
   st->pawnKey = compute_pawn_key();
@@ -245,7 +245,7 @@ void Position::set_castling_rights(char token) {
     Square sqH = relative_square(c, SQ_H1);
     Square rsq, ksq = king_square(c);
 
-    token = toupper(token);
+    token = char(toupper(token));
 
     if (token == 'K')
         for (rsq = sqH; piece_on(rsq) != make_piece(c, ROOK); rsq--) {}
@@ -493,19 +493,6 @@ bool Position::move_attacks_square(Move m, Square s) const {
 }
 
 
-/// Position::find_checkers() computes the checkersBB bitboard, which
-/// contains a nonzero bit for each checking piece (0, 1 or 2). It
-/// currently works by calling Position::attackers_to, which is probably
-/// inefficient. Consider rewriting this function to use the last move
-/// played, like in non-bitboard versions of Glaurung.
-
-void Position::find_checkers() {
-
-  Color us = side_to_move();
-  st->checkersBB = attackers_to(king_square(us)) & pieces(opposite_color(us));
-}
-
-
 /// Position::pl_move_is_legal() tests whether a pseudo-legal move is legal
 
 bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
@@ -1763,11 +1750,11 @@ void Position::init() {
 
   for (Square s = SQ_A1; s <= SQ_H8; s++)
       for (Piece p = WP; p <= WK; p++)
-          PieceSquareTable[p][s] = make_score(MgPST[p][s], EgPST[p][s]);
+          pieceSquareTable[p][s] = make_score(MgPST[p][s], EgPST[p][s]);
 
   for (Square s = SQ_A1; s <= SQ_H8; s++)
       for (Piece p = BP; p <= BK; p++)
-          PieceSquareTable[p][s] = -PieceSquareTable[p-8][flip_square(s)];
+          pieceSquareTable[p][s] = -pieceSquareTable[p-8][flip_square(s)];
 }
 
 
@@ -1807,7 +1794,7 @@ void Position::flip() {
       st->epSquare = flip_square(pos.st->epSquare);
 
   // Checkers
-  find_checkers();
+  st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(opposite_color(sideToMove));
 
   // Hash keys
   st->key = compute_key();