Update app.py
Browse files
app.py
CHANGED
@@ -85,34 +85,38 @@ fig, axs = plt.subplots(3, 1, figsize=(10, 8))
|
|
85 |
plt.subplots_adjust(hspace=0.45)
|
86 |
lags_shown = 6
|
87 |
|
88 |
-
def draw_world(seq, axs, step,
|
89 |
-
torsion_profile = np.array([ANGLE_MAP.get(nt, 0.0) for nt in seq])
|
90 |
-
runs = find_local_min_runs(torsion_profile, min_run, max_run)
|
91 |
axs[0].cla()
|
92 |
axs[1].cla()
|
93 |
axs[2].cla()
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
104 |
|
105 |
-
|
106 |
-
axs[1].
|
107 |
-
axs[1].
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
axs[2].bar(np.arange(lags_shown), ac_hist[-1][:lags_shown], color='teal', alpha=0.7)
|
112 |
-
axs[2].set_xlabel("Лаг")
|
113 |
-
axs[2].set_ylabel("Автокорреляция")
|
114 |
-
axs[2].set_title("Автокорреляция углового профиля (структурность) и энтропия")
|
115 |
-
axs[2].text(0.70,0.70, f"Энтропия: {ent_hist[-1]:.2f}", transform=axs[2].transAxes)
|
116 |
|
117 |
# --- Запуск анимации в Streamlit ---
|
118 |
if st.button("Начать анимацию"):
|
|
|
85 |
plt.subplots_adjust(hspace=0.45)
|
86 |
lags_shown = 6
|
87 |
|
88 |
+
def draw_world(seq, axs, step, stat_bist_counts, stat_entropy, stat_autocorr):
|
|
|
|
|
89 |
axs[0].cla()
|
90 |
axs[1].cla()
|
91 |
axs[2].cla()
|
92 |
+
axs[3].cla()
|
93 |
|
94 |
+
# Отображение торсионного профиля
|
95 |
+
axs[0].plot(seq, label=f"Step {step}", color='skyblue')
|
96 |
+
axs[0].set_title("Торсионный профиль (углы)")
|
97 |
+
axs[0].set_ylim(-180, 180)
|
98 |
+
|
99 |
+
# Выделение устойчивых машин
|
100 |
+
stable_zones = find_local_min_runs(seq)
|
101 |
+
for start, end in stable_zones:
|
102 |
+
axs[0].axvspan(start, end, color='yellow', alpha=0.3)
|
103 |
+
axs[0].text((start + end) // 2, 160, f'▲ {end - start}', ha='center', va='center', fontsize=8, color='darkgreen')
|
104 |
|
105 |
+
# Количество "машин"
|
106 |
+
axs[1].plot(stat_bist_counts, label='Machines', color='orchid')
|
107 |
+
axs[1].set_title("Кол-во устойчивых машин (стромбистов)")
|
108 |
+
|
109 |
+
# Энтропия
|
110 |
+
axs[2].plot(stat_entropy, label='Entropy', color='crimson')
|
111 |
+
axs[2].set_title("Энтропия торсионного поля")
|
112 |
+
|
113 |
+
# Автокорреляция
|
114 |
+
axs[3].plot(stat_autocorr, label='Autocorr', color='seagreen')
|
115 |
+
axs[3].set_title("Автокорреляция (память)")
|
116 |
+
|
117 |
+
for ax in axs:
|
118 |
+
ax.legend()
|
119 |
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
# --- Запуск анимации в Streamlit ---
|
122 |
if st.button("Начать анимацию"):
|