From 2998d9105ac1f73f9679509544d9322ec3b37faf Mon Sep 17 00:00:00 2001 From: beatles Date: Sun, 15 Nov 2009 13:24:45 +0000 Subject: [PATCH] * [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. --- changelog | 9 ++++++++- mk_rate | 13 ++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/changelog b/changelog index fe7794b..2fec24f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +2009-11-11 Daigo Moriwaki + + * [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 * [shogi-server] @@ -10,7 +17,7 @@ % ./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 diff --git a/mk_rate b/mk_rate index e3350e5..1409df3 100755 --- a/mk_rate +++ b/mk_rate @@ -34,6 +34,9 @@ # 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) # @@ -591,7 +594,7 @@ def half_life(days) 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] @@ -635,6 +638,7 @@ def parse(line) 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) @@ -662,6 +666,7 @@ def usage(io) 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 @@ -674,6 +679,7 @@ end 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], @@ -699,6 +705,11 @@ def main 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 -- 2.11.0