Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (29 sloc) 829 Bytes
#!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.on("-r", "--runs N", Integer, "Number of runs") do |runs|
options[:runs] = runs
end
opts.on("-o", "--rounds N", Integer, "Number of rounds") do |rounds|
options[:rounds] = rounds
end
end.parse!
options[:runs] = 1000 unless options[:runs]
options[:rounds] = 10 unless options[:rounds]
last_line = []
options[:runs].times do |i|
output = `ruby ./engine.rb -r #{options[:rounds]}`
last_line.push output.split("\n").last
round = i+1
print "\rRound #{round} finished".rjust(30, ' ')
STDOUT.flush
end
puts ''
winners = Hash.new(0)
last_line.each do |val|
winners[val] += 1
end
winners.sort_by{|winner, times| -times}.each do |winner, times|
puts "#{winner.to_s.gsub(' is the winner!', '')} won #{times} times"
end
Something went wrong with that request. Please try again.