import numpy as np
import json
from ca import CASim


def main():
    ca = CASim()
    ca.k = 4
    ca.r = 1
    ca.width = 10
    ca.height = ca.k ** ca.width
    ca.build_random_table = False
    ca.reset()

    times = {}
    n = 10

    for labda in [float(x) / ca.rule_length for x in range(ca.rule_length + 1)]:
        ca.labda = labda
        times[labda] = []

        for i in range(0, n):
            ca.reset()
            trans_t = 0

            while not trans_t and ca.t < ca.height:
                trans_t = ca.step()
            times[labda].append(trans_t)

        print(f"{labda} {times[labda]}")

    with open("res.json", 'w') as f:
        json.dump(times, f)



if __name__ == '__main__':
    main()
