Module: TournamentSystem::Swiss::Dutch

Extended by:
Dutch
Included in:
Dutch
Defined in:
lib/tournament_system/swiss/dutch.rb

Overview

A Dutch pairing system implementation.

Instance Method Summary collapse

Instance Method Details

#pair(driver, options = {}) ⇒ Array<Array(team, team)>

Pair teams using dutch pairing for a swiss system tournament.

Teams are initially grouped by their score and then slide paired (Algorithm::GroupPairing.slide). If that fails to produce unique matches it will match teams by the minimum score difference, aniling duplicate matches (default) and optionally pushing byes to a certain side.

Parameters:

  • driver (Driver)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • allow_duplicates (Boolean)

    removes the penalty of duplicate matches from the pairing algorithm

  • push_byes_to (:none, :top_half, :bottom_half)

    adds a penalty to the pairing algorithm for when a bye match is not with a team in the desired position.

Returns:

  • (Array<Array(team, team)>)

    the generated pairs of teams


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tournament_system/swiss/dutch.rb', line 25

def pair(driver, options = {})
  state = build_state(driver, options)

  dutch_pairings = generate_dutch_pairings(state)

  duplicates = driver.count_duplicate_matches(dutch_pairings)

  if duplicates.zero?
    dutch_pairings
  else
    generate_best_pairings(state)
  end
end