This is a simple gem that implements numerous tournament systems.
It is designed to easily fit into any memory model you might already have.
Add this line to your application's Gemfile:
gem 'tournament-system', '~> 2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install tournament-system
First you need to implement a driver to handle the interface between your data and the tournament systems:
class Driver < TournamentSystem::Driver
def matches
...
end
def seeded_teams
...
end
def ranked_teams
...
end
def get_match_winner(match)
...
end
def get_match_teams(match)
...
end
def get_team_score(team)
...
end
def get_team_matches(team)
...
end
def build_match(home_team, away_team)
...
end
end
Check the docs on TournamentSystem::Driver
for more information.
Then you can simply generate matches for any tournament system using a driver instance:
driver = Driver.new
# Generate a round of a single elimination tournament
TournamentSystem::SingleElimination.generate driver
# Generate a round for a round robin tournament
TournamentSystem::RoundRobin.generate driver
# Generate a round for a swiss system tournament, pushing byes to the bottom
# half (bottom half teams will bye before the top half)
TournamentSystem::Swiss.generate driver, pairer: TournamentSystem::Swiss::Dutch,
pair_options: { push_byes_to: :bottom_half }
# Alternatively use the accelerated swiss system
TournamentSystem::Swiss.generate driver, pairer: TournamentSystem::Swiss::AcceleratedDutch
# Generate a round for a page playoff system, with an optional bronze match
TournamentSystem::PagePlayoff.generate driver, bronze_match: true
Bug reports and pull requests are welcome on GitHub at https://github.com/ozfortress/tournament-system.
The gem is available as open source under the terms of the MIT License.