mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Cleanup Position::print()
And remove not used OUTSIDE enum Piece. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4d438fae9e
commit
a84e4b2049
2 changed files with 20 additions and 23 deletions
|
@ -39,9 +39,8 @@ enum PieceType {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Piece {
|
enum Piece {
|
||||||
NO_PIECE = 0, WP = 1, WN = 2, WB = 3, WR = 4, WQ = 5, WK = 6,
|
EMPTY_BLACK_SQ = 0, WP = 1, WN = 2, WB = 3, WR = 4, WQ = 5, WK = 6,
|
||||||
BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14,
|
BP = 9, BN = 10, BB = 11, BR = 12, BQ = 13, BK = 14, EMPTY = 16
|
||||||
EMPTY = 16, OUTSIDE = 17
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ struct PieceLetters : std::map<char, Piece> {
|
||||||
operator[]('B') = WB; operator[]('b') = BB;
|
operator[]('B') = WB; operator[]('b') = BB;
|
||||||
operator[]('N') = WN; operator[]('n') = BN;
|
operator[]('N') = WN; operator[]('n') = BN;
|
||||||
operator[]('P') = WP; operator[]('p') = BP;
|
operator[]('P') = WP; operator[]('p') = BP;
|
||||||
|
operator[](' ') = EMPTY; operator[]('.') = EMPTY_BLACK_SQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
char from_piece(Piece p) const {
|
char from_piece(Piece p) const {
|
||||||
|
@ -82,7 +83,6 @@ Key Position::zobExclusion;
|
||||||
|
|
||||||
Score Position::PieceSquareTable[16][64];
|
Score Position::PieceSquareTable[16][64];
|
||||||
|
|
||||||
static bool RequestPending = false;
|
|
||||||
static PieceLetters pieceLetters;
|
static PieceLetters pieceLetters;
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,44 +372,42 @@ const string Position::to_fen() const {
|
||||||
/// Position::print() prints an ASCII representation of the position to
|
/// Position::print() prints an ASCII representation of the position to
|
||||||
/// the standard output. If a move is given then also the san is print.
|
/// the standard output. If a move is given then also the san is print.
|
||||||
|
|
||||||
void Position::print(Move m) const {
|
void Position::print(Move move) const {
|
||||||
|
|
||||||
static const string pieceLetters = " PNBRQK PNBRQK .";
|
const char* dottedLine = "\n+---+---+---+---+---+---+---+---+\n";
|
||||||
|
static bool requestPending = false;
|
||||||
|
|
||||||
// Check for reentrancy, as example when called from inside
|
// Check for reentrancy, as example when called from inside
|
||||||
// MovePicker that is used also here in move_to_san()
|
// MovePicker that is used also here in move_to_san()
|
||||||
if (RequestPending)
|
if (requestPending)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RequestPending = true;
|
requestPending = true;
|
||||||
|
|
||||||
cout << endl;
|
if (move)
|
||||||
if (m != MOVE_NONE)
|
|
||||||
{
|
{
|
||||||
Position p(*this, thread());
|
Position p(*this, thread());
|
||||||
string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : "");
|
string dd = (color_of_piece_on(move_from(move)) == BLACK ? ".." : "");
|
||||||
cout << "Move is: " << col << move_to_san(p, m) << endl;
|
cout << "\nMove is: " << dd << move_to_san(p, move);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
|
for (Rank rank = RANK_8; rank >= RANK_1; rank--)
|
||||||
{
|
{
|
||||||
cout << "+---+---+---+---+---+---+---+---+" << endl;
|
cout << dottedLine << '|';
|
||||||
for (File file = FILE_A; file <= FILE_H; file++)
|
for (File file = FILE_A; file <= FILE_H; file++)
|
||||||
{
|
{
|
||||||
Square sq = make_square(file, rank);
|
Square sq = make_square(file, rank);
|
||||||
|
char c = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
|
||||||
Piece piece = piece_on(sq);
|
Piece piece = piece_on(sq);
|
||||||
if (piece == EMPTY && square_color(sq) == WHITE)
|
|
||||||
piece = NO_PIECE;
|
|
||||||
|
|
||||||
char col = (color_of_piece_on(sq) == BLACK ? '=' : ' ');
|
if (piece == EMPTY && square_color(sq) == BLACK)
|
||||||
cout << '|' << col << pieceLetters[piece] << col;
|
piece = EMPTY_BLACK_SQ;
|
||||||
|
|
||||||
|
cout << c << pieceLetters.from_piece(piece) << c << '|';
|
||||||
}
|
}
|
||||||
cout << '|' << endl;
|
|
||||||
}
|
}
|
||||||
cout << "+---+---+---+---+---+---+---+---+" << endl
|
cout << dottedLine << "Fen is: " << to_fen() << "\nKey is: " << st->key << endl;
|
||||||
<< "Fen is: " << to_fen() << endl
|
requestPending = false;
|
||||||
<< "Key is: " << st->key << endl;
|
|
||||||
|
|
||||||
RequestPending = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue