def life_or_death(state, neighbours):
    """
    1. Any live cell with two or three live neighbors survives.
    2. Any dead cell with three live neighbors becomes a live cell.
    3. All other live cells die in the next generation.
       Similarly, all other dead cells stay dead.
    """
    if state == 1:
        if neighbours == 2 or neighbours == 3:
            return 1
        else:
            return 0
    else: # state = 0
        if neighbours == 3:
            return 1
        else:
            return 0