def star_wars(x, y, elem, neighbours):
    """Star Wars preset of the Generations family. (345/2/4)"""
    red_count = 0
    for neighbour in neighbours:
        if neighbour == 3:
            red_count += 1

    if elem == 3: # The cell is alive
        if red_count in [3,4,5]:
            return 3
        else:
            return 2
    elif elem > 0: # The cell is decaying
        return elem - 1
    elif red_count == 2: # The cell is dead, but will be brought to life
        return 3
    else: # The cell is dead
        return 0