def cellular_automata(rule, initial_state, generations):
  """
    Runs a one-dimensional cellular automata and records results in binary,
    allowing the state to grow.

    Args:
        rule (int): The rule number for the cellular automata (0-255).
        initial_state (list): The initial state of the cellular automata.
        generations (int): The number of generations to run.

    Returns:
        list: A list of binary strings representing the state of the cellular automata at each generation.
    """
  # Convert the rule number to a binary string and pad with zeros to 8 bits
  rule_binary = format(rule, '08b')

  # Initialize the list to store the results
  results = ["".join(map(str, initial_state))]

  # Run the cellular automata for the specified number of generations
  current_state = initial_state.copy()
  for _ in range(generations):
    # Initialize the next state with a zero on each end
    next_state = [0] + current_state + [0]

    # Apply the rule to each cell in the current state
    for i in range(1, len(next_state) - 1):
      # Get the left, center, and right cells
      left = current_state[i - 2] if i > 1 else 0
      center = current_state[i - 1]
      right = current_state[i] if i < len(current_state) else 0

      # Convert the left, center, and right cells to a binary string
      neighborhood = f"{left}{center}{right}"

      # Get the next state of the cell based on the rule
      next_state[i] = int(rule_binary[7 - int(neighborhood, 2)])

    # Update the current state and append the next state to the results
    current_state = next_state
    results.append("".join(map(str, next_state)))

  return results

    Runs a one-dimensional cellular automata and records results in binary,
    allowing the state to grow.

    Args:
        rule (int): The rule number for the cellular automata (0-255).
        initial_state (list): The initial state of the cellular automata.
        generations (int): The number of generations to run.

    Returns:
        list: A list of binary strings representing the state of the cellular automata at each generation.
    
boost/src/custom_modules/cea.py