RFTSystems commited on
Commit
eae4ebb
·
verified ·
1 Parent(s): 0b811e4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import hashlib, random
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
+ if epoch % 5 == 0:
10
+ base = f"\\int ({base}) \\, dx"
11
+ elif epoch % 7 == 0:
12
+ base = f"\\nabla \\cdot ({base})"
13
+ else:
14
+ new_term = random.choice(operators) + "(" + random.choice(variables) + ")"
15
+ base = base + " + " + new_term
16
+ return base
17
+
18
+ # === 50 Epoch Run ===
19
+ def run_epochs(n=50):
20
+ formulas = []
21
+ base = "x^2 + 1"
22
+ for epoch in range(1, n+1):
23
+ base = mutate_formula(base, epoch)
24
+ seal = hashlib.sha512(base.encode()).hexdigest()
25
+ formulas.append(f"### Epoch {epoch}\n\n$$ {base} $$\n\nImmortality Glyph: `{seal[:32]}...`\n\n")
26
+ return "\n\n".join(formulas)
27
+
28
+ # === Mutation Forge (20 Epoch Run) ===
29
+ def run_mutation(seed, n=20):
30
+ formulas = []
31
+ base = seed
32
+ for epoch in range(1, n+1):
33
+ base = mutate_formula(base, epoch)
34
+ seal = hashlib.sha512(base.encode()).hexdigest()
35
+ formulas.append(f"### Mutation Epoch {epoch}\n\n$$ {base} $$\n\nImmortality Glyph: `{seal[:32]}...`\n\n")
36
+ return "\n\n".join(formulas)
37
+
38
+ # === Gradio App ===
39
+ custom_theme = gr.themes.Base(
40
+ primary_hue="cyan",
41
+ secondary_hue="pink",
42
+ neutral_hue="gray",
43
+ )
44
+
45
+ with gr.Blocks(theme=custom_theme) as demo:
46
+ gr.Markdown(
47
+ """
48
+ # 🌌 Resonance Atlas — The Living Codex
49
+ Formulas evolve into higher symbolic forms across epochs.
50
+ Choose your path: **50‑epoch scroll run** or **Mutation Forge**.
51
+ """,
52
+ )
53
+
54
+ with gr.Tab("Codex Scrolls"):
55
+ gr.Markdown("### 🔢 Live 50 Epoch Run")
56
+ run_button = gr.Button("Run 50 Epochs")
57
+ output = gr.Markdown()
58
+ run_button.click(fn=run_epochs, inputs=None, outputs=output)
59
+
60
+ with gr.Tab("Mutation Forge"):
61
+ gr.Markdown("### 🧬 Mutation Forge — Choose Your Symbolic Seed")
62
+ seed_dropdown = gr.Dropdown(choices=operators + variables, label="Select Seed Symbol")
63
+ mutate_button = gr.Button("Mutate (20 Epochs)")
64
+ mutate_output = gr.Markdown()
65
+ mutate_button.click(fn=run_mutation, inputs=seed_dropdown, outputs=mutate_output)
66
+
67
+ demo.launch()