From 50edb7cd7353e24e17da8f428e4b12375cf684f7 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 13 Feb 2012 09:17:56 +0100 Subject: [PATCH] Spread usage of pos.piece_moved() No functional change. Signed-off-by: Marco Costalba --- src/move.cpp | 2 +- src/movepick.cpp | 4 +--- src/position.cpp | 19 ++++++++----------- src/position.h | 3 --- src/search.cpp | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/move.cpp b/src/move.cpp index a60506fd..f589889b 100644 --- a/src/move.cpp +++ b/src/move.cpp @@ -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)) diff --git a/src/movepick.cpp b/src/movepick.cpp index 37775faa..1eb6d54e 100644 --- a/src/movepick.cpp +++ b/src/movepick.cpp @@ -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)); } } diff --git a/src/position.cpp b/src/position.cpp index f4b051ed..9fde1226 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -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); diff --git a/src/position.h b/src/position.h index 48e8fbe4..2bbd43fd 100644 --- a/src/position.h +++ b/src/position.h @@ -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); diff --git a/src/search.cpp b/src/search.cpp index 16efe2db..28e231dd 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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(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); -- 2.39.2