改为使用确认OK的 make_square() 函数

This commit is contained in:
Calcitem 2020-09-06 21:58:44 +08:00
parent 5182518257
commit 81f5a5e5ce
3 changed files with 6 additions and 20 deletions

View File

@ -1457,13 +1457,6 @@ void Position::square_to_polar(const Square s, File &file, Rank &rank)
rank = Rank((s & 0x07) + 1);
}
Square Position::polar_to_square(File file, Rank rank)
{
assert(!(file < 1 || file > FILE_NB || rank < 1 || rank > RANK_NB));
return static_cast<Square>(file * RANK_NB + rank - 1);
}
Color Position::color_on(Square s) const
{
return Color((board[s] & 0x30) >> PLAYER_SHIFT);

View File

@ -158,7 +158,6 @@ public:
bool is_all_surrounded() const;
static void square_to_polar(Square s, File &file, Rank &rank);
static Square polar_to_square(File file, Rank rank);
static void print_board();
@ -307,23 +306,19 @@ inline Thread *Position::this_thread() const
return thisThread;
}
inline bool Position::select_piece(File file, Rank rank)
inline bool Position::select_piece(File f, Rank r)
{
return select_piece(Position::polar_to_square(file, rank));
return select_piece(make_square(f, r));
}
inline bool Position::put_piece(File file, Rank rank)
inline bool Position::put_piece(File f, Rank r)
{
Square s = Position::polar_to_square(file, rank);
return put_piece(s, true);
return put_piece(make_square(f, r), true);
}
inline bool Position::remove_piece(File file, Rank rank)
inline bool Position::remove_piece(File f, Rank r)
{
Square s = Position::polar_to_square(file, rank);
return remove_piece(s, 1);
return remove_piece(make_square(f, r), 1);
}
inline bool Position::move_piece(Square from, Square to)

View File

@ -437,8 +437,6 @@ constexpr Color operator~(Color color)
// return Piece(p ^ 8); // Swap color of piece
// }
// TODO
constexpr Square make_square(File file, Rank rank)
{
return Square((file << 3) + rank - 1);