diff --git a/src/aithread.cpp b/src/aithread.cpp index f76f95d2..8052e8b4 100644 --- a/src/aithread.cpp +++ b/src/aithread.cpp @@ -118,7 +118,8 @@ void sq2str(char *str) sig = 0; } - Position::square_to_polar((Square)sq, file, rank); + file = file_of(sq); + rank = rank_of(sq); if (sig == 1) { sprintf_s(str, 16, "(%d,%d)", file, rank); diff --git a/src/position.cpp b/src/position.cpp index 198d8fb6..ea4d6625 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -616,7 +616,8 @@ bool Position::put_piece(Square s, bool updateCmdlist) start(); } - Position::square_to_polar(s, file, rank); + file = file_of(s); + rank = rank_of(s); if (phase == PHASE_PLACING) { piece = (Piece)((0x01 | (sideToMove << PLAYER_SHIFT)) + rule.nTotalPiecesEachSide - pieceCountInHand[us]); @@ -753,9 +754,8 @@ bool Position::remove_piece(Square s, bool updateCmdlist) if (pieceCountNeedRemove <= 0) return false; - File file; - Rank rank; - Position::square_to_polar(s, file, rank); + File file = file_of(s); + Rank rank = rank_of(s); int seconds = -1; @@ -1447,14 +1447,6 @@ void Position::create_mill_table() #endif /* DEBUG_MODE */ } -void Position::square_to_polar(const Square s, File &file, Rank &rank) -{ - //r = s / RANK_NB; - //s = s % RANK_NB + 1; - file = File(s >> 3); - rank = Rank((s & 0x07) + 1); -} - Color Position::color_on(Square s) const { return Color((board[s] & 0x30) >> PLAYER_SHIFT); diff --git a/src/position.h b/src/position.h index bb79fab2..308eb46c 100644 --- a/src/position.h +++ b/src/position.h @@ -157,8 +157,6 @@ public: void surrounded_pieces_count(Square s, int &nOurPieces, int &nTheirPieces, int &nBanned, int &nEmpty); bool is_all_surrounded() const; - static void square_to_polar(Square s, File &file, Rank &rank); - static void print_board(); int pieces_on_board_count(); diff --git a/src/search.cpp b/src/search.cpp index 1acc6c0f..17fd7123 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -604,16 +604,14 @@ const char* AIAlgorithm::nextMove() const char *AIAlgorithm::moveToCommand(Move move) { - File file2; - Rank rank2; - Position::square_to_polar(to_sq(move), file2, rank2); + File file2 = file_of(to_sq(move)); + Rank rank2 = rank_of(to_sq(move)); if (move < 0) { sprintf(cmdline, "-(%1u,%1u)", file2, rank2); } else if (move & 0x7f00) { - File file1; - Rank rank1; - Position::square_to_polar(from_sq(move), file1, rank1); + File file1 = file_of(from_sq(move)); + Rank rank1 = rank_of(from_sq(move)); sprintf(cmdline, "(%1u,%1u)->(%1u,%1u)", file1, rank1, file2, rank2); } else { sprintf(cmdline, "(%1u,%1u)", file2, rank2); diff --git a/src/types.h b/src/types.h index f8a7de67..561b5ea8 100644 --- a/src/types.h +++ b/src/types.h @@ -481,26 +481,14 @@ constexpr bool is_ok(Square s) constexpr File file_of(Square s) { - return File((s >> 3) - 1); + return File(s >> 3); } constexpr Rank rank_of(Square s) { - return Rank(s & 7); + return Rank((s & 0x07) + 1); } -#if 0 -constexpr ring_t ring_of(Square s) -{ - // return File(s & 7); -} - -constexpr Rank seat_of(Square s) -{ - //return seat(s >> 3); -} -#endif - constexpr Square from_sq(Move m) { return static_cast(m >> 8);