Skip to content

Commit

Permalink
Print chess piece using unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-bovet committed May 6, 2021
1 parent d059505 commit b846d9a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Shared/Engine/ChessBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,31 +397,31 @@ void ChessBoard::move(Color color, Piece piece, Square from, Square to) {
occupancyDirty = true;
}

inline static char charForPiece(Color color, Piece piece) {
inline static std::string charForPiece(Color color, Piece piece) {
auto white = color == WHITE;
switch (piece) {
case PAWN:
return white ? 'P' : 'p';
return white ? "" : "♟︎";
case ROOK:
return white ? 'R' : 'r';
return white ? "" : "";
case KNIGHT:
return white ? 'N' : 'n';
return white ? "" : "";
case BISHOP:
return white ? 'B' : 'b';
return white ? "" : "";
case QUEEN:
return white ? 'Q' : 'q';
return white ? "" : "";
case KING:
return white ? 'K' : 'k';
return white ? "" : "";
case PCOUNT:
return '?';
return "?";
}
}

void ChessBoard::print() {
for (Rank reverseRank = 0; reverseRank < 8; reverseRank++) {
Rank rank = 7 - reverseRank;
for (File file = 0; file < 8; file++) {
char c = '.';
std::string c = "·";

for (unsigned color=0; color<Color::COUNT; color++) {
for (unsigned piece=0; piece<Piece::PCOUNT; piece++) {
Expand Down

0 comments on commit b846d9a

Please sign in to comment.