-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathmulti_run.rb
More file actions
executable file
·36 lines (29 loc) · 829 Bytes
/
Copy pathmulti_run.rb
File metadata and controls
executable file
·36 lines (29 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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