OSDN Git Service

Quick fixes.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Mon, 14 Aug 2006 08:23:07 +0000 (08:23 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Mon, 14 Aug 2006 08:23:07 +0000 (08:23 +0000)
changelog
mk_rate
shogi-server

index 4a6ef1b..07b02af 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+2006-08-14  Daigo Moriwaki <daigo at debian dot org>
+
+       * [mk_rate] Record numbers of win/loss games.
+       * Add mk_html, which genrates html from players.haml
+       * Fix test/test_board.rb. Now it works. 
+       * Add test/TC_ALL.rb to run all test cases.
+
 2006-08-11  Daigo Moriwaki <daigo at debian dot org>
        
        * Add mk_rate, which calculate rating scores.
diff --git a/mk_rate b/mk_rate
index 2b99a7a..1a74f8a 100755 (executable)
--- a/mk_rate
+++ b/mk_rate
@@ -216,11 +216,15 @@ def main
        rating.integer!
 
        yaml = {}
-       keys.each_with_index do |p, i|
+       keys.each_with_index do |p, i| # player_id, index#
+               win_loss = $players[p].values.inject(Vector[0,0]) {|sum, v| sum + v}
+    win = win_loss_matrix
                yaml[p] = 
                        { 'name' => p.split("+")[0],
                    'rate' => rating.rate[i],
-                   'last_modified' => $players_time[p]}
+                   'last_modified' => $players_time[p],
+                   'win'  => win_loss[0],
+                   'loss' => win_loss[1]}
        end
        puts yaml.to_yaml
 end
index 1cbd387..4006658 100755 (executable)
@@ -1139,7 +1139,7 @@ class Board
     return true
   end
 
-  def handle_one_move(str, sente)
+  def handle_one_move(str, sente=nil)
     if (str =~ /^([\+\-])(\d)(\d)(\d)(\d)([A-Z]{2})/)
       sg = $1
       x0 = $2.to_i
@@ -1148,6 +1148,7 @@ class Board
       y1 = $5.to_i
       name = $6
     elsif (str =~ /^%KACHI/)
+      raise ArgumentError, "sente is null", callser unless sente
       if (good_kachi?(sente))
         return :kachi_win
       else
@@ -1844,6 +1845,7 @@ def good_game_name?(str)
   end
 end
 
+# TODO This is also checked by good_game_name?().
 def good_identifier?(str)
   if str =~ /\A[\w\d_@\-\.]{1,#{Max_Identifier_Length}}\z/
     return true