diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-04-25 12:36:52 -0400 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-04-25 12:36:52 -0400 |
commit | 426c916c62d5ff28742821e482f291c5cecc0f64 (patch) | |
tree | e5f45fdafe9be2c6eb48d8000fe73c5a1f9666ee /lib/scheduling/roundrobin.rb | |
parent | c584cd3127ad47a9c093356aee46394c6b35cc3e (diff) |
Added the round robin algorithm. Its based on array rotations. The array needs to be properly populated (I'm not sure how to add the teams to the array)
Diffstat (limited to 'lib/scheduling/roundrobin.rb')
-rw-r--r-- | lib/scheduling/roundrobin.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/scheduling/roundrobin.rb b/lib/scheduling/roundrobin.rb index e050c41..a3a75c9 100644 --- a/lib/scheduling/roundrobin.rb +++ b/lib/scheduling/roundrobin.rb @@ -11,6 +11,23 @@ module Scheduling num_teams = (self.tournament.players.count/self.tournament.min_players_per_team).floor num_matches = Float(num_teams/2)*(num_teams-1) + #round robin should look like this + @team_pairs = Array.new(num_matches) + #team_pairs needs populated with the team objects and im not sure how to do that + end + + #this is called when a round has completed + def rotate + + for i in 0..@team_pairs-2 + hold = @team_pairs.shift + @team_pairs.rotate! + @team_pairs.unshift(hold) + # for j in 0..4 + # puts "#{array[j]}, #{array[j+(array.size/2)-1]}" + # end + # puts "\n\n" + end end def match_finished(match) |