X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=mk_rate;h=12531d304c9b8da0c4f4ce5fb7897baf4f5b8586;hp=f935acbb97a512a69b10086b8c06c2ac3b4a51f1;hb=a03582d1222f70e51cef415d9946e327c239789a;hpb=6cb094d104de5c5d77f4e0e13889adcf1eec7a18 diff --git a/mk_rate b/mk_rate index f935acb..12531d3 100755 --- a/mk_rate +++ b/mk_rate @@ -1,4 +1,4 @@ -#!/usr/bin/ruby +#!/usr/bin/ruby1.9.1 # $Id$ # # Author:: Daigo Moriwaki @@ -24,15 +24,20 @@ # # == Synopsis # -# mk_rate reads CSA files, calculates rating scores of each player, and then -# outputs a yaml file (players.yaml) that Shogi-server can recognize. +# mk_rate reads game results files generated by the mk_game_results command, +# calculates rating scores of each player, and then outputs a yaml file +# (players.yaml) that Shogi-server can recognize. # # == Usage # -# ./mk_rate [options] DIR.. +# ./mk_rate [options] GAME_RESULTS_FILE [...] +# +# ./mk_rate [options] # -# DIR:: -# CSA files are recursively looked up the directories. +# GAME_RESULTS_FILE:: +# a path to a file listing results of games, which is genrated by the +# mk_game_results command. +# In the second style above, the file content can be read from the stdin. # # --base-date:: # a base time point for this calicuration (default now). Ex. '2009-10-31' @@ -61,29 +66,27 @@ # # Sample Command lines that isntall prerequires will work on Debian. # -# * Ruby 1.8.7 -# -# $ sudo aptitude install ruby1.8 -# -# * Rubygems +# * Ruby 1.9.3 (including Rubygems) # -# $ sudo aptitude install rubygems +# $ sudo aptitude install ruby1.9.1 # # * Ruby bindings for the GNU Scientific Library (GSL[http://rb-gsl.rubyforge.org/]) # -# $ sudo aptitude install libgsl-ruby1.8 +# $ sudo aptitude install ruby-gsl # # * RGL: {Ruby Graph Library}[http://rubyforge.org/projects/rgl/] # -# $ sudo gem install rgl +# $ sudo gem1.9.1 install rgl # -# == Run +# == Examples # -# $ ./mk_rate . > players.yaml +# $ ./mk_rate game_results.txt > players.yaml # -# or, if you do not want the file to be update in case of errors, +# $ ./mk_game_results . | ./mk_rate > players.yaml # -# $ ./mk_rate . && ./mk_rate . > players.yaml +# If you do not want the file to be update in case of errors, +# +# $ ./mk_rate game_results.txt && ./mk_rate game_results.txt > players.yaml # # == How players are rated # @@ -339,6 +342,7 @@ class Rating old_f = f old_f_nrm2 = old_f.nrm2 deaccelrate(1.0, old_rate, a, old_f_nrm2) + #@rate -= a # Instead, do not deaccelerate @record.set(func_vector.nrm2, @rate) $stderr.printf "|error| : %5.2e\n", a.nrm2 if $DEBUG @@ -355,6 +359,7 @@ class Rating @rate = @record.get $stderr.puts "resolved f: %s -> %f" % [func_vector.to_a.inspect, func_vector.nrm2] if $DEBUG + $stderr.puts "Count: %d" % [@count] if $DEBUG @rate *= 1.0/K finite! @@ -432,7 +437,7 @@ class WinLossMatrix 0 else p2 = keys[j] - v = p1_hash[p2] || Vector[0,0] + v = p1_hash[p2] || GSL::Vector[0,0] v[0] end end) @@ -679,8 +684,14 @@ end def usage(io) io.puts <