Exemple #1
0
 def __init__(self, world, load_file="save_bots/qbot.json"):
     ValueBot.__init__(self, world, load_file)
     self.ngame = 0
Exemple #2
0
 def __init__(self, world, load_file="save_bots/qbot.json"):
     self.world = world
     ValueBot.__init__(self, world, load_file)
     self.nturns = 0
     self.pathfinder = None
Exemple #3
0
 def __init__(self,world, load_file="save_bots/qbot.json"):
     ValueBot.__init__(self,world, load_file)
     self.nturns = 0
     self.percentSeen = 0
     self.lastPercentSeen = 0
     self.world.stateless = False
Exemple #4
0
 def __init__(self,world, load_file="save_bots/qbot.json"):
     ValueBot.__init__(self,world, load_file)
     self.ngame = 0
Exemple #5
0
    """
    
    win_rate = [(i, float(bot_wins[i]) / float(bot_games[i])) for i in range(0, len(bot_wins))]
    win_rate.sort(key=lambda x: x[1], reverse=True)
    
    return win_rate

if __name__ == '__main__':
    engine = BatchLocalEngine()

    # Run quick games: 100 turns only
    engine.PrepareGame(["--run", "-t", "100"])
    
    # Initialize a random set of bots
    features = MovingTowardsFeatures()
    team_a = [ValueBot(engine.GetWorld(), load_file=None) for i in range(5)]
    for bot in team_a:
        w = [random.uniform(-1,1) for i in range(0, features.num_features())]
        bot.set_features(features)        
        bot.set_weights(w)
    
    # Play several games against GreedyBot
    (bot_scores, bot_wins, bot_score_diffs, bot_games) = engine.RunTournament(5, team_a, [GreedyBot(engine.GetWorld())], [30, 30])

    # Sort bots by their win rate
    a_rate = win_rate(bot_wins[0], bot_games[0])
    
    # Print out tournament results according to win rates 
    for i, rate in a_rate:
        print "Bot %d: Win rate = %g " % (i, rate)
        print team_a[i]
Exemple #6
0
 def __init__(self,world, load_file="save_bots/qbot.json"):
     self.world = world
     ValueBot.__init__(self,world, load_file)
     self.nturns = 0
     self.pathfinder = None