Created
September 10, 2010 02:57
-
-
Save pitluga/572991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOTS = %w(Bully Dual Prospector Rage Random) | |
MAPS = 1..100 | |
def play_game(map, challenger) | |
cmd = %Q{java -jar tools/PlayGame.jar maps/map#{map}.txt 1000 1000 log.txt "ruby mybot.rb" "java -jar example_bots/#{challenger}Bot.jar"} | |
`#{cmd} 2> commentary.txt` | |
output = File.read('commentary.txt').split("\n") | |
victory = output[-1] =~ /Player 1 Wins/ | |
turn = output[-2].split[1] | |
print victory.nil? ? "L" : "W" | |
print "(#{turn}) " | |
end | |
task :play do | |
map = ENV['MAP'] || 7 | |
bot = ENV['BOT'] || 'Dual' | |
play_game(map, bot) | |
puts | |
end | |
task :tournament do | |
BOTS.each do |bot| | |
print "Challenging #{bot}Bot: " | |
MAPS.each do |map| | |
play_game map, bot | |
STDOUT.flush | |
end | |
puts | |
end | |
end | |
task :help do | |
puts "Available bots: #{BOTS.join(',')}" | |
puts "Available maps: #{MAPS.inspect}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment