+2008-03-04 Daigo Moriwaki <daigo at debian dot org>
+
+ * [mk_rate]
+ - If the computed ratings do not stabilize, then mk_rate aborts.
+ $ ./mk_rate dir && ./mk_rate dir > players.yaml
+ can avoid rewriting the invalid ratings to the file.
+
2008-02-23 Daigo Moriwaki <daigo at debian dot org>
* [shogi-server]
#!/usr/bin/ruby
## $Id$
-## Copyright (C) 2006 Daigo Moriwaki <daigo at debian dot org>
+## Copyright (C) 2006-2008 Daigo Moriwaki <daigo at debian dot org>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
#
# Sample:
# $ ./mk_rate . > players.yaml
+# $ ./mk_rate . && ./mk_rate . > players.yaml
#
# The conditions that games and players are rated as following:
# * Rated games, which were played by both rated players.
exit 1
end
+def validate(yaml)
+ yaml["players"].each do |group_key, group|
+ group.each do |player_key, player|
+ rate = player['rate']
+ next unless rate
+ if rate > 10000 || rate < -10000
+ return false
+ end
+ end
+ end
+ return true
+end
+
def main
usage if ARGV.empty?
while dir = ARGV.shift do
'win' => v[0],
'loss' => v[1]}
end
+ unless validate(yaml)
+ $stderr.puts "Aborted. It did not result in valid ratings."
+ exit 10
+ end
puts yaml.to_yaml
end