+2009-11-11 Daigo Moriwaki <daigo at debian dot org>
+
+ * [mk_rate]
+ - Added a new command line option: --base-date. You can specify a
+ base date to calculate rating scores. Games in the `future' are
+ ignored for the calculation.
+
2009-11-10 Daigo Moriwaki <daigo at debian dot org>
* [shogi-server]
% ./mk_game_results dir_of_csa_files > 00LIST
2. Run the server. It appends a result of each game to
'00LIST' when the game finishes.
- 3. From the list of game results, calcurate rating scores of
+ 3. From the list of game results, calculate rating scores of
players.
% ./mk_rate 00LIST > players.yaml
# DIR::
# CSA files are recursively looked up the directories.
#
+# --base-date::
+# a base time point for this calicuration (default now). Ex. '2009-10-31'
+#
# --half-life::
# n [days] (default 60)
#
end
def _add_win_loss(winner, loser, time)
- how_long_days = (Time.now - time)/(3600*24)
+ how_long_days = ($options["base-date"] - time)/(3600*24)
$players[winner] ||= Hash.new { GSL::Vector[0,0] }
$players[loser] ||= Hash.new { GSL::Vector[0,0] }
$players[winner][loser] += GSL::Vector[1.0*half_life(how_long_days),0]
return if state == "abnormal"
time = Time.parse(time)
+ return if $options["base-date"] < time
black_id = identify_id(black_id)
white_id = identify_id(white_id)
USAGE: #{$0} [options] DIR..
DIR where CSA files are looked up recursively
OPTOINS:
+ --base-date a base time point for this calicuration (default now). Ex. '2009-10-31'
--half-life n [days] (default 60)
--half-life-ignore m [days] (default 7)
after m days, half-life effect works
def main
$options = Hash::new
parser = GetoptLong.new(
+ ["--base-date", GetoptLong::REQUIRED_ARGUMENT],
["--half-life", GetoptLong::REQUIRED_ARGUMENT],
["--half-life-ignore", GetoptLong::REQUIRED_ARGUMENT],
["--help", "-h", GetoptLong::NO_ARGUMENT],
usage($stdout)
exit 0
end
+ if $options["base-date"]
+ $options["base-date"] = Time::parse $options["base-date"]
+ else
+ $options["base-date"] = Time.now
+ end
$options["half-life"] ||= 60
$options["half-life"] = $options["half-life"].to_i
$options["half-life-ignore"] ||= 7