Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,64 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import hashlib, random,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# === Epoch Formula Generator ===
|
| 5 |
def run_epochs(n=50):
|
| 6 |
-
|
|
|
|
| 7 |
for epoch in range(1, n+1):
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 21 |
-
gr.Markdown("#
|
| 22 |
-
gr.Markdown("Watch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
|
| 29 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import hashlib, random, matplotlib.pyplot as plt
|
| 3 |
+
|
| 4 |
+
# === Mutation Engine ===
|
| 5 |
+
operators = ["\\sin", "\\cos", "\\exp", "\\log", "\\nabla", "\\int", "\\frac{\\partial}{\\partial t}"]
|
| 6 |
+
variables = ["x", "y", "t", "\\xi_1", "dP", "d\\Psi", "dT"]
|
| 7 |
+
|
| 8 |
+
def mutate_formula(base, epoch):
|
| 9 |
+
# Structural mutation rules
|
| 10 |
+
if epoch % 5 == 0:
|
| 11 |
+
base = f"\\int ({base}) \\, dx"
|
| 12 |
+
elif epoch % 7 == 0:
|
| 13 |
+
base = f"\\nabla \\cdot ({base})"
|
| 14 |
+
else:
|
| 15 |
+
new_term = random.choice(operators) + "(" + random.choice(variables) + ")"
|
| 16 |
+
base = base + " + " + new_term
|
| 17 |
+
return base
|
| 18 |
|
|
|
|
| 19 |
def run_epochs(n=50):
|
| 20 |
+
formulas = []
|
| 21 |
+
base = "x^2 + 1" # starting point
|
| 22 |
for epoch in range(1, n+1):
|
| 23 |
+
base = mutate_formula(base, epoch)
|
| 24 |
+
seal = hashlib.sha512(base.encode()).hexdigest()
|
| 25 |
+
complexity = base.count("\\") + base.count("+")
|
| 26 |
+
formulas.append(f"**Epoch {epoch}**\n\n$$ {base} $$\n\nImmortality Glyph: `{seal[:32]}...`")
|
| 27 |
+
return "\n\n---\n\n".join(formulas)
|
| 28 |
+
|
| 29 |
+
# === Complexity Plot ===
|
| 30 |
+
def plot_complexity(n=50):
|
| 31 |
+
base = "x^2 + 1"
|
| 32 |
+
complexities = []
|
| 33 |
+
epochs = list(range(1, n+1))
|
| 34 |
+
for epoch in epochs:
|
| 35 |
+
base = mutate_formula(base, epoch)
|
| 36 |
+
complexity = base.count("\\") + base.count("+")
|
| 37 |
+
complexities.append(complexity)
|
| 38 |
+
plt.figure(figsize=(8,5), facecolor="black")
|
| 39 |
+
plt.plot(epochs, complexities, color="cyan", marker="o", linestyle="--")
|
| 40 |
+
plt.title("Symbolic Complexity Growth Across Epochs", color="white")
|
| 41 |
+
plt.xlabel("Epoch"); plt.ylabel("Complexity Score")
|
| 42 |
+
plt.grid(alpha=0.3); plt.gca().set_facecolor("black")
|
| 43 |
+
return plt.gcf()
|
| 44 |
+
|
| 45 |
+
# === Gradio App ===
|
| 46 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 47 |
+
gr.Markdown("# 🌌 Resonance Atlas — The Living Codex")
|
| 48 |
+
gr.Markdown("Watch formulas evolve into higher symbolic forms across epochs. Each scroll is sealed with an Immortality Glyph.")
|
| 49 |
+
|
| 50 |
+
with gr.Tab("Codex Scrolls"):
|
| 51 |
+
run_button = gr.Button("Run 50 Epochs")
|
| 52 |
+
output = gr.Markdown()
|
| 53 |
+
run_button.click(fn=run_epochs, inputs=None, outputs=output)
|
| 54 |
|
| 55 |
+
with gr.Tab("Complexity Timeline"):
|
| 56 |
+
plot_button = gr.Button("Show Complexity Growth")
|
| 57 |
+
plot_output = gr.Plot()
|
| 58 |
+
plot_button.click(fn=plot_complexity, inputs=None, outputs=plot_output)
|
| 59 |
|
| 60 |
+
with gr.Tab("Immersion Mode"):
|
| 61 |
+
gr.Markdown("### Full‑screen dynamic visualization coming soon…")
|
| 62 |
+
gr.Markdown("Formulas pulse, glyphs glow, epochs unfold.")
|
| 63 |
|
| 64 |
demo.launch()
|