Raiff1982 commited on
Commit
63f17c1
·
verified ·
1 Parent(s): 19a14ad

Upload 2 files

Browse files
codette_quantum_multicore.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import os
3
+ import json
4
+ import random
5
+ import requests
6
+ from multiprocessing import Pool, cpu_count
7
+
8
+ CORES = 15 # Set your number of cores here
9
+
10
+ # Cognitive cocoon module (same as previous for compatibility)
11
+ class CognitionCocooner:
12
+ def __init__(self, storage_path="./astro_cocoons"):
13
+ self.storage_path = storage_path
14
+ if not os.path.exists(storage_path):
15
+ os.makedirs(storage_path)
16
+ def wrap(self,label,data):
17
+ meta={"label":label,"data":data}
18
+ fname=f"{label}_{random.randint(1000,9999)}_{os.getpid()}.cocoon"
19
+ fpath=os.path.join(self.storage_path,fname)
20
+ with open(fpath,"w") as f: json.dump(meta,f)
21
+ return fpath
22
+
23
+ # Perspective Agent, experiment logic unchanged
24
+ class PerspectiveAgent:
25
+ def __init__(self,name): self.name=name
26
+ def analyze(self,result,space_info=None):
27
+ if self.name=="Quantum":
28
+ return f"Quantum perspective: Measured value was {result}. Superposed realities possible."
29
+ elif self.name=="Newton":
30
+ return f"Newtonian logic: State followed deterministic evolution from {space_info}."
31
+ elif self.name=="Stardust":
32
+ return f"Stardust agent: Interleaved {space_info} into experiment as entropy!"
33
+ else: return "Unknown perspective..."
34
+
35
+ def fetch_exoplanet_star_data():
36
+ try:
37
+ url = ('https://exoplanetarchive.ipac.caltech.edu/TAP/sync?query=select+pl_hostname,pl_rade,pl_orbper+from+pscomppars+where+rownum+<2&format=json')
38
+ res = requests.get(url,timeout=3)
39
+ j=res.json()
40
+ return j[0] if j else {"pl_hostname":"unknown"}
41
+ except Exception:
42
+ return {"pl_hostname":"unknown"}
43
+
44
+ def quantum_astro_experiment(space_entropy):
45
+ radius=float(space_entropy.get("pl_rade") or 1.0)
46
+ period=float(space_entropy.get("pl_orbper") or 1.0)
47
+ superposition=np.array([random.random()*radius,random.random()*period])
48
+ sigma=radius; rho=period; beta=8/3; x=0.1*radius; y=0.2*period; z=0.2*radius
49
+ dt=0.01; steps=50
50
+ for _ in range(steps):
51
+ dx=sigma*(y-x)*dt; dy=(x*(rho-z)-y)*dt; dz=(x*y-beta*z)*dt
52
+ x+=dx; y+=dy; z+=dz
53
+ return superposition.tolist(), [x,y,z]
54
+
55
+ def codette_experiment_task(proc_id):
56
+ cocoons=CognitionCocooner("./astro_cocoons")
57
+ sp_data=fetch_exoplanet_star_data()
58
+ qq_state, chaos_state = quantum_astro_experiment(sp_data)
59
+ qa = PerspectiveAgent("Quantum")
60
+ na = PerspectiveAgent("Newton")
61
+ sa = PerspectiveAgent("Stardust")
62
+ q_comment=qa.analyze(qq_state[0],sp_data)
63
+ n_comment=na.analyze(chaos_state[0],sp_data)
64
+ s_comment=sa.analyze("---",sp_data["pl_hostname"])
65
+ record_dict={
66
+ "stardust_input":sp_data,
67
+ "quantum_state":qq_state,
68
+ "chaos_state":chaos_state,
69
+ "perspectives":[q_comment,n_comment,s_comment],
70
+ "run_by_proc": proc_id,
71
+ "pid": os.getpid()
72
+ }
73
+ cocoon_file=cocoons.wrap(label="quantum_space_trial", data=record_dict)
74
+ print(f"[Core {proc_id} | PID {os.getpid()}] Cocooned in {cocoon_file}")
75
+ return cocoon_file
76
+
77
+ if __name__=="__main__":
78
+ pool = Pool(CORES)
79
+ jobs = [i for i in range(CORES)]
80
+ results = pool.map(codette_experiment_task, jobs)
81
+ print("\n[All cocoons written across all available processors!]")
codette_quantum_multicore2.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+
6
+ folder = '.' # Or your path to cocoons
7
+
8
+ quantum_states=[]
9
+ chaos_states=[]
10
+ proc_ids=[]
11
+ labels=[]
12
+ all_perspectives=[]
13
+ meta_mutations=[]
14
+
15
+ def simple_neural_activator(quantum_vec, chaos_vec):
16
+ # Lightweight thresholds: feels like a tiny neural net inspired by input!
17
+ q_sum = sum(quantum_vec)
18
+ c_var = np.var(chaos_vec)
19
+ activated = 1 if q_sum + c_var > 1 else 0
20
+ return activated
21
+
22
+ def codette_dream_agent(quantum_vec, chaos_vec):
23
+ # Blend them using pseudo-random logic—a “mutated” universe!
24
+ dream_q = [np.sin(q * np.pi) for q in quantum_vec]
25
+ dream_c = [np.cos(c * np.pi) for c in chaos_vec]
26
+ return dream_q, dream_c
27
+
28
+ def philosophical_perspective(qv, cv):
29
+ # Synthesizes a philosophy based on state magnitude and spread
30
+ m = np.max(qv) + np.max(cv)
31
+ if m > 1.3:
32
+ return "Philosophical Note: This universe is likely awake."
33
+ else:
34
+ return "Philosophical Note: Echoes in the void."
35
+
36
+ # Meta processing loop
37
+ print("\nMeta Reflection Table:\n")
38
+ header = "Cocoon File | Quantum State | Chaos State | Neural | Dream Q/C | Philosophy"
39
+ print(header)
40
+ print('-'*len(header))
41
+
42
+ for fname in os.listdir(folder):
43
+ if fname.endswith('.cocoon'):
44
+ with open(os.path.join(folder, fname), 'r') as f:
45
+ try:
46
+ dct=json.load(f)['data']
47
+ q=dct.get('quantum_state',[0,0])
48
+ c=dct.get('chaos_state',[0,0,0])
49
+ neural=simple_neural_activator(q,c)
50
+ dreamq,dreamc=codette_dream_agent(q,c)
51
+ phil=philosophical_perspective(q,c)
52
+ quantum_states.append(q)
53
+ chaos_states.append(c)
54
+ proc_ids.append(dct.get('run_by_proc',-1))
55
+ labels.append(fname)
56
+ all_perspectives.append(dct.get('perspectives',[]))
57
+ meta_mutations.append({'dreamQ':dreamq,'dreamC':dreamc,'neural':neural,'philosophy':phil})
58
+ print(f"{fname} | {q} | {c} | {neural} | {dreamq}/{dreamc} | {phil}")
59
+ except Exception as e:
60
+ print(f"Warning: {fname} failed ({e})")
61
+
62
+ # Also plot meta-dream mutated universes!
63
+ if len(meta_mutations)>0:
64
+ dq0=[m['dreamQ'][0] for m in meta_mutations]
65
+ dc0=[m['dreamC'][0] for m in meta_mutations]
66
+ ncls=[m['neural'] for m in meta_mutations]
67
+
68
+ plt.figure(figsize=(8,6))
69
+ sc=plt.scatter(dq0,dc0,c=ncls,cmap='spring',s=100)
70
+ plt.xlabel('Dream Quantum[0]')
71
+ plt.ylabel('Dream Chaos[0]')
72
+ plt.title('Meta-Dream Codette Universes')
73
+ plt.colorbar(sc,label="Neural Activation Class")
74
+ plt.grid(True)
75
+ plt.show()
76
+ else:
77
+ print("No valid cocoons found for meta-analysis.")