def connect_reachable_exit(entrance, general, worldspecific, worldoors):
    if (random.randint(0, 1) == 0):
        primary = general
        secondary = worldspecific
    else:
        primary = worldspecific
        secondary = general
    try:
        cave = extract_reachable_exit(primary)
    except RuntimeError:
        cave = extract_reachable_exit(secondary)
    exit = cave[(- 1)]
    cave = cave[:(- 1)]
    connect_exit(world, exit, entrance, player)
    connect_entrance(world, worldoors.pop(), exit, player)
    worldspecific.append(cave)
def connect_reachable_exit(entrance, general, worldspecific, worldoors):
    if (random.randint(0, 1) == 0):
        primary = general
        secondary = worldspecific
    else:
        primary = worldspecific
        secondary = general
    try:
        cave = extract_reachable_exit(primary)
    except RuntimeError:
        cave = extract_reachable_exit(secondary)
    exit = cave[(- 1)]
    cave = cave[:(- 1)]
    connect_exit(world, exit, entrance, player)
    connect_entrance(world, worldoors.pop(), exit, player)
    worldspecific.append(cave)