def truncate_recordings(recordings, max_floor, min_length=300):
    """
    Truncate the recordings so that they never exceed a
    given floor.

    This can be used, for example, to train an agent to
    solve the beginning of every level.

    Args:
        recordings: a list of Recordings.
        max_floor: the floor which no recording should get
          up to.
        min_length: the minimum length of a truncated
          recording for it to be included in the result.

    Returns:
        A list of truncated Recordings.
    """
    res = []
    for rec in recordings:
        if rec.floor < 0:
            continue
        trunc = rec.truncate(max_floor)
        if trunc is not None and trunc.num_steps >= min_length:
            res.append(trunc)
    return res