private static List<TMatchResult> getRandomOutcomes(Set<TMatchSetup> nextMatches) {
   Random random = new Random();
   List<TMatchResult> outcomes = Lists.newArrayList();
   for (TMatchSetup setup : nextMatches) {
     outcomes.add(FuzzTests.getResult(random, setup));
   }
   return outcomes;
 }
 @Parameters(name = "{index}: {0} players, {1}")
 public static Iterable<Object[]> data() {
   return Iterables.filter(
       FuzzTests.getParameters(),
       new Predicate<Object[]>() {
         @Override
         public boolean apply(@Nonnull Object[] arguments) {
           String testSpec = (String) arguments[1];
           return testSpec.startsWith("swiss")
               // This is a bug in the stable swiss1 format.
               && !testSpec.startsWith("swiss1");
         }
       });
 }
  @Test
  public void testNonLosingPlayerAlwaysWins() {
    TTournament spec = TestSpecs.load(testSpec);
    for (long seed = 0L; seed < 100L; seed++) {
      try {
        Random random = new Random(seed);
        TSeeding initialSeeding = FuzzTests.createRandomSeeding(random, numPlayers);
        TTournamentStatus status = TTournamentStatus.getInitialStatus(spec, initialSeeding);
        Set<TPlayer> playersInRound = Sets.newHashSet();
        boolean nonFixedSumGamePlayed = false;
        TRanking standings = status.getCurrentStandings();
        while (true) {
          Set<TMatchSetup> nextMatches = status.getNextMatchesToRun().getMatchesToRun();
          if (nextMatches.isEmpty()) {
            break;
          }

          // To keep this deterministic, we need to go through the matches in sorted order
          SortedSet<TMatchSetup> sortedMatches =
              ImmutableSortedSet.copyOf(MatchSetups.COMPARATOR, nextMatches);
          List<TMatchResult> results = Lists.newArrayList();
          for (TMatchSetup match : sortedMatches) {
            playersInRound.addAll(match.getPlayers());
            nonFixedSumGamePlayed |= !match.getGame().isFixedSum();

            results.add(FuzzTests.getResult(random, match));
          }

          status = status.withNewResults(results);

          // Standings change when the round shifts
          TRanking newStandings = status.getCurrentStandings();
          if (!standings.equals(newStandings)) {
            // Check that players with byes didn't go down in the rankings
            // if it was a fixed-sum game
            if (!nonFixedSumGamePlayed) {
              for (TPlayer player : initialSeeding.getPlayersBestFirst()) {
                if (!playersInRound.contains(player)) {
                  int oldPosition = standings.getPosition(player);
                  int newPosition = newStandings.getPosition(player);
                  // Lower numbers are better
                  if (newPosition > oldPosition) {
                    fail(
                        "Player "
                            + player
                            + " fell from "
                            + oldPosition
                            + " to "
                            + newPosition
                            + " despite having a bye");
                  }
                }
              }
            }

            // Reset the players we examine
            nonFixedSumGamePlayed = false;
            playersInRound.clear();
            standings = newStandings;
          }
        }

      } catch (Exception | AssertionError e) {
        throw new RuntimeException("Seed was " + seed, e);
      }
    }
  }