-#!/usr/bin/ruby
+#!/usr/bin/ruby1.9.1
# $Id$
#
# Author:: Daigo Moriwaki
#
# == 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'
#
# 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
#
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
@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!
0
else
p2 = keys[j]
- v = p1_hash[p2] || Vector[0,0]
+ v = p1_hash[p2] || GSL::Vector[0,0]
v[0]
end
end)
def usage(io)
io.puts <<EOF
-USAGE: #{$0} [options] DIR..
- DIR where CSA files are looked up recursively
+USAGE: #{$0} [options] GAME_RESULTS_FILE [...]
+ #{$0} [options]
+
+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.
+
OPTOINS:
--base-date a base time point for this calicuration (default now). Ex. '2009-10-31'
--half-life n [days] (default 60)