mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Simplify Position::print()
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
c19a6ef82d
commit
f86182e791
1 changed files with 11 additions and 18 deletions
|
@ -63,7 +63,7 @@ const Value PieceValueEndgame[17] = {
|
|||
};
|
||||
|
||||
// To convert a Piece to and from a FEN char
|
||||
static const string PieceToChar(" PNBRQK pnbrqk .");
|
||||
static const string PieceToChar(" PNBRQK pnbrqk");
|
||||
|
||||
|
||||
/// CheckInfo c'tor
|
||||
|
@ -154,7 +154,7 @@ void Position::from_fen(const string& fenStr, bool isChess960, Thread* th) {
|
|||
sq += Square(token - '0'); // Advance the given number of files
|
||||
|
||||
else if (token == '/')
|
||||
sq = make_square(FILE_A, rank_of(sq) - Rank(2));
|
||||
sq -= Square(16);
|
||||
|
||||
else if ((p = PieceToChar.find(token)) != string::npos)
|
||||
{
|
||||
|
@ -319,7 +319,11 @@ const string Position::to_fen() const {
|
|||
|
||||
void Position::print(Move move) const {
|
||||
|
||||
const char* dottedLine = "\n+---+---+---+---+---+---+---+---+\n";
|
||||
const string dottedLine = "\n+---+---+---+---+---+---+---+---+";
|
||||
const string twoRows = dottedLine + "\n| | . | | . | | . | | . |"
|
||||
+ dottedLine + "\n| . | | . | | . | | . | |";
|
||||
|
||||
string brd = twoRows + twoRows + twoRows + twoRows + dottedLine;
|
||||
|
||||
if (move)
|
||||
{
|
||||
|
@ -327,22 +331,11 @@ void Position::print(Move move) const {
|
|||
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
|
||||
}
|
||||
|
||||
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
|
||||
{
|
||||
cout << dottedLine << '|';
|
||||
for (File file = FILE_A; file <= FILE_H; file++)
|
||||
{
|
||||
Square sq = make_square(file, rank);
|
||||
Piece piece = piece_on(sq);
|
||||
char c = (color_of(piece) == BLACK ? '=' : ' ');
|
||||
for (Square sq = SQ_A1; sq <= SQ_H8; sq++)
|
||||
if (piece_on(sq) != NO_PIECE)
|
||||
brd[513 - 68*rank_of(sq) + 4*file_of(sq)] = PieceToChar[piece_on(sq)];
|
||||
|
||||
if (piece == NO_PIECE && !opposite_colors(sq, SQ_A1))
|
||||
piece++; // Index the dot
|
||||
|
||||
cout << c << PieceToChar[piece] << c << '|';
|
||||
}
|
||||
}
|
||||
cout << dottedLine << "Fen is: " << to_fen() << "\nKey is: " << st->key << endl;
|
||||
cout << brd << "\nFen is: " << to_fen() << "\nKey is: " << st->key << endl;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue