Tournament System

Build Status Coverage Status Gem Version

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'

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 < Tournament::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 build_match(home_team, away_team)
    ...
  end
end

Then you can simply generate matches for any tournament system using a driver instance:

driver = Driver.new

# Generate the 3rd round of a single elimination tournament
Tournament::SingleElimination.generate driver, round: 2

# Generate a round for a round robin tournament, guesses round automatically
Tournament::RoundRobin.generate driver

# Generate a round for a swiss system tournament
# with Dutch pairings (default) with a minimum pair size of 6
Tournament::Swiss.generate driver, pairer: Tournament::Swiss::Dutch,
                                   pair_options: { min_pair_size: 6 }

# Generate a round for a page playoff system, with an optional bronze match
Tournament::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.