def load_map_dir(path): return dict((b,tronutils.read_board(b)) for b in tronutils.list_files(path))
def load_map_dir(path): return dict( (b, tronutils.read_board(b)) for b in tronutils.list_files(path))
def classify_result(result): "Turn the result from the engine into (W)in, (L)ose, or (D)raw." if result in result_classification: return result_classification[result] else: return result def play_game(mapfile, bot1, bot2): "Runs a single game and returns the result." command = make_command(mapfile, bot1, bot2) process = subprocess.Popen(command, stdout=subprocess.PIPE) for line in process.stdout.readlines(): result = line.strip() return classify_result(result) def run_gauntlet(mapfiles, bot1, bot2): "Run the bots on all the specified mapfiles." summary = dict((c,0) for c in result_classification.values()) for mapfile in mapfiles: result = play_game(mapfile, bot1, bot2) if result in summary: summary[result] += 1 print mapfile, result print summary if __name__ == '__main__': mapfiles = list_files(sys.argv[1]) bot1 = sys.argv[2] bot2 = sys.argv[3] run_gauntlet(mapfiles, bot1, bot2)
return result_classification[result] else: return result def play_game(mapfile, bot1, bot2): "Runs a single game and returns the result." command = make_command(mapfile, bot1, bot2) process = subprocess.Popen(command, stdout=subprocess.PIPE) for line in process.stdout.readlines(): result = line.strip() return classify_result(result) def run_gauntlet(mapfiles, bot1, bot2): "Run the bots on all the specified mapfiles." summary = dict((c, 0) for c in result_classification.values()) for mapfile in mapfiles: result = play_game(mapfile, bot1, bot2) if result in summary: summary[result] += 1 print mapfile, result print summary if __name__ == "__main__": mapfiles = list_files(sys.argv[1]) bot1 = sys.argv[2] bot2 = sys.argv[3] run_gauntlet(mapfiles, bot1, bot2)