예제 #1
0
 def test_game_over_on_third_mistake(self):
     h = HanabiGame(2, 'aaaaa')
     h.play(1)
     h.play(1)
     self.assertFalse(h.is_game_over(),
                      "Game is not over after two mistakes")
     h.play(1)
     self.assertTrue(h.is_game_over(), "Game is over after three mistakes")
예제 #2
0
def bot_game(bot_class, num_players, seed, reps):
    scores = []

    title = "{} x {} playing, starting seed {} for {} reps"\
             .format(num_players, bot_class.__name__, seed, reps)
    print(title)
    for i in range(reps):
        sys.stdout = StringIO()
        hanabi     = HanabiGame(num_players, seed)
        while not hanabi.is_game_over():
            bot = bot_class(hanabi)
            play_move(hanabi, bot.get_move())
        scores.append((seed, hanabi.score(), hanabi.lives))
        seed       = hanabi.random_seed()
        sys.stdout = sys.__stdout__

    # these two lines can be uncommented if the render block is moved into the above loop
    # os.system('clear')
    # print(title)
    print(render_scores(scores))
    sleep(0.1)
    exit()