Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 37 lines (29 sloc) 0.829 kb
085f657 @reedlaw multi run and results
authored
1 #!/usr/bin/env ruby
9c508a5 @ryw allow setting both # of runs and # of rounds
ryw authored
2 require 'optparse'
085f657 @reedlaw multi run and results
authored
3
9c508a5 @ryw allow setting both # of runs and # of rounds
ryw authored
4 options = {}
5 OptionParser.new do |opts|
6 opts.on("-r", "--runs N", Integer, "Number of runs") do |runs|
7 options[:runs] = runs
8 end
9 opts.on("-o", "--rounds N", Integer, "Number of rounds") do |rounds|
10 options[:rounds] = rounds
11 end
12 end.parse!
085f657 @reedlaw multi run and results
authored
13
9c508a5 @ryw allow setting both # of runs and # of rounds
ryw authored
14 options[:runs] = 1000 unless options[:runs]
15 options[:rounds] = 10 unless options[:rounds]
16
17 last_line = []
a409706 @Jberlinsky Let multi_run run R times (-r flag)
Jberlinsky authored
18
1553b61 @siannopollo Improved feedback during multi-run
siannopollo authored
19 options[:runs].times do |i|
9c508a5 @ryw allow setting both # of runs and # of rounds
ryw authored
20 output = `ruby ./engine.rb -r #{options[:rounds]}`
085f657 @reedlaw multi run and results
authored
21 last_line.push output.split("\n").last
1553b61 @siannopollo Improved feedback during multi-run
siannopollo authored
22 round = i+1
23 print "\rRound #{round} finished".rjust(30, ' ')
24 STDOUT.flush
085f657 @reedlaw multi run and results
authored
25 end
1553b61 @siannopollo Improved feedback during multi-run
siannopollo authored
26 puts ''
085f657 @reedlaw multi run and results
authored
27
28 winners = Hash.new(0)
29
30 last_line.each do |val|
31 winners[val] += 1
32 end
33
34 winners.sort_by{|winner, times| -times}.each do |winner, times|
1553b61 @siannopollo Improved feedback during multi-run
siannopollo authored
35 puts "#{winner.to_s.gsub(' is the winner!', '')} won #{times} times"
085f657 @reedlaw multi run and results
authored
36 end
Something went wrong with that request. Please try again.