diff --git a/src/position.cpp b/src/position.cpp index d78c4270..cb47bfd6 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -660,20 +660,6 @@ out: return true; } -bool Position::put_piece(File file, Rank rank) -{ - Square s = Position::polar_to_square(file, rank); - - return put_piece(s, true); -} - -bool Position::remove_piece(File file, Rank rank) -{ - Square s = Position::polar_to_square(file, rank); - - return remove_piece(s, 1); -} - bool Position::remove_piece(Square s, bool updateCmdlist) { if (phase & PHASE_NOTPLAYING) @@ -802,20 +788,6 @@ bool Position::select_piece(Square s) return false; } -bool Position::select_piece(File file, Rank rank) -{ - return select_piece(Position::polar_to_square(file, rank)); -} - -bool Position::move_piece(Square from, Square to) -{ - if (select_piece(from)) { - return put_piece(to); - } - - return false; -} - bool Position::giveup(Color loser) { if (phase & PHASE_NOTPLAYING || @@ -1256,18 +1228,7 @@ time_t Position::get_elapsed_time(int us) return elapsedSeconds[us]; } -void Position::construct_key() -{ - st.key = 0; -} - -Key Position::key() -{ - // TODO: Move to suitable function - return update_key_misc(); -} - -Key Position::update_key(Square s) +inline Key Position::update_key(Square s) { // PieceType is board[s] @@ -1282,7 +1243,7 @@ Key Position::update_key(Square s) return st.key; } -Key Position::revert_key(Square s) +inline Key Position::revert_key(Square s) { return update_key(s); } @@ -1326,7 +1287,7 @@ Key Position::next_primary_key(Move m) return npKey; } - + int pieceType = sideToMove; npKey ^= Zobrist::psq[pieceType][s]; diff --git a/src/position.h b/src/position.h index 0cdae582..ffd6fbb5 100644 --- a/src/position.h +++ b/src/position.h @@ -255,11 +255,7 @@ public: Move move { MOVE_NONE }; }; -inline bool Position::empty(Square s) const -{ - return piece_on(s) == NO_PIECE; -} - +extern std::ostream &operator<<(std::ostream &os, const Position &pos); inline Color Position::side_to_move() const { @@ -272,6 +268,78 @@ inline Piece Position::piece_on(Square s) const return board[s]; } +inline bool Position::empty(Square s) const +{ + return piece_on(s) == NO_PIECE; +} + +template inline int Position::count(Color c) const +{ + if (Pt == ON_BOARD) { + return pieceCountOnBoard[c]; + } else if (Pt == IN_HAND) { + return pieceCountInHand[c]; + } + + return 0; +} + +inline Key Position::key() +{ + // TODO: Move to suitable function + return update_key_misc(); +} + +inline void Position::construct_key() +{ + st.key = 0; +} + +inline int Position::game_ply() const +{ + return gamePly; +} + +inline int Position::rule50_count() const +{ + return st.rule50; +} + +inline Thread *Position::this_thread() const +{ + return thisThread; +} + +inline bool Position::select_piece(File file, Rank rank) +{ + return select_piece(Position::polar_to_square(file, rank)); +} + +inline bool Position::put_piece(File file, Rank rank) +{ + Square s = Position::polar_to_square(file, rank); + + return put_piece(s, true); +} + +inline bool Position::remove_piece(File file, Rank rank) +{ + Square s = Position::polar_to_square(file, rank); + + return remove_piece(s, 1); +} + +inline bool Position::move_piece(Square from, Square to) +{ + if (select_piece(from)) { + return put_piece(to); + } + + return false; +} + +/// Mill Game + inline char Position::color_to_char(Color color) { return static_cast('0' + color); @@ -286,17 +354,6 @@ inline std::string Position::char_to_string(char ch) } } -template inline int Position::count(Color c) const -{ - if (Pt == ON_BOARD) { - return pieceCountOnBoard[c]; - } else if (Pt == IN_HAND) { - return pieceCountInHand[c]; - } - - return 0; -} - inline Piece *Position::get_board() const { return (Piece *)board;