Skip to content

Commit

Permalink
Merge 16e5479 into fd63ad4
Browse files Browse the repository at this point in the history
  • Loading branch information
ujh committed May 17, 2016
2 parents fd63ad4 + 16e5479 commit 35add8e
Show file tree
Hide file tree
Showing 9 changed files with 626 additions and 35 deletions.
36 changes: 27 additions & 9 deletions bin/wins-from-benchmark-results.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Urban Hafner
# Copyright (c) 2016 Urban Hafner
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
Expand All @@ -21,22 +22,37 @@
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'csv'

def data(contents)
contents.each_line.find_all {|l| l !~ /^#/ }.map do |l|
l.split(/\s+/)[3]
end
def parse_file(fn)
contents = File.read(fn)
relevant_lines = contents.each_line.find_all {|l| l !~ /^#/ }
CSV.parse(relevant_lines.map(&:strip).join("\n"), col_sep: "\t")
end

def wins(file)
contents = File.read(file)
white = data(contents).find_all {|l| l =~ /W\+/ }.count
black = data(contents).find_all {|l| l =~ /B\+/ }.count
RES_B = 1
RES_W = 2
RES_R = 3

def wins(fn)
data = parse_file(fn)
white = data.find_all {|row| row[RES_R] =~ /W\+/ }.count
black = data.find_all {|row| row[RES_R] =~ /B\+/ }.count
n = white + black
p = white.to_f/n
"#{(p*100).round(2)}% wins (#{white} games of #{n}, ± #{error(p: p, n: n, confidence: 0.95).round(2)} at 95%, ± #{error(p: p, n: n, confidence: 0.99).round(2)} at 99%)"
end

def scoring(fn)
data = parse_file(fn)
relevant = data.find_all {|row| row[RES_R] !~ /[BW]\+R/ }
relevant.map {|row| row[RES_R] }.uniq.each {|s| puts s }
agreeing = relevant.find_all {|row| row[RES_W] == row[RES_B] }.count
n = relevant.length
p = agreeing.to_f/n
"#{(p*100).round(2)}% same score as GnuGo (#{agreeing} of #{n}, ± #{error(p: p, n: n, confidence: 0.95).round(2)} at 95%, ± #{error(p: p, n: n, confidence: 0.99).round(2)} at 99%)"
end

def z(confidence:)
alpha = 1 - confidence
(1 - 0.5*alpha)*2
Expand All @@ -48,5 +64,7 @@ def error(p:, n:, confidence:)

Dir["*.dat"].each do |fn|
next if fn =~ /summary\.dat/
puts "#{fn}: #{wins(fn)}"
puts "#{fn}:"
puts "\t\t#{wins(fn)}"
puts "\t\t#{scoring(fn)}"
end
2 changes: 1 addition & 1 deletion ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ run_test_suite() {
fi

cargo build --target $TARGET --verbose
cargo test --target $TARGET
cargo test --target $TARGET -j 1
}

main() {
Expand Down
Loading

0 comments on commit 35add8e

Please sign in to comment.