No release in over 3 years
Low commit activity in last 3 years
There's a lot of open issues
Implements various tournament systems
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.16.0

Runtime

 Project Readme

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.