def check_players
      raise "the number of players (#{@player.size}) must be at least 2" if @player.size < 2
      ids = Hash.new
      fide_ids = Hash.new
      @player.each do |num, p|
        if p.id
          raise "duplicate ICU IDs, players #{p.num} and #{ids[p.id]}" if ids[p.id]
          ids[p.id] = num
        end
        if p.fide_id
          raise "duplicate FIDE IDs, players #{p.num} and #{fide_ids[p.fide_id]}" if fide_ids[p.fide_id]
          fide_ids[p.fide_id] = num
        end
        return if p.results.size == 0
        p.results.each do |r|
          next unless r.opponent
          opponent = @player[r.opponent]
          raise "opponent #{r.opponent} of player #{num} is not in the tournament" unless opponent
          o = opponent.find_result(r.round)
          raise "opponent #{r.opponent} of player #{num} has no result in round #{r.round}" unless o
          score = r.rateable || o.rateable ? [] : [:score]
          raise "opponent's result (#{o.inspect}) is not reverse of player's (#{r.inspect})" unless o.reverse.eql?(r, :except => score)
        end
      end
    end
def check_players
      raise "the number of players (#{@player.size}) must be at least 2" if @player.size < 2
      ids = Hash.new
      fide_ids = Hash.new
      @player.each do |num, p|
        if p.id
          raise "duplicate ICU IDs, players #{p.num} and #{ids[p.id]}" if ids[p.id]
          ids[p.id] = num
        end
        if p.fide_id
          raise "duplicate FIDE IDs, players #{p.num} and #{fide_ids[p.fide_id]}" if fide_ids[p.fide_id]
          fide_ids[p.fide_id] = num
        end
        return if p.results.size == 0
        p.results.each do |r|
          next unless r.opponent
          opponent = @player[r.opponent]
          raise "opponent #{r.opponent} of player #{num} is not in the tournament" unless opponent
          o = opponent.find_result(r.round)
          raise "opponent #{r.opponent} of player #{num} has no result in round #{r.round}" unless o
          score = r.rateable || o.rateable ? [] : [:score]
          raise "opponent's result (#{o.inspect}) is not reverse of player's (#{r.inspect})" unless o.reverse.eql?(r, :except => score)
        end
      end
    end
Check players.