<jupyter_start><jupyter_text>Visualizing Elementary Cellular AutomataIn this Notebook we will visualize all 22 reversible ECA rules, so it becomes clearer what they do.For every rule we show to pictures. On the left is the evolution of single "enabled" cell. On the right there is evolution of the random state.<jupyter_code>from matplotlib import pyplot as plt
import numpy as np
from quantum_eca import BorderCondition, ECA


def single_cell_state(n, pos):
    row0 = np.zeros(n, np.int8)
    row0[pos] = 1
    return row0

def visualize_rules(rules):
    fig, axs = plt.subplots(len(rules), 2, figsize=(15, 7 * len(rules)))
    for i in range(len(rules)):
        ca = ECA(rules[i], BorderCondition.PERIODIC)
        pic0 = ca.visualize(single_cell_state(61, 30), steps=60)
        pic1 = ca.visualize(np.random.choice(2, size=61), steps=60)
        axs[i][0].imshow(pic0, cmap='Greys')
        axs[i][1].imshow(pic1, cmap='Greys')
        axs[i][0].set_ylabel('Rule %d' % rules[i])
    plt.show()

RULES = [15,45,51,60,75,85,89,90,101,102,105,150,153,154,165,166,170,180,195,204,210,240]
visualize_rules(RULES)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1284965034965035, 'fraction_numerical': 0.07604895104895106, 'mean_word_length': 4.531400966183575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '126442', 'license': 'MIT', 'n_tokens_mistral': 475, 'n_tokens_neox': 414, 'n_words': 106, 'path': 'cellular_automata/eca_pictures.ipynb', 'repo_name': 'fedimser/quant_comp', 'size': '1144'}