OSDN Git Service

* [shogi-server]
[shogi-server/shogi-server.git] / mk_rate
diff --git a/mk_rate b/mk_rate
index 3678b45..1f9e54a 100755 (executable)
--- a/mk_rate
+++ b/mk_rate
@@ -1,11 +1,11 @@
-#!/usr/bin/ruby
+#!/usr/bin/ruby1.9.1
 # $Id$
 #
 # Author:: Daigo Moriwaki
 # Homepage:: http://sourceforge.jp/projects/shogi-server/
 #
 #--
-# Copyright (C) 2006-2009 Daigo Moriwaki <daigo at debian dot org>
+# Copyright (C) 2006-2012 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 Command lines that isntall prerequires will work on Debian.
 #
-# * Ruby 1.8.7
+# * Ruby 1.9.3 or 1.8.7 (including Rubygems)
 #
-#   $ sudo aptitude install ruby1.8
-#
-# * 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
 #
 # == Examples
 #
 require 'yaml'
 require 'time'
 require 'getoptlong'
-require 'gsl'
+require 'set'
 require 'rubygems'
+require 'gsl'
 require 'rgl/adjacency'
 require 'rgl/connected_components'
 
@@ -127,6 +124,8 @@ DRAW_MARK = "draw"
 $players = Hash.new
 # Holds the last time when a player gamed
 $players_time = Hash.new { Time.at(0) }
+# Holds history of input lines to check duplicated inputs
+$history = Set.new
 
 
 #################################################
@@ -658,6 +657,12 @@ end
 # Parse a game result line
 #
 def parse(line)
+  if $history.include? line
+    $stderr.puts "[WARNING] Duplicated: #{line}"
+    return
+  end
+  $history.add line
+
   time, state, black_mark, black_id, white_id, white_mark, file = line.split("\t")
   unless time && state && black_mark && black_id &&
          white_id && white_mark && file