def calculate_ttc(
            state,
            risk_args,
            verbose=True):
    """
    This first method to calculate ttc (time-to-collision) is just brute force.

    Propagate the scene forward by tenths of a second until a collision
    is detected, or the maximum horizon is reached.

    Assume horizontal speed for the ego car is 0.
    Assume all accelerations are 0.

    Arguments:
        state:
          the StateHistory object that is used to get current positions / speeds for vehicles.
        risk_args:
          the parameters class for risk predictor, containing parameters like
          collisions tolerances, horizon to use, etc.
        verbose:
          Bool, whether or not to print logging messages.
        collision_tolerance:
          Float (or None), the collision tolerance for both lateral and
          longitudinal directions.

    Returns:
      Time to collision, or None if no collision within the given H.

    """
    t = 0
    while (t < risk_args.H):
        t += risk_args.step
        ego_pos_x = 0 # for now, assume no lateral motion.
        ego_pos_y = state.get_ego_speed() * t
        for veh_id in state.state_histories.keys():
            this_state = state.state_histories[veh_id][-1].quantities
                # most recent vehicle_state
            new_pos_x = None
            new_pos_y = None
            if "distance_x" in this_state and "speed_x" in this_state:
                new_pos_x = this_state["distance_x"] + this_state["speed_x"]*t
            if "distance_y" in this_state and "speed_y" in this_state:
                new_pos_y = this_state["distance_y"] + this_state["speed_y"]*t

            if (new_pos_x is not None and \
                    abs(new_pos_x - ego_pos_x) <= risk_args.collision_tolerance_x) \
                    and (new_pos_y is not None and \
                    abs(new_pos_y - ego_pos_y) <= risk_args.collision_tolerance_y):
                if verbose:
                    print("calculate_ttc")
                    print(new_pos_x, ego_pos_x)
                    print(new_pos_y, ego_pos_y)
                    print("veh id", veh_id, "colliding in", t, "seconds")
                return t
    return None