Ejemplo n.º 1
0
def test_greedy_strategy():
    """Test the greedy strategy of the AI."""
    tiles = Tiles(800, 100)
    board = Board(800, 100, tiles)
    player = Player('Alfred', board, 'black')
    ai = AI(board, player)
    for i in range(board.count // 2 + 1, board.count - 1):
        board.add_tile(i, board.count // 2 - 1, 'black')
    assert ai.greedy_strategy()[0] == (board.count - 1, board.count // 2 - 1)
    assert len(ai.greedy_strategy()[1]) == board.count // 2 - 1
    board.add_tile(board.count // 2 - 1, 0, 'white')
    for i in range(1, board.count - 1):
        if board.tiles_list[board.count // 2 - 1][i] is None:
            board.add_tile(board.count // 2 - 1, i, 'black')
        else:
            board.tiles_list[board.count // 2 - 1][i].color = 'black'
    assert ai.greedy_strategy()[0] == (board.count // 2 - 1, board.count - 1)
    assert len(ai.greedy_strategy()[1]) == board.count - 2