def rules(state, alive):
        """
        1. Any live cell with two or three live neighbours survives.
        2. Any dead cell with three live neighbours becomes a live cell.
        3. All other live cells die in the next generation. Similarly, all other dead cells stay dead.
        """
        if state == 1: # cell was alive
            if alive - 1 in [2,3]:
                return 1 # lives
            else:
                return 0 # dies
        else: # cell was dead
            if alive in [3]:
                return 1 # revives
            else:
                return 0