Exemple #1
0
def main(game):
    return simulate.callback(
        game=game,
        agent1='mcts',
        agent2='random',
        n_iter1=100,
        n_iter2=-55,  # doesn't matter
        n_runs=1,
        silent=True,
    )
Exemple #2
0
    def test_simulation_equal_depths(self):
        # mcts against itself should win and lose about equally
        from aidoodle.run import simulate

        _, n_wins1, n_wins2, _ = simulate.callback(
            game='dice',
            agent1='mcts',
            agent2='mcts',
            n_iter1=100,
            n_iter2=100,
            n_runs=50,
        )
        assert abs(n_wins1 - n_wins2) <= 15
Exemple #3
0
    def test_simulation_against_random(self, agent1, agent2):
        # mcts should mostly win against random
        from aidoodle.run import simulate

        _, n_wins1, n_wins2, _ = simulate.callback(
            game='dice',
            agent1=agent1,
            agent2=agent2,
            n_iter1=100,
            n_iter2=100,
            n_runs=100,
        )
        if agent1 == 'mcts':
            assert n_wins1 > 60
        else:
            assert n_wins2 > 60
Exemple #4
0
    def test_simulation_different_depths(self, n_iter1, n_iter2):
        # mcts 100 vs mcts 10 should mostly win
        from aidoodle.run import simulate

        _, n_wins1, n_wins2, _ = simulate.callback(
            game='dice',
            agent1='mcts',
            agent2='mcts',
            n_iter1=n_iter1,
            n_iter2=n_iter2,
            n_runs=100,
        )
        if n_iter1 > n_iter2:
            assert n_wins1 > 60
        else:
            assert n_wins2 > 60
Exemple #5
0
    def test_simulation_equal_depths(self):
        # mcts against itself should mostly tie

        # note that n_iter must be sufficiently high, otherwise the
        # starting player will mostly win
        from aidoodle.run import simulate

        _, _, _, n_ties = simulate.callback(
            game='tictactoe',
            agent1='mcts',
            agent2='mcts',
            n_iter1=500,
            n_iter2=500,
            n_runs=50,
        )
        assert n_ties > 20