def mark_regions(world, player):
    player_dungeons = [dungeon for dungeon in world.dungeons if (dungeon.player == player)]
    for dungeon in player_dungeons:
        queue = deque(dungeon.regions)
        while (len(queue) > 0):
            region = world.get_region(queue.popleft(), player)
            if (region.name not in dungeon.regions):
                dungeon.regions.append(region.name)
                region.dungeon = dungeon
            for ext in region.exits:
                d = world.check_for_door(ext.name, player)
                connected = ext.connected_region
                if ((d is not None) and (connected is not None)):
                    if ((d.dest is not None) and (connected.name not in dungeon.regions) and (connected.type == RegionType.Dungeon) and (connected.name not in queue)):
                        queue.append(connected)
                elif ((connected is not None) and (connected.name not in dungeon.regions) and (connected.type == RegionType.Dungeon) and (connected.name not in queue)):
                    queue.append(connected)
def mark_regions(world, player):
    player_dungeons = [dungeon for dungeon in world.dungeons if (dungeon.player == player)]
    for dungeon in player_dungeons:
        queue = deque(dungeon.regions)
        while (len(queue) > 0):
            region = world.get_region(queue.popleft(), player)
            if (region.name not in dungeon.regions):
                dungeon.regions.append(region.name)
                region.dungeon = dungeon
            for ext in region.exits:
                d = world.check_for_door(ext.name, player)
                connected = ext.connected_region
                if ((d is not None) and (connected is not None)):
                    if ((d.dest is not None) and (connected.name not in dungeon.regions) and (connected.type == RegionType.Dungeon) and (connected.name not in queue)):
                        queue.append(connected)
                elif ((connected is not None) and (connected.name not in dungeon.regions) and (connected.type == RegionType.Dungeon) and (connected.name not in queue)):
                    queue.append(connected)