Module: SwintExec::Tournament

Defined in:
lib/swint_exec/tournament.rb

Class Method Summary collapse

Class Method Details

.start(args) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/swint_exec/tournament.rb', line 26

def Tournament.start(args)
  
  puts 'sorry, not implemented yet'
  exit

###      config = OpenStruct.new
###      config.step = false
###      config.wait = false
###      config.visual = true
###      config.map = 'example.map'
###      config.robots = []
###      config.statistics = false
###      
###      opts = OptionParser.new do |o|
###        o.on('-r', '--robot URI', 'URI of robot') do |r|
###          r = "http://localhost:#{r}/" if /[0-9]+/.match(r)
###          config.robots << r
###        end
###        o.on('-m', '--map URI', 'URI of map') { |m| config.map = m }
###        o.on('-s', '--step', 'Show each step') { config.step = true }
###        o.on('-w', '--wait', 'Wait for return after visual') { config.wait = true }
###        o.on('-v', '--no-visual', 'No visual at all') { config.visual = false }
###        o.on('-t', '--test', 'Do not rotate map') { config.test = true }
###        o.on('-i', '--statistics', 'Display statistics') { config.statistics = true }
###        o.on('-e', '--require FILENAME', 'Provide a file to require') { |e| require(e) }
###        o.on('-c', '--class CLASS', 'Provide a Ruby Robot Class') { |c| config.robots << Kernel.const_get(c) }
###      end
###      
###      opts.parse!(args)
###      
###      Swint.rotate_map! unless config.test
###      
###      unless File.exist?(config.map)
###        puts "mapfile #{config.map} not found"
###        exit
###      end
###      
###      game = Swint::Game.new(config)
###      result = game.run
###      puts "winner after % 3s rounds robot %s" % [result.rounds, result.winner]
###      if config.statistics
###        puts "\ntiming statistics\n-----------------"
###        puts "game took %5.2f seconds" % result.time 
###        result.data.each do |r, d|
###          time = 0
###          d[:times].each { |t| time += t }
###          puts "% 5.2f seconds %s (%s)" % [time, d[:robot].name, d[:robot].owner]
###        end
###      end
  
end