OSDN Git Service

When there were too few games to rate players (i.e. no
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 27 Mar 2007 15:21:29 +0000 (15:21 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 27 Mar 2007 15:21:29 +0000 (15:21 +0000)
player to rate), mk_rate caused an error. Now it no longer shows
the error.

changelog
mk_rate

index f73b12c..4c62560 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
+2007-03-27  Daigo Moriwaki <daigo at debian dot org>
+
+       * [mk_rate] When there were too few games to rate players (i.e. no
+         player to rate), mk_rate caused an error. Now it no longer shows
+         the error.
+
 2007-03-10  Daigo Moriwaki <daigo at debian dot org>
 
        * [mk_html] Popup shows additional information.
diff --git a/mk_rate b/mk_rate
index 07736ac..396d237 100755 (executable)
--- a/mk_rate
+++ b/mk_rate
@@ -620,31 +620,33 @@ def main
     Dir.glob( File.join(dir, "**", "*.csa") ) {|f| grep(f)}
   end
 
-  obj = WinLossMatrix::mk_win_loss_matrix($players)
   yaml = {} 
   yaml["players"] = {}
-  rating_group = 0
-  obj.connected_subsets.each do |win_loss_matrix|
-    yaml["players"][rating_group] = {}
-
-    rating = Rating.new(win_loss_matrix.matrix)
-    rating.rating
-    rating.average!(Rating::AVERAGE_RATE)
-    rating.integer!
-
-    win_loss_matrix.keys.each_with_index do |p, i| # player_id, index#
-      win  = win_loss_matrix.matrix.row(i).sum
-      loss = win_loss_matrix.matrix.col(i).sum
-
-      yaml["players"][rating_group][p] = 
-        { 'name' => p.split("+")[0],
-          'rating_group' => rating_group,
-          'rate' => rating.rate[i],
-          'last_modified' => $players_time[p].dup,
-          'win'  => win,
-          'loss' => loss}
+  if $players.size > 0
+    obj = WinLossMatrix::mk_win_loss_matrix($players)
+    rating_group = 0
+    obj.connected_subsets.each do |win_loss_matrix|
+      yaml["players"][rating_group] = {}
+
+      rating = Rating.new(win_loss_matrix.matrix)
+      rating.rating
+      rating.average!(Rating::AVERAGE_RATE)
+      rating.integer!
+
+      win_loss_matrix.keys.each_with_index do |p, i| # player_id, index#
+        win  = win_loss_matrix.matrix.row(i).sum
+        loss = win_loss_matrix.matrix.col(i).sum
+
+        yaml["players"][rating_group][p] = 
+          { 'name' => p.split("+")[0],
+            'rating_group' => rating_group,
+            'rate' => rating.rate[i],
+            'last_modified' => $players_time[p].dup,
+            'win'  => win,
+            'loss' => loss}
+      end
+      rating_group += 1
     end
-    rating_group += 1
   end
   puts yaml.to_yaml
 end