From 17d59963aa53e352a1a8e5174c73d09a30353be4 Mon Sep 17 00:00:00 2001 From: Daigo Moriwaki Date: Sat, 23 Nov 2013 22:48:34 +0900 Subject: [PATCH] * [mk_rate] Now duplicated inputs are checked and skipped. --- changelog | 1 + mk_rate | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/changelog b/changelog index 077bc80..a562e3d 100644 --- a/changelog +++ b/changelog @@ -2,6 +2,7 @@ * [mk_rate] - gsl library may be provided as a gem + - Now duplicated inputs are checked and skipped. * test/TC_floodgate.rb - Improved randomness check so that it works on Ruby 2.0.0 as well diff --git a/mk_rate b/mk_rate index 6252991..1f9e54a 100755 --- a/mk_rate +++ b/mk_rate @@ -104,6 +104,7 @@ require 'yaml' require 'time' require 'getoptlong' +require 'set' require 'rubygems' require 'gsl' require 'rgl/adjacency' @@ -123,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 ################################################# @@ -654,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 -- 2.11.0