mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Spread usage of pos.piece_moved()
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4aadd1e401
commit
50edb7cd73
5 changed files with 11 additions and 19 deletions
|
@ -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))
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue