+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]
--- /dev/null
+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()
+
+
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