From bd1699969017c8c8f056808ba33e906426962754 Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Sun, 27 Apr 2014 17:45:45 -0400 Subject: these should have been deleted --- lib/pairing/PairingAlgorithm.rb | 6 ------ lib/playing/.keep | 0 2 files changed, 6 deletions(-) delete mode 100644 lib/pairing/PairingAlgorithm.rb delete mode 100644 lib/playing/.keep (limited to 'lib') diff --git a/lib/pairing/PairingAlgorithm.rb b/lib/pairing/PairingAlgorithm.rb deleted file mode 100644 index 81e4df6..0000000 --- a/lib/pairing/PairingAlgorithm.rb +++ /dev/null @@ -1,6 +0,0 @@ -module Pairing - class PairingAlgorithm - def self.pair(matches, players) - end - end -end diff --git a/lib/playing/.keep b/lib/playing/.keep deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3-54-g00ecf From cc7faa1bc3a542e0ea057971d37aa400f711d8c0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 18:22:19 -0400 Subject: tidy up README.md's --- lib/sampling/README.md | 15 ++++++++++++++- lib/scheduling/README.md | 19 ++++++++++++++----- lib/scoring/README.md | 7 ++++++- 3 files changed, 34 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/sampling/README.md b/lib/sampling/README.md index 28c603e..731f1d1 100644 --- a/lib/sampling/README.md +++ b/lib/sampling/README.md @@ -1,28 +1,41 @@ -Files in this directory should be modules implementing the following +Sampling interface +================== + +Files in this directory should be _modules_ implementing the following interface: - `works_with?(Game) => Boolean` + Returns whether or not this sampling method works with the specified game. - `uses_remote?() => Boolean` + Return whether or not this sampling method requires remote IDs for users. - `set_remote_name(User, Game, String)` + Set the remote ID for a user for the specified game. It is safe to assume that this sampling method `works_with?` that game. - `get_remote_name(Object)` + When given an object from `RemoteUsername#value`, give back a human-readable/editable name to display. - `sampling_start(Match)` + Fetch the statistics for a match. + - `sampling_done?(Match) => Boolean` + Returns whether or not statistics have been completely collected yet. - `render_user_interaction(Match, User) => String` + Returns HTML to render on a page. + - `handle_user_interaction(Match, User, Hash params)` + Handles params from the form generated by `#user_interaction_render`. diff --git a/lib/scheduling/README.md b/lib/scheduling/README.md index 173b7be..8b21164 100644 --- a/lib/scheduling/README.md +++ b/lib/scheduling/README.md @@ -1,13 +1,22 @@ -Files in this directory should implement the following interface: +Scheduling interface +==================== + +Files in this directory should be _classes_ implementing the following +interface: - `initialize(tournament_stage)` - construct new Scheduling object from tournament_stage + + Construct new Scheduling object from tournament_stage. - `create_matches` - creates all the matches of the current round + + Creates all the matches of the current round. - `finish_match(match)` - progresses the match through the schedule + + Progresses the match through the schedule. - `graph` - returns a string representation of an svg image of the current stage \ No newline at end of file + + Returns a string representation of an svg image of the current + stage. diff --git a/lib/scoring/README.md b/lib/scoring/README.md index 95dd5e0..5beb0a2 100644 --- a/lib/scoring/README.md +++ b/lib/scoring/README.md @@ -1,10 +1,15 @@ -Files in this directory should be modules implementing the following +Scoring interface +================= + +Files in this directory should be _modules_ implementing the following interface: - `stats_needed() => Array[i]=Symbol` + Returns which statistics need to be collected for this scoring algorithm. - `score(match) => Hash[User]=Integer` + User scores for this match, assuming statistics have been collected. -- cgit v1.2.3-54-g00ecf From c16c1b2928d0156fc00617a6abd81f4714045e5e Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 18:25:04 -0400 Subject: Updated Seeing and Round Robin scheduling. --- app/controllers/matches_controller.rb | 2 +- lib/scheduling/round_robin.rb | 8 ++++++-- lib/seeding/README.md | 5 +++-- lib/seeding/early_bird_seeding.rb | 2 +- lib/seeding/fair_ranked_seeding.rb | 2 +- lib/seeding/random_seeding.rb | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 4a20df2..8b8e86d 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -286,7 +286,7 @@ class MatchesController < ApplicationController params.require(:match).permit(:status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations, :update_action) end - # Turn of check_edit, since our #update is flexible + # Turn of check_edit, since our #update is flexible def check_edit set_match end diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb index 7a9e257..1d9ac0d 100644 --- a/lib/scheduling/round_robin.rb +++ b/lib/scheduling/round_robin.rb @@ -7,11 +7,15 @@ module Scheduling end def create_matches + #number of teams*number of teams per match = number of matches per round num_teams = (tournament.players.count/tournament.min_players_per_team).floor - num_matches = Float(num_teams/2)*(num_teams-1) - for i in 1..num_matches + @matches_per_round = num_teams * tournament.min_teams_per_match + + @matches_per_round.each do |match| tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end + + tournament_stage.seeding.seed_matches(tournament_stage) end def finish_match(match) diff --git a/lib/seeding/README.md b/lib/seeding/README.md index 67fc19b..596adea 100644 --- a/lib/seeding/README.md +++ b/lib/seeding/README.md @@ -1,4 +1,5 @@ Files in this directory should implement the following interface: -- seed_matches(tournament) - take the matches of a tournament and the players in a tournament, assign players to teams, and teams to matches (all must exist) \ No newline at end of file +- `seed(tournament_stage)` + take a tournament stage, assign players to teams and teams to + matches (matches must exist) \ No newline at end of file diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb index 30e15fc..f3fc6f9 100644 --- a/lib/seeding/early_bird_seeding.rb +++ b/lib/seeding/early_bird_seeding.rb @@ -1,6 +1,6 @@ module Seeding class EarlyBirdSeeding - def seed_matches(tournament) + def seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 4eb8c26..22c245e 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -1,6 +1,6 @@ module Seeding class FairRankedSeeding - def seed_matches(tournament) + def seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb index ec39e61..bc332ef 100644 --- a/lib/seeding/random_seeding.rb +++ b/lib/seeding/random_seeding.rb @@ -1,6 +1,6 @@ module Seeding class RandomSeeding - def seed_matches(tournament) + def seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 -- cgit v1.2.3-54-g00ecf From 70690fe168e88ad54be83e7a1ac45bdc32f1a54a Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 20:13:18 -0400 Subject: Updated RR scheduling. --- lib/scheduling/round_robin.rb | 77 ++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 45 deletions(-) (limited to 'lib') diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb index 1d9ac0d..0cbddc1 100644 --- a/lib/scheduling/round_robin.rb +++ b/lib/scheduling/round_robin.rb @@ -7,42 +7,53 @@ module Scheduling end def create_matches - #number of teams*number of teams per match = number of matches per round - num_teams = (tournament.players.count/tournament.min_players_per_team).floor + # => find the number of matches and teams to create + @num_teams = (tournament.players.count/tournament.min_players_per_team).floor @matches_per_round = num_teams * tournament.min_teams_per_match + # => initialize data and status members + @team_pairs ||= {} + if @team_pairs.empty? + @matches_finished = 0 + end + + # => Create new matches @matches_per_round.each do |match| tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0) end - tournament_stage.seeding.seed_matches(tournament_stage) + # => seed the first time + if @team_pairs.empty? + tournament_stage.seeding.seed_matches(tournament_stage) + tournament_stage.matches.each {|match| match.teams.each {|team| @team_pairs += team}} + else + # => Reorder the list of teams + top = @team_pairs.shift + @team_pairs.push @team_pairs.shift + @team_pairs.unshift top + + # => Add the teams to the matches + match = tournament_stage.matches[@matches_finished-1] + matches = 1 + (0..@team_pairs.count-1).each do |i| + match.teams += @team_pairs[i] + if @team_pairs.count.%(tournament.min_teams_per_match).zero? + match = tournament_stage.matches[@matches_finished-1 + matches] + matches += 1 + end + end + + end end def finish_match(match) - #declare winner of match, and store that somehow - rotate - return "totes worked\n" + @matches_finished += 1 end def graph(current_user) end private - - def create_round_array - #round robin should look like this. - #NOTE: I DO NOT KNOW IF THIS IS HOW TO PROPERLY POPULATE THE ROUND ROBIN ARRAY WITH TEAMS - @team_pairs = Array.new(num_matches) - for i in 0..@match.teams.size - @team_pairs.push(@match.teams[i]) - #if there is an odd number of teams, add a dummy for byes - if @match.teams.size % 2 != 0 && i == @match.teams.size-1 - dummy = Team.create - @team_pairs.push(dummy) - end - end - end - def tournament_stage @tournament_stage end @@ -50,29 +61,5 @@ module Scheduling def tournament tournament_stage.tournament end - - def rotate - #this is called when a round has completed - - #remove first team - hold = @team_pairs.shift - #rotate by 1 element - @team_pairs.rotate! - #place first team the front of the array - @team_pairs.unshift(hold) - end - - def mother_fuckin_winner - scores = {} - @teams_pairs.each do |team| - scores[team] = team.matches. - where(:tournament_stage => tournament_stage). - collect{|match|match.winner==team} - end - weiner = scores.index(scores.max) - scores[weiner] - end - - end end -- cgit v1.2.3-54-g00ecf From b71747c6c8b24ab8144a3fc412cc2d385406c512 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:26:10 -0400 Subject: clean lib/seeding/README.md --- lib/seeding/README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/seeding/README.md b/lib/seeding/README.md index 596adea..d323b6d 100644 --- a/lib/seeding/README.md +++ b/lib/seeding/README.md @@ -1,5 +1,10 @@ -Files in this directory should implement the following interface: +Seeding interface +================= -- `seed(tournament_stage)` - take a tournament stage, assign players to teams and teams to - matches (matches must exist) \ No newline at end of file +Files in this directory should be _modules_ implement the following +interface: + + - `seed(TournamentStage)` + + Take a tournament stage, assign players to teams and teams to + matches (matches must exist). -- cgit v1.2.3-54-g00ecf From 9d0be853cef35412c0bfe92c80502fd9da7947f1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 27 Apr 2014 20:29:22 -0400 Subject: Fix namespacing in lib/seeding --- lib/seeding/early_bird_seeding.rb | 6 +++--- lib/seeding/fair_ranked_seeding.rb | 16 ++++++++-------- lib/seeding/random_seeding.rb | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb index f3fc6f9..488a1a2 100644 --- a/lib/seeding/early_bird_seeding.rb +++ b/lib/seeding/early_bird_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class EarlyBirdSeeding - def seed(tournament_stage) + module EarlyBirdSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -17,4 +17,4 @@ module Seeding end end end -end \ No newline at end of file +end diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 22c245e..f56d648 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class FairRankedSeeding - def seed(tournament_stage) + module FairRankedSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -19,17 +19,17 @@ module Seeding end private - def best_first(tournament) + def self.best_first(tournament) tournament.players.sort {|a, b| better(a, b, tournament) } end - def better(player1, player2, tournament) - ps1 = previousScore(player1, tournament) - ps2 = previousScore(player2, tournament) + def self.better(player1, player2, tournament) + ps1 = previous_score(player1, tournament) + ps2 = previous_score(player2, tournament) ps1 <=> ps2 end - def previousScore(player, tournament) + def self.previous_score(player, tournament) score = tournament.statistics.getStatistic(player.matches.last, player, :score) if score.nil? return 0 @@ -37,4 +37,4 @@ module Seeding score end end -end \ No newline at end of file +end diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb index bc332ef..723d70e 100644 --- a/lib/seeding/random_seeding.rb +++ b/lib/seeding/random_seeding.rb @@ -1,6 +1,6 @@ module Seeding - class RandomSeeding - def seed(tournament_stage) + module RandomSeeding + def self.seed(tournament_stage) matches = tournament.current_stage.matches match = matches.first match_num = 0 @@ -17,4 +17,4 @@ module Seeding end end end -end \ No newline at end of file +end -- cgit v1.2.3-54-g00ecf