def smooth_door_pairs(world, player):
    all_doors = [x for x in world.doors if (x.player == player)]
    skip = set()
    for door in all_doors:
        if ((door.type in [DoorType.Normal, DoorType.Interior]) and (door not in skip)):
            partner = door.dest
            skip.add(partner)
            room_a = world.get_room(door.roomIndex, player)
            room_b = world.get_room(partner.roomIndex, player)
            type_a = room_a.kind(door)
            type_b = room_b.kind(partner)
            valid_pair = (stateful_door(door, type_a) and stateful_door(partner, type_b))
            if (door.type == DoorType.Normal):
                if ((type_a == DoorKind.SmallKey) or (type_b == DoorKind.SmallKey)):
                    if valid_pair:
                        if (type_a != DoorKind.SmallKey):
                            room_a.change(door.doorListPos, DoorKind.SmallKey)
                        if (type_b != DoorKind.SmallKey):
                            room_b.change(partner.doorListPos, DoorKind.SmallKey)
                        add_pair(door, partner, world, player)
                    else:
                        if (type_a == DoorKind.SmallKey):
                            remove_pair(door, world, player)
                        if (type_b == DoorKind.SmallKey):
                            remove_pair(door, world, player)
                elif ((type_a in [DoorKind.Bombable, DoorKind.Dashable]) or (type_b in [DoorKind.Bombable, DoorKind.Dashable])):
                    if valid_pair:
                        if (type_a == type_b):
                            add_pair(door, partner, world, player)
                            spoiler_type = ('Bomb Door' if (type_a == DoorKind.Bombable) else 'Dash Door')
                            world.spoiler.set_door_type(((door.name + ' <-> ') + partner.name), spoiler_type, player)
                        else:
                            new_type = (DoorKind.Dashable if ((type_a == DoorKind.Dashable) or (type_b == DoorKind.Dashable)) else DoorKind.Bombable)
                            if (type_a != new_type):
                                room_a.change(door.doorListPos, new_type)
                            if (type_b != new_type):
                                room_b.change(partner.doorListPos, new_type)
                            add_pair(door, partner, world, player)
                            spoiler_type = ('Bomb Door' if (new_type == DoorKind.Bombable) else 'Dash Door')
                            world.spoiler.set_door_type(((door.name + ' <-> ') + partner.name), spoiler_type, player)
                    elif (type_a in [DoorKind.Bombable, DoorKind.Dashable]):
                        room_a.change(door.doorListPos, DoorKind.Normal)
                        remove_pair(door, world, player)
                    elif (type_b in [DoorKind.Bombable, DoorKind.Dashable]):
                        room_b.change(partner.doorListPos, DoorKind.Normal)
                        remove_pair(partner, world, player)
            elif (world.experimental[player] and valid_pair and (type_a != DoorKind.SmallKey) and (type_b != DoorKind.SmallKey)):
                random_door_type(door, partner, world, player, type_a, type_b, room_a, room_b)
    world.paired_doors[player] = [x for x in world.paired_doors[player] if (x.pair or x.original)]
def smooth_door_pairs(world, player):
    all_doors = [x for x in world.doors if (x.player == player)]
    skip = set()
    for door in all_doors:
        if ((door.type in [DoorType.Normal, DoorType.Interior]) and (door not in skip)):
            partner = door.dest
            skip.add(partner)
            room_a = world.get_room(door.roomIndex, player)
            room_b = world.get_room(partner.roomIndex, player)
            type_a = room_a.kind(door)
            type_b = room_b.kind(partner)
            valid_pair = (stateful_door(door, type_a) and stateful_door(partner, type_b))
            if (door.type == DoorType.Normal):
                if ((type_a == DoorKind.SmallKey) or (type_b == DoorKind.SmallKey)):
                    if valid_pair:
                        if (type_a != DoorKind.SmallKey):
                            room_a.change(door.doorListPos, DoorKind.SmallKey)
                        if (type_b != DoorKind.SmallKey):
                            room_b.change(partner.doorListPos, DoorKind.SmallKey)
                        add_pair(door, partner, world, player)
                    else:
                        if (type_a == DoorKind.SmallKey):
                            remove_pair(door, world, player)
                        if (type_b == DoorKind.SmallKey):
                            remove_pair(door, world, player)
                elif ((type_a in [DoorKind.Bombable, DoorKind.Dashable]) or (type_b in [DoorKind.Bombable, DoorKind.Dashable])):
                    if valid_pair:
                        if (type_a == type_b):
                            add_pair(door, partner, world, player)
                            spoiler_type = ('Bomb Door' if (type_a == DoorKind.Bombable) else 'Dash Door')
                            world.spoiler.set_door_type(((door.name + ' <-> ') + partner.name), spoiler_type, player)
                        else:
                            new_type = (DoorKind.Dashable if ((type_a == DoorKind.Dashable) or (type_b == DoorKind.Dashable)) else DoorKind.Bombable)
                            if (type_a != new_type):
                                room_a.change(door.doorListPos, new_type)
                            if (type_b != new_type):
                                room_b.change(partner.doorListPos, new_type)
                            add_pair(door, partner, world, player)
                            spoiler_type = ('Bomb Door' if (new_type == DoorKind.Bombable) else 'Dash Door')
                            world.spoiler.set_door_type(((door.name + ' <-> ') + partner.name), spoiler_type, player)
                    elif (type_a in [DoorKind.Bombable, DoorKind.Dashable]):
                        room_a.change(door.doorListPos, DoorKind.Normal)
                        remove_pair(door, world, player)
                    elif (type_b in [DoorKind.Bombable, DoorKind.Dashable]):
                        room_b.change(partner.doorListPos, DoorKind.Normal)
                        remove_pair(partner, world, player)
            elif (world.experimental[player] and valid_pair and (type_a != DoorKind.SmallKey) and (type_b != DoorKind.SmallKey)):
                random_door_type(door, partner, world, player, type_a, type_b, room_a, room_b)
    world.paired_doors[player] = [x for x in world.paired_doors[player] if (x.pair or x.original)]