1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Retire Position::type_of_piece_on()

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-06-26 10:28:54 +01:00
parent 351ef5c85b
commit a9782b94e6
6 changed files with 19 additions and 24 deletions

View file

@ -95,7 +95,7 @@ const string move_to_san(Position& pos, Move m) {
bool ambiguousMove, ambiguousFile, ambiguousRank; bool ambiguousMove, ambiguousFile, ambiguousRank;
Square sq, from = move_from(m); Square sq, from = move_from(m);
Square to = move_to(m); Square to = move_to(m);
PieceType pt = pos.type_of_piece_on(from); PieceType pt = type_of_piece(pos.piece_on(from));
string san; string san;
if (m == MOVE_NONE) if (m == MOVE_NONE)

View file

@ -217,7 +217,7 @@ MoveStack* generate<MV_NON_CAPTURE_CHECK>(const Position& pos, MoveStack* mlist)
while (b) while (b)
{ {
from = pop_1st_bit(&b); from = pop_1st_bit(&b);
switch (pos.type_of_piece_on(from)) switch (type_of_piece(pos.piece_on(from)))
{ {
case PAWN: /* Will be generated togheter with pawns direct checks */ break; case PAWN: /* Will be generated togheter with pawns direct checks */ break;
case KNIGHT: mlist = generate_discovered_checks<KNIGHT>(pos, mlist, from); break; case KNIGHT: mlist = generate_discovered_checks<KNIGHT>(pos, mlist, from); break;
@ -267,7 +267,7 @@ MoveStack* generate<MV_EVASION>(const Position& pos, MoveStack* mlist) {
assert(pos.color_of_piece_on(checksq) == opposite_color(us)); assert(pos.color_of_piece_on(checksq) == opposite_color(us));
switch (pos.type_of_piece_on(checksq)) switch (type_of_piece(pos.piece_on(checksq)))
{ {
case BISHOP: sliderAttacks |= BishopPseudoAttacks[checksq]; break; case BISHOP: sliderAttacks |= BishopPseudoAttacks[checksq]; break;
case ROOK: sliderAttacks |= RookPseudoAttacks[checksq]; break; case ROOK: sliderAttacks |= RookPseudoAttacks[checksq]; break;

View file

@ -237,7 +237,7 @@ void MovePicker::score_captures() {
{ {
m = cur->move; m = cur->move;
cur->score = piece_value_midgame(pos.piece_on(move_to(m))) cur->score = piece_value_midgame(pos.piece_on(move_to(m)))
- pos.type_of_piece_on(move_from(m)); - type_of_piece(pos.piece_on(move_from(m)));
if (move_is_promotion(m)) if (move_is_promotion(m))
cur->score += QueenValueMidgame; cur->score += QueenValueMidgame;
@ -276,7 +276,7 @@ void MovePicker::score_evasions() {
cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom cur->score = seeScore - History::MaxValue; // Be sure we are at the bottom
else if (pos.move_is_capture(m)) else if (pos.move_is_capture(m))
cur->score = piece_value_midgame(pos.piece_on(move_to(m))) cur->score = piece_value_midgame(pos.piece_on(move_to(m)))
- pos.type_of_piece_on(move_from(m)) + History::MaxValue; - type_of_piece(pos.piece_on(move_from(m))) + History::MaxValue;
else else
cur->score = H.value(pos.piece_on(move_from(m)), move_to(m)); cur->score = H.value(pos.piece_on(move_from(m)), move_to(m));
} }

View file

@ -582,7 +582,7 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
// If the moving piece is a king, check whether the destination // If the moving piece is a king, check whether the destination
// square is attacked by the opponent. Castling moves are checked // square is attacked by the opponent. Castling moves are checked
// for legality during move generation. // for legality during move generation.
if (type_of_piece_on(from) == KING) if (type_of_piece(piece_on(from)) == KING)
return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us))); return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
// A non-king move is legal if and only if it is not pinned or it // A non-king move is legal if and only if it is not pinned or it
@ -712,7 +712,7 @@ bool Position::move_is_pl(const Move m) const {
{ {
// In case of king moves under check we have to remove king so to catch // 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. // as invalid moves like b1a1 when opposite queen is on c1.
if (type_of_piece_on(from) == KING) if (type_of_piece(piece_on(from)) == KING)
{ {
Bitboard b = occupied_squares(); Bitboard b = occupied_squares();
clear_bit(&b, from); clear_bit(&b, from);
@ -749,7 +749,7 @@ bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
Square from = move_from(m); Square from = move_from(m);
Square to = move_to(m); Square to = move_to(m);
PieceType pt = type_of_piece_on(from); PieceType pt = type_of_piece(piece_on(from));
// Direct check ? // Direct check ?
if (bit_is_set(ci.checkSq[pt], to)) if (bit_is_set(ci.checkSq[pt], to))
@ -918,7 +918,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
Piece piece = piece_on(from); Piece piece = piece_on(from);
PieceType pt = type_of_piece(piece); PieceType pt = type_of_piece(piece);
PieceType capture = ep ? PAWN : type_of_piece_on(to); PieceType capture = ep ? PAWN : type_of_piece(piece_on(to));
assert(color_of_piece_on(from) == us); assert(color_of_piece_on(from) == us);
assert(color_of_piece_on(to) == them || square_is_empty(to)); assert(color_of_piece_on(to) == them || square_is_empty(to));
@ -1255,7 +1255,7 @@ void Position::undo_move(Move m) {
bool ep = move_is_ep(m); bool ep = move_is_ep(m);
bool pm = move_is_promotion(m); bool pm = move_is_promotion(m);
PieceType pt = type_of_piece_on(to); PieceType pt = type_of_piece(piece_on(to));
assert(square_is_empty(from)); assert(square_is_empty(from));
assert(color_of_piece_on(to) == us); assert(color_of_piece_on(to) == us);
@ -1502,16 +1502,16 @@ int Position::see(Move m) const {
from = move_from(m); from = move_from(m);
to = move_to(m); to = move_to(m);
capturedType = type_of_piece_on(to); capturedType = type_of_piece(piece_on(to));
occupied = occupied_squares(); occupied = occupied_squares();
// Handle en passant moves // Handle en passant moves
if (st->epSquare == to && type_of_piece_on(from) == PAWN) if (st->epSquare == to && type_of_piece(piece_on(from)) == PAWN)
{ {
Square capQq = (side_to_move() == WHITE ? to - DELTA_N : to - DELTA_S); Square capQq = (side_to_move() == WHITE ? to - DELTA_N : to - DELTA_S);
assert(capturedType == PIECE_TYPE_NONE); assert(capturedType == PIECE_TYPE_NONE);
assert(type_of_piece_on(capQq) == PAWN); assert(type_of_piece(piece_on(capQq)) == PAWN);
// Remove the captured pawn // Remove the captured pawn
clear_bit(&occupied, capQq); clear_bit(&occupied, capQq);
@ -1536,7 +1536,7 @@ int Position::see(Move m) const {
// capture with the least valuable piece. After each capture, we look for // capture with the least valuable piece. After each capture, we look for
// new X-ray attacks from behind the capturing piece. // new X-ray attacks from behind the capturing piece.
swapList[0] = PieceValueMidgame[capturedType]; swapList[0] = PieceValueMidgame[capturedType];
capturedType = type_of_piece_on(from); capturedType = type_of_piece(piece_on(from));
do { do {
// Locate the least valuable attacker for the side to move. The loop // Locate the least valuable attacker for the side to move. The loop
@ -1645,7 +1645,7 @@ Key Position::compute_key() const {
for (Square s = SQ_A1; s <= SQ_H8; s++) for (Square s = SQ_A1; s <= SQ_H8; s++)
if (square_is_occupied(s)) if (square_is_occupied(s))
result ^= zobrist[color_of_piece_on(s)][type_of_piece_on(s)][s]; result ^= zobrist[color_of_piece_on(s)][type_of_piece(piece_on(s))][s];
if (ep_square() != SQ_NONE) if (ep_square() != SQ_NONE)
result ^= zobEp[ep_square()]; result ^= zobEp[ep_square()];
@ -1923,7 +1923,7 @@ bool Position::is_ok(int* failedStep) const {
{ {
int kingCount[2] = {0, 0}; int kingCount[2] = {0, 0};
for (Square s = SQ_A1; s <= SQ_H8; s++) for (Square s = SQ_A1; s <= SQ_H8; s++)
if (type_of_piece_on(s) == KING) if (type_of_piece(piece_on(s)) == KING)
kingCount[color_of_piece_on(s)]++; kingCount[color_of_piece_on(s)]++;
if (kingCount[0] != 1 || kingCount[1] != 1) if (kingCount[0] != 1 || kingCount[1] != 1)

View file

@ -129,7 +129,6 @@ public:
// The piece on a given square // The piece on a given square
Piece piece_on(Square s) const; Piece piece_on(Square s) const;
PieceType type_of_piece_on(Square s) const;
Color color_of_piece_on(Square s) const; Color color_of_piece_on(Square s) const;
bool square_is_empty(Square s) const; bool square_is_empty(Square s) const;
bool square_is_occupied(Square s) const; bool square_is_occupied(Square s) const;
@ -327,10 +326,6 @@ inline Color Position::color_of_piece_on(Square s) const {
return color_of_piece(piece_on(s)); return color_of_piece(piece_on(s));
} }
inline PieceType Position::type_of_piece_on(Square s) const {
return type_of_piece(piece_on(s));
}
inline bool Position::square_is_empty(Square s) const { inline bool Position::square_is_empty(Square s) const {
return piece_on(s) == PIECE_NONE; return piece_on(s) == PIECE_NONE;
} }

View file

@ -300,7 +300,7 @@ namespace {
if (moveIsCheck && pos.see_sign(m) >= 0) if (moveIsCheck && pos.see_sign(m) >= 0)
result += CheckExtension[PvNode]; result += CheckExtension[PvNode];
if (pos.type_of_piece_on(move_from(m)) == PAWN) if (type_of_piece(pos.piece_on(move_from(m))) == PAWN)
{ {
Color c = pos.side_to_move(); Color c = pos.side_to_move();
if (relative_rank(c, move_to(m)) == RANK_7) if (relative_rank(c, move_to(m)) == RANK_7)
@ -316,7 +316,7 @@ namespace {
} }
if ( captureOrPromotion if ( captureOrPromotion
&& pos.type_of_piece_on(move_to(m)) != PAWN && type_of_piece(pos.piece_on(move_to(m))) != PAWN
&& ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK) && ( pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)
- piece_value_midgame(pos.piece_on(move_to(m))) == VALUE_ZERO) - piece_value_midgame(pos.piece_on(move_to(m))) == VALUE_ZERO)
&& !move_is_special(m)) && !move_is_special(m))
@ -1666,7 +1666,7 @@ split_point_start: // At split points actual search starts from here
// value of the threatening piece, don't prune moves which defend it. // value of the threatening piece, don't prune moves which defend it.
if ( pos.move_is_capture(threat) if ( pos.move_is_capture(threat)
&& ( piece_value_midgame(pos.piece_on(tfrom)) >= piece_value_midgame(pos.piece_on(tto)) && ( piece_value_midgame(pos.piece_on(tfrom)) >= piece_value_midgame(pos.piece_on(tto))
|| pos.type_of_piece_on(tfrom) == KING) || type_of_piece(pos.piece_on(tfrom)) == KING)
&& pos.move_attacks_square(m, tto)) && pos.move_attacks_square(m, tto))
return true; return true;