示例#1
0
    def __init__(self, bots, room_size, default_bot_class, run_factor=10):
        """

        Args:
            bots: (PROG) the players program to be executed and ranked
            room_size: (INT) the size of the rooms
            run_factor(int): The average number of random games per combination of bots.
        """
        self.default_bot_class = default_bot_class
        self.room_size = room_size
        self.scores = {}  # Prog:scores
        self.rooms = {}  # Rooms:Rankings
        self.cur_run = 0
        self.total_runs = run_factor * choose(max(len(bots), 4), 4)
        for bot in bots:
            self.scores[bot] = OnlineMean()
示例#2
0
def test_rolling_n(nums, rolling_n, out):
    online_mean = OnlineMean(roll_after_n=rolling_n)
    for n in nums:
        online_mean.add(n)
    assert online_mean.rounded_mean(2) == round(out, 2)
示例#3
0
def test_rounded_mean(nums, places, out):
    online_mean = OnlineMean()
    for n in nums:
        online_mean.add(n)
    assert online_mean.rounded_mean(places=places) == out
示例#4
0
def test_floored_mean(inp, out):
    online_mean = OnlineMean()
    for i in inp:
        online_mean.add(i)
    assert online_mean.floored_mean == out
示例#5
0
def test_add_op(inp, out):
    online_mean = OnlineMean()
    for i in inp:
        online_mean = online_mean + i
    assert online_mean.mean == out
示例#6
0
def test_add(inp, out):
    online_mean = OnlineMean()
    for i in inp:
        online_mean.add(i)
    assert online_mean.mean == out
示例#7
0
 def add_bot(self, bot, gamedb):
     # load old mean
     mean = gamedb.get_value(bot.token, "rolling_score", 0)
     n = gamedb.get_value(bot.token, "rolling_n", 0)
     self.scores[bot] = OnlineMean(n, mean, roll_after_n=self.rolling_n)
     self.bots |= {bot.token}