OSDN Git Service

Display not-yet-rated players. Interium commit.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 5 Feb 2008 11:39:07 +0000 (11:39 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 5 Feb 2008 11:39:07 +0000 (11:39 +0000)
changelog
mk_html
mk_rate

index 9d8bfe6..c08edfe 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,7 +1,11 @@
+2008-02-05 Daigo Moriwaki <daigo at debian dot org>
+
+       * [mk_rate] [mk_html]
+         - Display not-yet-rated players as well.
+
 2008-02-04 Daigo Moriwaki <daigo at debian dot org>
 
-       * [shogi-server]
-       * [webserver]
+       * [shogi-server] [webserver]
          - In the daemon mode, if the specified directory was a relative
            path, the server could fail to start with a permission denied
            error. This issue has been fixed. The path is interpreted as 
diff --git a/mk_html b/mk_html
index 31bfe80..51928d7 100755 (executable)
--- a/mk_html
+++ b/mk_html
@@ -48,6 +48,14 @@ def main
   file = YAML::load(lines)
   erb = ERB.new( DATA.read, nil, "%>" )
   tables = []
+  group_names = []
+  file["players"].keys.sort.each do |index|
+    if index < 999
+      group_names << "#{index}"
+    else
+      group_names << "Not-Yet-Rated Players"
+    end
+  end
 
   file["players"].sort.each do |key, yaml| # sort groups in the order written in players.yaml
   sorted_keys = yaml.keys.sort {|a,b| yaml[b]['rate'] <=> yaml[a]['rate']} # sort players in a group by one's rate
@@ -83,7 +91,7 @@ def main
         <%= h yaml[key]['name'] %> </td>
     <td class="rate">
         <span class="popup"><%= "%5d" % [ diff_rate ] %> | <%= "%.3f" % [ diff_possibility ] %></span>
-        <%= "%5d"  % [ rate ] %> </td>
+        <%= rate != 0 ? "%5d"  % [ rate ] : "N/A" %> </td>
     <td class="ngames">
         <%= "%5d"  % [ win ] %>  </td>
     <td class="ngames">
@@ -162,7 +170,7 @@ __END__
 
 % tables.each_with_index do |t, index|
 <table>
-<caption>Group: <%=index%></caption>
+<caption>Group: <%=group_names[index]%></caption>
 <colgroup>
   <col class="name">
   <col class="rate">
@@ -177,7 +185,7 @@ __END__
   <th>rate</th> 
   <th>win</th> 
   <th>loss</th> 
-  <th>win_rate</th> 
+  <th>&#37;</th> 
   <th>last_modified</th>
 </tr>
 </thead>
diff --git a/mk_rate b/mk_rate
index 8e2c598..9982ce8 100755 (executable)
--- a/mk_rate
+++ b/mk_rate
@@ -210,9 +210,9 @@ class Rating
   end
 
   ##
-  # The initial value of the rate, which is of very importance for Newton method.
-  # This is based on my huristics; the higher the win probablity of a player is, 
-  # the greater points he takes.
+  # The initial value of the rate, which is of very importance for Newton
+  # method.  This is based on my huristics; the higher the win probablity of
+  # a player is, the greater points he takes.
   #
   def initial_rate
     possibility = 
@@ -450,7 +450,8 @@ class WinLossMatrix
   end
 
   ##
-  # Removes players who do not pass a criteria to be rated, and returns a new object.
+  # Removes players who do not pass a criteria to be rated, and returns a
+  # new object.
   # 
   def filter
     $stderr.puts @keys.inspect if $DEBUG
@@ -626,9 +627,9 @@ def main
 
   yaml = {} 
   yaml["players"] = {}
+  rating_group = 0
   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] = {}
 
@@ -652,6 +653,30 @@ def main
       rating_group += 1
     end
   end
+  rating_group -= 1
+  non_rated_group = 999 # large enough
+  yaml["players"][non_rated_group] = {}
+  $players.each_key do |id|
+    # skip players who have already been rated
+    found = false
+    (0..rating_group).each do |i|
+       found = true if yaml["players"][i][id]
+       break if found
+    end
+    next if found
+
+    v = GSL::Vector[0, 0]
+    $players[id].each_value {|value| v += value}
+    next if v[0] < 1 && v[1] < 1
+
+    yaml["players"][non_rated_group][id] =
+      { 'name' => id.split("+")[0],
+        'rating_group' => non_rated_group,
+        'rate' => 0,
+        'last_modified' => $players_time[id].dup,
+        'win'  => v[0],
+        'loss' => v[1]}
+  end
   puts yaml.to_yaml
 end