Skip to content

Commit e0e540e

Browse files
skiminkiAloril
authored andcommitted
Send rating difference between player and opponent (UCI)
Send "UCI_RatingAdv" to communicate the rating difference between the player and the opponent. The difference is computed as the rating advantage. That is: UCI_RatingAdv = OwnRating - OpponentRating UCI_RatingAdv can be used for contempt based on the relative opponent strength, for instance. UCI_RatingAdv is sent only when the ratings for both engines are defined.
1 parent 2f30b03 commit e0e540e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

projects/lib/src/uciengine.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ UciEngine::UciEngine(QObject* parent)
8686
: ChessEngine(parent),
8787
m_useDirectPv(false),
8888
m_sendOpponentsName(false),
89+
m_sendRatingAdv(false),
8990
m_canPonder(false),
9091
m_ponderState(NotPondering),
9192
m_movesPondered(0),
@@ -159,6 +160,12 @@ void UciEngine::startGame()
159160
QString value = QString("none %1 %2 %3")
160161
.arg(opRating, opType, opponent()->name());
161162
sendOption("UCI_Opponent", value);
163+
}
164+
165+
if (m_sendRatingAdv)
166+
{
167+
if (opponent()->rating() && rating())
168+
sendOption("UCI_RatingAdv", QString::number(rating() - opponent()->rating()));
162169
}
163170

164171
sendPosition();
@@ -768,6 +775,8 @@ void UciEngine::parseLine(const QString& line)
768775
addVariantsFromOption(option);
769776
else if (option->name() == "UCI_Opponent")
770777
m_sendOpponentsName = true;
778+
else if (option->name() == "UCI_RatingAdv")
779+
m_sendRatingAdv = true;
771780
else if (option->name() == "Ponder")
772781
m_canPonder = true;
773782
else

projects/lib/src/uciengine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class LIB_EXPORT UciEngine : public ChessEngine
9090
// after it sends a "bestmove"
9191
QStringList m_bmBuffer;
9292
bool m_sendOpponentsName;
93+
bool m_sendRatingAdv;
9394
bool m_canPonder;
9495
PonderState m_ponderState;
9596
Chess::Move m_ponderMove;

0 commit comments

Comments
 (0)