OSDN Git Service

Bumped up GAME_LIMIT
[shogi-server/shogi-server.git] / mk_rate
diff --git a/mk_rate b/mk_rate
index 07736ac..919a7c5 100755 (executable)
--- a/mk_rate
+++ b/mk_rate
@@ -28,7 +28,7 @@
 #   * Rated games, which were played by both rated players.
 #   * Rated players, who logged in the server with a name followed by a trip:
 #     "name,trip".
-#   * (Rated) players, who played more than $GAMES_LIMIT [ten] (rated) games. 
+#   * (Rated) players, who played more than $GAMES_LIMIT [15] (rated) games. 
 #
 #
 # PREREQUIRE
@@ -60,7 +60,7 @@ require 'rgl/connected_components'
 #
 
 # Count out players who play less games than $GAMES_LIMIT
-$GAMES_LIMIT = $DEBUG ? 0 : 10
+$GAMES_LIMIT = $DEBUG ? 0 : 15
 WIN_MARK  = "win"
 LOSS_MARK = "lose"
 DRAW_MARK = "draw"
@@ -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