summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-27 20:39:13 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-27 20:39:13 -0400
commitc87dbe49d521683900c20a9425a96467fa631489 (patch)
treef76748dc029617b83c5d6a02ad7b950ad48054f6
parent8891daf9f1b38dadd5d5873fd3703d246876cabc (diff)
Seeding Algorithms now create teams.
-rw-r--r--lib/seeding/early_bird_seeding.rb2
-rw-r--r--lib/seeding/fair_ranked_seeding.rb3
-rw-r--r--lib/seeding/random_seeding.rb2
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb
index f3fc6f9..cb24415 100644
--- a/lib/seeding/early_bird_seeding.rb
+++ b/lib/seeding/early_bird_seeding.rb
@@ -7,7 +7,7 @@ module Seeding
teams = 0
tournament.players.each_slice(tournament.min_players_per_team) do |slice|
if teams < tournament.min_teams_per_match
- match.teams[teams].players += slice
+ match.teams.push Team.create(players: slice)
teams += 1
else
match_num += 1
diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb
index 22c245e..6531c43 100644
--- a/lib/seeding/fair_ranked_seeding.rb
+++ b/lib/seeding/fair_ranked_seeding.rb
@@ -5,6 +5,9 @@ module Seeding
match = matches.first
match_num = 0
players_used = 0
+ (tournament.players.count/tournament.min_players_per_team).floor.times do
+ match.teams.push Team.create()
+ end
best_first(tournament).each_slice(tournament.min_teams_per_match) do |slice|
(0..tournament.min_teams_per_match-1).each do |index|
match.teams[index].players += slice[index]
diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb
index bc332ef..65979bc 100644
--- a/lib/seeding/random_seeding.rb
+++ b/lib/seeding/random_seeding.rb
@@ -7,7 +7,7 @@ module Seeding
teams = 0
tournament.players.shuffle.each_slice(tournament.min_players_per_team) do |slice|
if teams < tournament.min_teams_per_match
- match.teams[teams].players += slice
+ match.teams.push Team.create(players: slice)
teams += 1
else
match_num += 1