Skip to content
Permalink
Browse files

Seperate UCI and Xboard high and mate scores

  • Loading branch information...
alwey authored and ilaripih committed Aug 9, 2017
1 parent d50212b commit 234fddf113ae0e9b491d348f93fb703089bf2258
@@ -40,17 +40,8 @@ QString evalString(const MoveEvaluation& eval)
str += "+";

// Detect mate-in-n scores

// convert new CECP mate scores to old ones if needed
if (absScore > 99900 && absScore < 100100)
{
absScore = 200000 - 2 * absScore + 30000;
if (score >= absScore)
absScore++;
}

if (absScore > 9900
&& (absScore = 1000 - (absScore % 1000)) < 100)
if (absScore > 98800
&& (absScore = 1000 - (absScore % 1000)) < 200)
{
if (score < 0)
str += "-";
@@ -417,9 +417,9 @@ void UciEngine::parseInfo(const QVarLengthArray<QStringRef>& tokens,
{
score = tokens[i].toString().toInt();
if (score > 0)
score = 30001 - score * 2;
score = 99000 + 1 - score * 2;
else if (score < 0)
score = -30000 - score * 2;
score = -99000 - score * 2;
}
else if (tokens[i - 1] == "lowerbound"
|| tokens[i - 1] == "upperbound")
@@ -536,6 +536,31 @@ void XboardEngine::setFeature(const QString& name, const QString& val)
write("accepted " + name, Unbuffered);
}

// shift assumed mate scores further out
int XboardEngine::adaptScore(int score) const
{
constexpr static int mateScore = 99000;
constexpr static int newCECPMateScore = 100000;
int absScore = qAbs<int>(score);

// convert new CECP mate scores to old ones
if (absScore > newCECPMateScore
&& absScore < newCECPMateScore + 100)
{
absScore = 2 * newCECPMateScore - 2 * absScore + mateScore;
if (score >= absScore)
absScore++;
}

// map assumed mate scores onto equivalents w/ higher absolute values
int distance = 1000 - (absScore % 1000);
if (absScore > 9900 && distance < 100)
score = (score > 0) ? mateScore - distance
: -mateScore + distance;

return score;
}

void XboardEngine::parseLine(const QString& line)
{
const QStringRef command(firstToken(line));
@@ -603,7 +628,7 @@ void XboardEngine::parseLine(const QString& line)
{
if (whiteEvalPov() && side() == Chess::Side::Black)
val = -val;
m_eval.setScore(val);
m_eval.setScore(adaptScore(val));
}

// Search time
@@ -66,6 +66,7 @@ class LIB_EXPORT XboardEngine : public ChessEngine
void sendTimeLeft();
void finishGame();
QString moveString(const Chess::Move& move);
int adaptScore(int score) const;

bool m_forceMode;
bool m_drawOnNextMove;

0 comments on commit 234fddf

Please sign in to comment.
You can’t perform that action at this time.