Skip to content
Merged

d #122

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "position.hpp"
#include "search.hpp"
#include "tuned.hpp"
#include "util/ios_fmt_guard.hpp"
#include "util/parse.hpp"
#include <algorithm>
#include <ios>
Expand Down Expand Up @@ -66,6 +67,8 @@ void UCIHandler::execute_command(const std::string& line) {
handle_setoption(is);
} else if (command == "fen") {
std::cout << m_position << std::endl;
} else if (command == "d") {
handle_d(is);
} else if (command == "attacks") {
handle_attacks(is);
} else if (command == "tunables" || command == "tunestr") {
Expand Down Expand Up @@ -165,6 +168,25 @@ void UCIHandler::handle_position(std::istringstream& is) {
}
}

void UCIHandler::handle_d(std::istringstream&) {
IosFmtGuard guard{std::cout};
std::cout << " +------------------------+" << std::endl;
for (i32 rank = 7; rank >= 0; rank--) {
std::cout << " " << static_cast<char>('1' + rank) << " |";
for (i32 file = 0; file < 8; file++) {
Place place = m_position.board()[Square::from_file_and_rank(file, rank)];
std::cout << " " << place.to_char() << " ";
}
std::cout << "|" << std::endl;
}
std::cout << " +------------------------+" << std::endl;
std::cout << " a b c d e f g h " << std::endl;
std::cout << std::endl;
std::cout << "fen: " << m_position << std::endl;
std::cout << "key: " << std::hex << std::setw(16) << std::setfill('0')
<< m_position.get_hash_key() << std::endl;
}

void UCIHandler::handle_setoption(std::istringstream& is) {
std::string token, name, value_str;

Expand Down
1 change: 1 addition & 0 deletions src/uci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class UCIHandler {
void handle_go(std::istringstream&);
void handle_position(std::istringstream&);
void handle_setoption(std::istringstream&);
void handle_d(std::istringstream&);
void handle_attacks(std::istringstream&);
void handle_perft(std::istringstream&);
};
Expand Down
Loading