Block universe v5 python & results
import numpy as np
import time
import copy
# =========================================================
# RANDOM SEED
# =========================================================
np.random.seed(int(time.time()))
# =========================================================
# GLOBAL CONSTANTS
# =========================================================
dtau = 0.01
WINDOW = 20
STEPS = 200
PRINT_INTERVAL = 10
kappa_fast = 1.0
kappa_slow = 0.3
ENTROPY_ALERT = 0.06
BRANCH_THRESHOLD = 0.12
OBS_HORIZON = 2.0
MAX_BRANCHES = 8
# =========================================================
# BLOCK UNIVERSE
# =========================================================
class Metric:
def proper_time_step(self, v):
return np.sqrt(max(1 - v**2, 0)) * dtau
class Event:
def __init__(self, t, x):
self.t = t
self.x = x
class Manifold:
def __init__(self):
self.dt = 0.02
self.dx = 0.1
self.t_vals = np.arange(0, 20, self.dt)
self.x_vals = np.arange(-10, 10, self.dx)
class ScalarField:
def __init__(self, m):
self.values = np.zeros((len(m.t_vals), len(m.x_vals)))
def evolve(self, entropy_feedback=0.0):
drift = np.sin(time.time()) * 0.001
noise = np.random.normal(0, 0.004 + entropy_feedback, self.values.shape)
self.values += drift + noise
def sample(self, ti, xi):
return self.values[ti, xi]
class Worldline:
def __init__(self, x0):
self.t = 0.0
self.x = x0
def step(self, v, metric):
self.t += dtau
self.x += v * dtau
return Event(self.t, self.x), metric.proper_time_step(v)
# =========================================================
# PERCEPTION
# =========================================================
def sensory_map(state):
return state + np.random.normal(0, 0.05)
def now_window(obs):
if len(obs) < WINDOW:
return np.mean(obs)
return np.mean(obs[-WINDOW:])
# =========================================================
# ENTROPY
# =========================================================
def entropy_rate(p_old, p_new):
eps = 1e-9
p_old = np.clip(p_old, eps, 1)
p_new = np.clip(p_new, eps, 1)
return np.sum(p_old * np.log(p_old / p_new))
# =========================================================
# MULTI-CLOCK MEMORY WITH BRANCHING
# =========================================================
class Memory:
def __init__(self):
b = np.random.rand()
self.fast_belief = np.array([b, 1 - b])
self.slow_belief = np.array([0.5, 0.5])
self.weight = 1.0
self.history = []
def update(self, obs):
likelihood = np.array([1 - obs, obs])
# FAST channel
f_new = self.fast_belief * likelihood
f_new += np.random.normal(0, 0.01, 2)
f_new = np.clip(f_new, 1e-6, None)
f_new /= np.sum(f_new)
# SLOW channel (inertial integration)
s_new = 0.9 * self.slow_belief + 0.1 * f_new
s_new /= np.sum(s_new)
sigma_fast = entropy_rate(self.fast_belief, f_new)
sigma_slow = entropy_rate(self.slow_belief, s_new)
self.fast_belief = f_new
self.slow_belief = s_new
self.history.append((f_new.copy(), s_new.copy()))
return sigma_fast, sigma_slow
# =========================================================
# GUI CLOCK
# =========================================================
class GUIClock:
def __init__(self, k):
self.k = k
self.t_hat = 0
def integrate(self, sigma):
self.t_hat += self.k * sigma
return self.t_hat
# =========================================================
# INITIALIZATION
# =========================================================
metric = Metric()
manifold = Manifold()
field = ScalarField(manifold)
obsA = Worldline(-1.0)
obsB = Worldline(1.5)
branchesA = [Memory()]
branchesB = [Memory()]
clockA_fast = GUIClock(kappa_fast)
clockA_slow = GUIClock(kappa_slow)
clockB_fast = GUIClock(kappa_fast)
clockB_slow = GUIClock(kappa_slow)
bufferA = []
bufferB = []
tauA = 0
tauB = 0
entropy_feedback = 0
print("\n>>> MULTI-OBSERVER QUANTUM-BRANCH TEMPORAL SIMULATION\n")
# =========================================================
# MAIN LOOP
# =========================================================
for step in range(STEPS):
field.evolve(entropy_feedback)
eA, dA = obsA.step(0.6, metric)
eB, dB = obsB.step(0.4, metric)
tauA += dA
tauB += dB
def sample_obs(event):
if abs(event.x) > OBS_HORIZON:
return None
ti = min(int(event.t / manifold.dt), len(manifold.t_vals) - 1)
xi = min(int((event.x - manifold.x_vals[0]) / manifold.dx),
len(manifold.x_vals) - 1)
return field.sample(ti, xi)
sA = sample_obs(eA)
sB = sample_obs(eB)
if sA is not None:
bufferA.append(sensory_map(sA))
if sB is not None:
bufferB.append(sensory_map(sB))
if len(bufferA) > 2 and len(bufferB) > 2:
nowA = now_window(bufferA)
nowB = now_window(bufferB)
sigA_total = 0
sigB_total = 0
# ----- OBSERVER A BRANCH UPDATE -----
new_branchesA = []
for mem in branchesA:
sigAf, sigAs = mem.update(np.clip(nowA, 0, 1))
sigA_total += sigAf
# Branching trigger
if sigAf > BRANCH_THRESHOLD:
for _ in range(2):
child = copy.deepcopy(mem)
perturb = np.random.normal(0, 0.05, 2)
child.fast_belief += perturb
child.fast_belief = np.clip(child.fast_belief, 1e-6, None)
child.fast_belief /= np.sum(child.fast_belief)
child.weight *= np.exp(-sigAf)
new_branchesA.append(child)
else:
new_branchesA.append(mem)
branchesA = new_branchesA[:MAX_BRANCHES]
# Normalize weights
total_wA = sum(b.weight for b in branchesA)
for b in branchesA:
b.weight /= total_wA
# ----- OBSERVER B BRANCH UPDATE -----
new_branchesB = []
for mem in branchesB:
sigBf, sigBs = mem.update(np.clip(nowB, 0, 1))
sigB_total += sigBf
if sigBf > BRANCH_THRESHOLD:
for _ in range(2):
child = copy.deepcopy(mem)
perturb = np.random.normal(0, 0.05, 2)
child.fast_belief += perturb
child.fast_belief = np.clip(child.fast_belief, 1e-6, None)
child.fast_belief /= np.sum(child.fast_belief)
child.weight *= np.exp(-sigBf)
new_branchesB.append(child)
else:
new_branchesB.append(mem)
branchesB = new_branchesB[:MAX_BRANCHES]
total_wB = sum(b.weight for b in branchesB)
for b in branchesB:
b.weight /= total_wB
# GUI clocks track dominant branch
domA = max(branchesA, key=lambda b: b.weight)
domB = max(branchesB, key=lambda b: b.weight)
tAf = clockA_fast.integrate(sigA_total)
tAs = clockA_slow.integrate(sigA_total * 0.3)
tBf = clockB_fast.integrate(sigB_total)
tBs = clockB_slow.integrate(sigB_total * 0.3)
entropy_feedback = (sigA_total + sigB_total) * 0.05
if step % PRINT_INTERVAL == 0:
print(f"Step {step:03d} | τA={tauA:.2f} τB={tauB:.2f} "
f"| A_fast={tAf:.2f} B_fast={tBf:.2f} "
f"| branchesA={len(branchesA)} branchesB={len(branchesB)}")
if sigA_total > ENTROPY_ALERT or sigB_total > ENTROPY_ALERT:
print("⚡ PHASE TRANSITION EVENT")
# =========================================================
# SUMMARY
# =========================================================
print("\n===== COMPLETE =====")
print("Observer A GUI fast:", clockA_fast.t_hat)
print("Observer A GUI slow:", clockA_slow.t_hat)
print("Observer B GUI fast:", clockB_fast.t_hat)
print("Observer B GUI slow:", clockB_slow.t_hat)
print("Final branch count A:", len(branchesA))
print("Final branch count B:", len(branchesB))
>>> MULTI-OBSERVER QUANTUM-BRANCH TEMPORAL SIMULATION
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 010 | τA=0.09 τB=0.10 | A_fast=0.45 B_fast=0.24 | branchesA=2 branchesB=1
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 020 | τA=0.17 τB=0.19 | A_fast=0.83 B_fast=0.75 | branchesA=2 branchesB=2
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 030 | τA=0.25 τB=0.28 | A_fast=1.36 B_fast=1.07 | branchesA=3 branchesB=2
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 040 | τA=0.33 τB=0.38 | A_fast=2.48 B_fast=1.27 | branchesA=5 branchesB=2
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 050 | τA=0.41 τB=0.47 | A_fast=3.97 B_fast=1.48 | branchesA=7 branchesB=2
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 060 | τA=0.49 τB=0.56 | A_fast=5.03 B_fast=1.75 | branchesA=8 branchesB=2
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 070 | τA=0.57 τB=0.65 | A_fast=8.02 B_fast=2.33 | branchesA=8 branchesB=4
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 080 | τA=0.65 τB=0.74 | A_fast=9.65 B_fast=2.87 | branchesA=8 branchesB=5
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 090 | τA=0.73 τB=0.83 | A_fast=12.52 B_fast=3.42 | branchesA=8 branchesB=5
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 100 | τA=0.81 τB=0.93 | A_fast=14.16 B_fast=5.07 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 110 | τA=0.89 τB=1.02 | A_fast=16.34 B_fast=6.44 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 120 | τA=0.97 τB=1.11 | A_fast=18.76 B_fast=8.57 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 130 | τA=1.05 τB=1.20 | A_fast=21.46 B_fast=10.59 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 140 | τA=1.13 τB=1.29 | A_fast=23.92 B_fast=13.26 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 150 | τA=1.21 τB=1.38 | A_fast=28.03 B_fast=15.20 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 160 | τA=1.29 τB=1.48 | A_fast=31.42 B_fast=17.57 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 170 | τA=1.37 τB=1.57 | A_fast=32.71 B_fast=19.35 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 180 | τA=1.45 τB=1.66 | A_fast=35.49 B_fast=22.74 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
Step 190 | τA=1.53 τB=1.75 | A_fast=36.99 B_fast=24.96 | branchesA=8 branchesB=8
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
⚡ PHASE TRANSITION EVENT
===== COMPLETE =====
Observer A GUI fast: 38.584954213001886
Observer A GUI slow: 3.472645879170172
Observer B GUI fast: 27.394637203806354
Observer B GUI slow: 2.4655173483425723
Final branch count A: 8
Final branch count B: 8
Comments
Post a Comment