from game import * rand_winners = 0 smart_winners = 0 rand_players = 0 smart_players = 0 total_games = 0 #print "FULL_GAME_DIR = %s" % FULL_GAME_DIR ## DEBUG # Get all the games game_names = [file for file in os.listdir(FULL_GAME_DIR) \ if os.path.isfile("%s/%s" % (FULL_GAME_DIR, file))] #print "game_names = %s" % game_names ## DEBUG for game_name in game_names: total_games += 1 print "game = %s" % game_name ## DEBUG try: my_game = load_game(game_name) except: print "Skipping %s ..." % game_name continue for player in my_game.players: #print "\tplayer = %s" % player.name ## DEBUG if player.name.find('rand') != -1: rand_players += 1 if player.has_won(): rand_winners += 1 else: smart_players += 1 if player.has_won(): smart_winners += 1 print "rand players = %d\nrand winners = %d (%.1f%%)\n\nsmart players = %d\nsmart winners = %d (%.1f%%)\n\ntotal games = %d\ntotal players = %d" \ % (rand_players, rand_winners, float(rand_winners)/rand_players*100.0, \ smart_players, smart_winners, float(smart_winners)/smart_players*100.0, \ total_games, rand_players + smart_players)