]> git.sesse.net Git - stockfish/commitdiff
Spread usage of pos.piece_moved()
authorMarco Costalba <mcostalba@gmail.com>
Mon, 13 Feb 2012 08:17:56 +0000 (09:17 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 19 Feb 2012 11:20:29 +0000 (12:20 +0100)
No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/move.cpp
src/movepick.cpp
src/position.cpp
src/position.h
src/search.cpp

index a60506fd7c88cebb04ff323f2a92416f7434d698..f589889b444ca2bc081f69465a59520a2405d44d 100644 (file)
@@ -84,7 +84,7 @@ const string move_to_san(Position& pos, Move m) {
   bool ambiguousMove, ambiguousFile, ambiguousRank;
   Square sq, from = from_sq(m);
   Square to = to_sq(m);
-  PieceType pt = type_of(pos.piece_on(from));
+  PieceType pt = type_of(pos.piece_moved(m));
   string san;
 
   if (is_castle(m))
index 37775faa33aa666e8b0bea1b4eb9e9d23cee2690..1eb6d54ec35b5d826a8ea5a6d31b5e5dd52627cc 100644 (file)
@@ -174,13 +174,11 @@ void MovePicker::score_captures() {
 void MovePicker::score_noncaptures() {
 
   Move m;
-  Square from;
 
   for (MoveStack* cur = moves; cur != lastMove; cur++)
   {
       m = cur->move;
-      from = from_sq(m);
-      cur->score = H.value(pos.piece_on(from), to_sq(m));
+      cur->score = H.value(pos.piece_moved(m), to_sq(m));
   }
 }
 
index f4b051ed762a31ac1b1ff48aa72bc82867d6e798..9fde122662c5ea80e56e91e4e0323b61af938dfb 100644 (file)
@@ -420,7 +420,7 @@ bool Position::move_attacks_square(Move m, Square s) const {
   Bitboard occ, xray;
   Square from = from_sq(m);
   Square to = to_sq(m);
-  Piece piece = piece_on(from);
+  Piece piece = piece_moved(m);
 
   assert(!square_is_empty(from));
 
@@ -452,7 +452,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   Color us = sideToMove;
   Square from = from_sq(m);
 
-  assert(color_of(piece_on(from)) == us);
+  assert(color_of(piece_moved(m)) == us);
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // En passant captures are a tricky special case. Because they are rather
@@ -467,7 +467,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
       Bitboard b = occupied_squares();
 
       assert(to == ep_square());
-      assert(piece_on(from) == make_piece(us, PAWN));
+      assert(piece_moved(m) == make_piece(us, PAWN));
       assert(piece_on(capsq) == make_piece(them, PAWN));
       assert(piece_on(to) == NO_PIECE);
 
@@ -517,7 +517,7 @@ bool Position::is_pseudo_legal(const Move m) const {
   Color them = ~sideToMove;
   Square from = from_sq(m);
   Square to = to_sq(m);
-  Piece pc = piece_on(from);
+  Piece pc = piece_moved(m);
 
   // Use a slower but simpler function for uncommon cases
   if (is_special(m))
@@ -608,11 +608,11 @@ bool Position::is_pseudo_legal(const Move m) const {
   {
       // In case of king moves under check we have to remove king so to catch
       // as invalid moves like b1a1 when opposite queen is on c1.
-      if (type_of(piece_on(from)) == KING)
+      if (type_of(pc) == KING)
       {
           Bitboard b = occupied_squares();
           b ^= from;
-          if (attackers_to(to_sq(m), b) & pieces(~us))
+          if (attackers_to(to, b) & pieces(~us))
               return false;
       }
       else
@@ -625,7 +625,7 @@ bool Position::is_pseudo_legal(const Move m) const {
 
           // Our move must be a blocking evasion or a capture of the checking piece
           target = squares_between(checksq, king_square(us)) | checkers();
-          if (!(target & to_sq(m)))
+          if (!(target & to))
               return false;
       }
   }
@@ -1224,13 +1224,10 @@ int Position::see_sign(Move m) const {
 
   assert(is_ok(m));
 
-  Square from = from_sq(m);
-  Square to = to_sq(m);
-
   // Early return if SEE cannot be negative because captured piece value
   // is not less then capturing one. Note that king moves always return
   // here because king midgame value is set to 0.
-  if (PieceValueMidgame[piece_on(to)] >= PieceValueMidgame[piece_on(from)])
+  if (PieceValueMidgame[piece_on(to_sq(m))] >= PieceValueMidgame[piece_moved(m)])
       return 1;
 
   return see(m);
index 48e8fbe419baf62ff913f06e2f4a8c44e55bfc7c..2bbd43fdac9016976e1ce5ef05117659022410ca 100644 (file)
@@ -191,10 +191,7 @@ public:
   bool both_color_bishops(Color c) const;
   bool has_pawn_on_7th(Color c) const;
   bool is_chess960() const;
-
-  // Current thread ID searching on the position
   int thread() const;
-
   int64_t nodes_searched() const;
   void set_nodes_searched(int64_t n);
 
index 16efe2db15cc5920fb0966bb64c4a493508bc88a..28e231dd98a0811529b165e14b1671e3d6e47fae 100644 (file)
@@ -1343,7 +1343,7 @@ split_point_start: // At split points actual search starts from here
     them = ~pos.side_to_move();
     ksq = pos.king_square(them);
     kingAtt = pos.attacks_from<KING>(ksq);
-    pc = pos.piece_on(from);
+    pc = pos.piece_moved(move);
 
     occ = pos.occupied_squares() & ~(1ULL << from) & ~(1ULL << ksq);
     oldAtt = pos.attacks_from(pc, from, occ);