OSDN Git Service

util/statistics.rb: Updated to investigate floodgate-600-10 games.
authorDaigo Moriwaki <daigo@debian.org>
Sat, 14 Feb 2015 08:40:28 +0000 (17:40 +0900)
committerDaigo Moriwaki <daigo@debian.org>
Sat, 14 Feb 2015 08:40:28 +0000 (17:40 +0900)
changelog
utils/histogram.R [new file with mode: 0644]
utils/statistics.rb

index f7ebb2e..2364fec 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,11 @@
+2015-02-14  Daigo Moriwaki <daigo at debian dot org>
+
+       * util/statistics.rb:
+         - Updated to investigate floodgate-600-10 games.
+           Consult the result at
+           http://www.sgtpepper.net/hyspro/diary/20150214.html.
+         - Added a companion R script: histogram.R 
+
 2015-01-20  Daigo Moriwaki <daigo at debian dot org>
 
        * [mk_rate]
diff --git a/utils/histogram.R b/utils/histogram.R
new file mode 100644 (file)
index 0000000..d6a19e9
--- /dev/null
@@ -0,0 +1,53 @@
+args <- commandArgs(TRUE)
+file1<- args[1]
+file2 <- args[2]
+title <- args[3]
+
+print(file)
+
+d1 <- read.csv(file1, header=F)
+d2 <- read.csv(file2, header=F)
+
+sink(file="summary1.txt", split=T)
+summary(d1)
+sink()
+
+con <- file("summary1.txt")
+open(con)
+summary_text <- readLines(con)
+close(con)
+
+sink(file="summary2.txt", split=T)
+summary(d2)
+sink()
+
+con <- file("summary2.txt")
+open(con)
+summary_text <- readLines(con)
+close(con)
+
+
+png(sprintf("%s.png", file1))
+
+library(MASS)
+par(mar = c(4.5, 4.5, 4.5, 5.5))
+
+max <- 60
+
+truehist(d1$V1, xlim=c(0,max), col="#66ff6640", border="#66ff66", axes = FALSE, xlab = "", ylab = "", prob=FALSE)
+axis(side = 1)                                          # x axis
+axis(side = 2, col.axis = "#66ff66", col = "#66ff66")   # left y axis
+mtext("floodgate-900-0", side = 2, line=3)
+
+par(new = TRUE)
+
+truehist(d2$V1, xlim=c(0,max), col="#6699ff40", border="#6699ff", axes = FALSE, xlab = "", ylab = "", prob=FALSE) 
+axis(side = 4, col.axis = "#6699ff", col = "#6699ff")   # right y axis
+mtext("floodgate-600-0", side = 4, line=3)
+
+mtext(title, side=1, line=3)
+
+dev.off()
+q()
+
+
index b931317..c98ee45 100755 (executable)
@@ -112,33 +112,24 @@ $states   = State.new
 
 def do_file(file)
   $OPT_REPEAT -= 1 if $OPT_REPEAT > 0
-  csa = CsaFileReader.new(file)
+  csa = CsaFileReader.new(file, "EUC-JP")
 
-  # See games between 2008/03 to 2009/07
-  return if csa.start_time.nil? ||
-            csa.start_time <  Time.parse("2008/03/01") ||
-            csa.start_time >= Time.parse("2009/08/01")
-
-  # Want to see complete games
+  # Want to see completed games only
   $states.add csa.state
   return unless csa.state == "toryo"
 
-  # Process monthly
+  # 1. Process monthly
   $monthly.add(csa)
 
-  # Process gametime
+  # 2. Process gametime
   duration = (csa.end_time - csa.start_time).to_i
-  if duration > 2200
-    $stderr.puts "Too long game: #{file}"
-    return
-  end
   $gametime.add duration.to_i
 
-  # Process movetime
+  # 3. Process movetime
   values = csa.movetimes
   $movetime.add values
 
-  #Process moves
+  # 4. Process moves
   $moves.add values.size
 
 rescue => ex