Module: TournamentSystem::RoundRobin
Overview
Implements the round-robin tournament system.
Instance Method Summary collapse
-
#generate(driver, options = {}) ⇒ nil
Generate matches with the given driver.
-
#guess_round(driver) ⇒ Integer
Guess the next round number (starting at 0) from the state in driver.
-
#total_rounds(driver) ⇒ Integer
The total number of rounds needed for a round robin tournament with the given driver.
Instance Method Details
#generate(driver, options = {}) ⇒ nil
Generate matches with the given driver.
14 15 16 17 18 19 20 21 22 |
# File 'lib/tournament_system/round_robin.rb', line 14 def generate(driver, = {}) round = [:round] || guess_round(driver) teams = Algorithm::Util.padd_teams_even(driver.seeded_teams) matches = Algorithm::RoundRobin.round_robin_pairing(teams, round) create_matches driver, matches, round end |
#guess_round(driver) ⇒ Integer
Guess the next round number (starting at 0) from the state in driver.
37 38 39 40 |
# File 'lib/tournament_system/round_robin.rb', line 37 def guess_round(driver) Algorithm::RoundRobin.guess_round(driver.seeded_teams.length, driver.matches.length) end |
#total_rounds(driver) ⇒ Integer
The total number of rounds needed for a round robin tournament with the given driver.
29 30 31 |
# File 'lib/tournament_system/round_robin.rb', line 29 def total_rounds(driver) Algorithm::RoundRobin.total_rounds(driver.seeded_teams.length) end |