def seating_rule(max_neighbours):
    """
    If a seat is empty (L) and there are no occupied seats adjacent to it,
    the seat becomes occupied.
    If a seat is occupied (#) and max_neighbours or more seats adjacent to it
    are also occupied, the seat becomes empty.
    Otherwise, the seat's state does not change.
    Floor (.) never changes; seats don't move, and nobody sits on the floor.
    """
    def rule(state, neighbours):
        occupied_neighbours = sum(n == '#' for n in neighbours)
        if state == 'L' and not occupied_neighbours:
            return '#'
        if state == '#' and occupied_neighbours >= max_neighbours:
            return 'L'
        return state
    return rule