Giter Site home page Giter Site logo

tournament-system's Introduction

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.

tournament-system's People

Contributors

benjaminschaaf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.