summaryrefslogtreecommitdiff
path: root/lib/seeding/random_seeding.rb
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-04-27 01:50:33 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-04-27 01:50:33 -0400
commit79b903fc5632242a6ab1ee0f7732dec168331703 (patch)
tree986bcf16f681b5b23b27b12797b74ba1b960b57a /lib/seeding/random_seeding.rb
parent353e0b387b8e76d407f9451c236efbb4bd3a19ef (diff)
Added 3 new seeding algorithms.
Diffstat (limited to 'lib/seeding/random_seeding.rb')
-rw-r--r--lib/seeding/random_seeding.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb
new file mode 100644
index 0000000..ec39e61
--- /dev/null
+++ b/lib/seeding/random_seeding.rb
@@ -0,0 +1,20 @@
+module Seeding
+ class RandomSeeding
+ def seed_matches(tournament)
+ matches = tournament.current_stage.matches
+ match = matches.first
+ match_num = 0
+ 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
+ teams += 1
+ else
+ match_num += 1
+ match = matches[match_num]
+ teams = 0
+ end
+ end
+ end
+ end
+end \ No newline at end of file