PartnerHandler Partner; // Global object
+void PartnerHandler::reset() {
+ sitRequested = partnerDead = weDead = false;
+}
+
+void PartnerHandler::ptell(const std::string& message) {
+ sync_cout << "tellics ptell " << message << sync_endl;
+}
+
void PartnerHandler::parse_partner(std::istringstream& is) {
std::string token;
if (is >> token)
- sync_cout << "tellics ptell partner Fairy-Stockfish is an engine. Ask it 'help' for supported commands." << sync_endl;
+ ptell("partner Fairy-Stockfish is an engine. Ask it 'help' for supported commands.");
else
isFairy = false;
}
else if (token == "help")
{
if (!(is >> token))
- sync_cout << "tellics ptell I listen to the commands help, sit, go, and move. Ptell 'help sit', etc. for details." << sync_endl;
+ ptell("I listen to the commands help, sit, go, and move. Ptell 'help sit', etc. for details.");
else if (token == "sit")
- sync_cout << "tellics ptell After receiving 'sit', I stop moving. Also see 'go'." << sync_endl;
+ ptell("After receiving 'sit', I stop moving. Also see 'go'.");
else if (token == "go")
- sync_cout << "tellics ptell After receiving 'go', I will no longer sit." << sync_endl;
+ ptell("After receiving 'go', I will no longer sit.");
else if (token == "move")
{
- sync_cout << "tellics ptell After receiving 'move', I will move immediately." << sync_endl;
- sync_cout << "tellics ptell If you specify a valid move, e.g., 'move e2e4', I will play it." << sync_endl;
+ ptell("After receiving 'move', I will move immediately." );
+ ptell("If you specify a valid move, e.g., 'move e2e4', I will play it.");
}
}
else if (!pos.two_boards())
else if (token == "sit")
{
sitRequested = true;
- sync_cout << "tellics ptell I sit, tell me 'go' to continue" << sync_endl;
+ ptell("I sit, tell me 'go' to continue");
}
else if (token == "go")
{
sitRequested = false;
Threads.stop = true;
}
+ else if (token == "dead")
+ {
+ partnerDead = true;
+ ptell("I will play fast");
+ }
+ else if (token == "x")
+ {
+ partnerDead = false;
+ ptell("I will play normally again");
+ }
else if (token == "move")
{
if (is >> token)
if (move && !Threads.abort.exchange(true))
moveRequested = move;
else
- sync_cout << "tellics ptell sorry, not possible" << sync_endl;
+ ptell("sorry, not possible");
}
else
Threads.stop = true;
/// in games played on two boards, such as bughouse.
struct PartnerHandler {
+ void reset();
+ void ptell(const std::string& message);
void parse_partner(std::istringstream& is);
void parse_ptell(std::istringstream& is, const Position& pos);
std::atomic<bool> isFairy;
- std::atomic<bool> sitRequested;
+ std::atomic<bool> sitRequested, partnerDead, weDead;
Move moveRequested;
};
Thread::search(); // Let's start searching!
}
+ if (rootPos.two_boards() && !Threads.abort)
+ {
+ if (!Partner.weDead && this->rootMoves[0].score <= VALUE_MATED_IN_MAX_PLY)
+ {
+ Partner.ptell("dead");
+ Partner.weDead = true;
+ }
+ else if (Partner.weDead && this->rootMoves[0].score > VALUE_MATED_IN_MAX_PLY)
+ {
+ Partner.ptell("x");
+ Partner.weDead = false;
+ }
+ }
+
// When we reach the maximum depth, we can arrive here without a raise of
// Threads.stop. However, if we are pondering or in an infinite search,
// the UCI protocol states that we shouldn't print the best move before the