Skip to content
A ruby gem that implements various tournament systems.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Bumped version number. Jun 10, 2018
spec
.gitignore
.reek Implemented accelerated dutch pairing. Jan 30, 2018
.rspec
.rubocop.yml
.travis.yml
Gemfile
LICENSE
README.md
Rakefile Updated dependencies and improved styling. Jan 30, 2018
tournament-system.gemspec

README.md

Tournament System

Build Status Coverage Status Gem Version Yard Docs

This is a simple gem that implements numerous tournament systems.

It is designed to easily fit into any memory model you might already have.

Installation

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

Usage

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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ozfortress/tournament-system.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.