Skip to content

Commit de8b9fb

Browse files
committed
Reduce TC after set of games
1 parent 6a4c6d7 commit de8b9fb

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

projects/lib/src/knockouttournament.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "playerbuilder.h"
2323
#include "mersenne.h"
2424
#include "board/boardfactory.h"
25+
#include <chessgame.h>
2526

2627
bool m_should_we_stop_global = false;
2728

@@ -185,6 +186,67 @@ bool KnockoutTournament::areAllGamesFinished() const
185186
return true;
186187
}
187188

189+
void KnockoutTournament::setTC(TournamentPlayer white, TournamentPlayer black, ChessGame * game, const TournamentPair* pair)
190+
{
191+
TimeControl wTimeControl = white.timeControl();
192+
TimeControl bTimeControl = black.timeControl();
193+
194+
if (!pair)
195+
{
196+
game->setTimeControl(wTimeControl, Chess::Side::White);
197+
game->setTimeControl(bTimeControl, Chess::Side::Black);
198+
return;
199+
}
200+
201+
int firstScore = pair->firstScore() + white.builder()->resumescore();
202+
int secondScore = pair->secondScore() + black.builder()->resumescore();
203+
204+
qWarning() << "ARUN: Holy:" << white.builder()->resumescore();
205+
206+
if ((firstScore + secondScore) >= 128)
207+
{
208+
wTimeControl.setTimePerTc(60000);
209+
wTimeControl.setTimeIncrement(1000);
210+
bTimeControl.setTimePerTc(60000);
211+
bTimeControl.setTimeIncrement(1000);
212+
qWarning() << "ARUNN: reducing TC: 64" << white.timeControl().timePerTc();
213+
}
214+
else if ((firstScore + secondScore) >= 112)
215+
{
216+
wTimeControl.setTimePerTc(120000);
217+
wTimeControl.setTimeIncrement(1000);
218+
bTimeControl.setTimePerTc(120000);
219+
bTimeControl.setTimeIncrement(1000);
220+
qWarning() << "ARUNN: reducing TC: 56" << white.timeControl().timePerTc();
221+
}
222+
else if ((firstScore + secondScore) >= 96)
223+
{
224+
wTimeControl.setTimePerTc(240000);
225+
wTimeControl.setTimeIncrement(2000);
226+
bTimeControl.setTimePerTc(240000);
227+
bTimeControl.setTimeIncrement(2000);
228+
qWarning() << "ARUNN: reducing TC: 48" << white.timeControl().timePerTc();
229+
}
230+
else if ((firstScore + secondScore) >= 80)
231+
{
232+
wTimeControl.setTimePerTc(480000);
233+
wTimeControl.setTimeIncrement(3000);
234+
bTimeControl.setTimePerTc(480000);
235+
bTimeControl.setTimeIncrement(3000);
236+
qWarning() << "ARUNN: reducing TC: 40" << white.timeControl().timePerTc();
237+
}
238+
else if ((firstScore + secondScore) >= 64)
239+
{
240+
wTimeControl.setTimePerTc(960000);
241+
bTimeControl.setTimePerTc(960000);
242+
wTimeControl.setTimeIncrement(4000);
243+
bTimeControl.setTimeIncrement(4000);
244+
qWarning() << "ARUNN: reducing TC: 32" << white.timeControl().timePerTc();
245+
}
246+
game->setTimeControl(wTimeControl, Chess::Side::White);
247+
game->setTimeControl(bTimeControl, Chess::Side::Black);
248+
}
249+
188250
bool KnockoutTournament::shouldWeStopTour() const
189251
{
190252
QString path = "failed.txt";

projects/lib/src/knockouttournament.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class LIB_EXPORT KnockoutTournament : public Tournament
5656
virtual bool shouldWeStop(int white, int black, const TournamentPair* pair) const;
5757
virtual bool shouldWeStopTour() const;
5858
virtual bool resetBook(const TournamentPair* pair) const;
59+
virtual void setTC(TournamentPlayer white, TournamentPlayer black, ChessGame * game, const TournamentPair* pair);
60+
5961
bool m_should_we_stop;
6062

6163
private:

projects/lib/src/tournament.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "elo.h"
3434
#include <jsonserializer.h>
3535
#include <QFileInfo>
36+
#include <chessgame.h>
3637

3738
Tournament::Tournament(GameManager* gameManager, EngineManager* engineManager,
3839
QObject *parent)
@@ -485,6 +486,12 @@ bool Tournament::hasGauntletRatingsOrder() const
485486
return false;
486487
}
487488

489+
void Tournament::setTC(TournamentPlayer white, TournamentPlayer black, ChessGame * game, const TournamentPair* pair)
490+
{
491+
game->setTimeControl(white.timeControl(), Chess::Side::White);
492+
game->setTimeControl(black.timeControl(), Chess::Side::Black);
493+
}
494+
488495
void Tournament::startGame(TournamentPair* pair)
489496
{
490497
Q_ASSERT(pair->isValid());
@@ -518,8 +525,7 @@ void Tournament::startGame(TournamentPair* pair)
518525
connect(game, SIGNAL(pgnMove()),
519526
this, SLOT(onPgnMove()));
520527

521-
game->setTimeControl(white.timeControl(), Chess::Side::White);
522-
game->setTimeControl(black.timeControl(), Chess::Side::Black);
528+
setTC(white, black, game, m_pair);
523529

524530
game->setOpeningBook(white.book(), Chess::Side::White, white.bookDepth());
525531
game->setOpeningBook(black.book(), Chess::Side::Black, black.bookDepth());

projects/lib/src/tournament.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class LIB_EXPORT Tournament : public QObject
477477
virtual bool shouldWeStopTour() const;
478478
virtual bool resetBook(const TournamentPair* pair) const;
479479
virtual bool fileExists(QString path) const;
480+
virtual void setTC(TournamentPlayer white, TournamentPlayer black, ChessGame * game, const TournamentPair* pair);
480481

481482

482483
private slots:

0 commit comments

Comments
 (0)