@@ -71,14 +71,15 @@ QList<int> KnockoutTournament::firstRoundPlayers() const
7171 for (int i = seedCount; i < n; i++)
7272 {
7373 unseeded << i;
74+ players << i;
7475 }
7576
77+ /*
7678 while (!unseeded.isEmpty())
7779 {
7880 int i = Mersenne::random() % unseeded.size();
79- players << unseeded.takeAt (i);
8081 }
81-
82+ */
8283 return players;
8384}
8485
@@ -108,12 +109,16 @@ void KnockoutTournament::initializePairing()
108109 all[byeIndex] = player;
109110 }
110111 else
111- all[index ] = player;
112+ all[i ] = player;
112113 }
113114
114115 QList<TournamentPair*> pairs;
116+ int j = 0 ;
115117 for (int i = 0 ; i < x; i += 2 )
116- pairs.append (pair (all.at (i), all.at (i + 1 )));
118+ {
119+ pairs.append (pair (all.at (j), all.at (x -j - 1 )));
120+ j++;
121+ }
117122
118123 m_rounds.clear ();
119124 m_rounds << pairs;
@@ -174,7 +179,20 @@ bool KnockoutTournament::areAllGamesFinished() const
174179
175180bool KnockoutTournament::shouldWeStopTour () const
176181{
177- return m_should_we_stop_global;
182+ QString path = " failed.txt" ;
183+
184+ if (!fileExists (path))
185+ {
186+ return m_should_we_stop_global;
187+ }
188+ else
189+ {
190+ qWarning () << " \n *************************************************************** \n " <<
191+ " We stopped before game#::" <<
192+ " Look at failed.txt" <<
193+ " \n *************************************************************** \n " ;
194+ return true ;
195+ }
178196}
179197
180198bool KnockoutTournament::shouldWeStop (int iWhite, int iBlack, const TournamentPair* pair) const
@@ -280,6 +298,10 @@ TournamentPair* KnockoutTournament::nextPair(int gameNumber)
280298 nextRound << pair (winners.at (i), winners.at (i + 1 ));
281299 }
282300 m_rounds << nextRound;
301+ if (currentRound () == 1 )
302+ {
303+ return nullptr ;
304+ }
283305 setCurrentRound (currentRound () + 1 );
284306
285307 for (TournamentPair* pair : qAsConst (nextRound))
0 commit comments