File size: 6,643 Bytes
02919f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import os
import json
import numpy as np
import matplotlib.pyplot as plt
from typing import List, Dict, Any, Optional

folder = '.'  # Or your path to cocoons

quantum_states = []
chaos_states = []
proc_ids = []
labels = []
all_perspectives = []
meta_mutations = []

def get_latest_quantum_state() -> List[float]:
    """Get the most recent quantum state from cocoon files."""
    latest_cocoon = None
    latest_time = 0
    
    for fname in os.listdir(folder):
        if fname.endswith('.cocoon'):
            full_path = os.path.join(folder, fname)
            file_time = os.path.getmtime(full_path)
            if file_time > latest_time:
                latest_time = file_time
                latest_cocoon = full_path
    
    if not latest_cocoon:
        return [0.0, 0.0]  # Default quantum state
        
    try:
        with open(latest_cocoon, 'r') as f:
            data = json.load(f)['data']
            return data.get('quantum_state', [0.0, 0.0])
    except Exception as e:
        print(f"Warning: Could not read quantum state from {latest_cocoon}: {e}")
        return [0.0, 0.0]

def simple_neural_activator(quantum_vec: List[float], chaos_vec: List[float]) -> int:
    """Lightweight thresholds: feels like a tiny neural net inspired by input!"""
    q_sum = sum(quantum_vec)
    c_var = np.var(chaos_vec)
    activated = 1 if q_sum + c_var > 1 else 0
    return activated

def codette_dream_agent(quantum_vec: List[float], chaos_vec: List[float]) -> tuple[List[float], List[float]]:
    """Blend quantum and chaos vectors using trigonometric transformations."""
    dream_q = [np.sin(q * np.pi) for q in quantum_vec]
    dream_c = [np.cos(c * np.pi) for c in chaos_vec]
    return dream_q, dream_c

def get_quantum_statistics() -> Dict[str, Any]:
    """Get statistical information about quantum states across all cocoons."""
    quantum_states = []
    
    for fname in os.listdir('.'):
        if fname.endswith('.cocoon'):
            try:
                with open(fname, 'r') as f:
                    data = json.load(f)['data']
                    state = data.get('quantum_state')
                    if state:
                        quantum_states.append(state)
            except:
                continue
    
    if not quantum_states:
        return {
            'count': 0,
            'average': [0.0, 0.0],
            'variance': [0.0, 0.0]
        }
    
    # Calculate statistics
    count = len(quantum_states)
    avg_state = [
        sum(s[0] for s in quantum_states) / count,
        sum(s[1] for s in quantum_states) / count
    ]
    
    var_state = [
        sum((s[0] - avg_state[0])**2 for s in quantum_states) / count,
        sum((s[1] - avg_state[1])**2 for s in quantum_states) / count
    ]
    
    return {
        'count': count,
        'average': avg_state,
        'variance': var_state
    }
        if fname.endswith('.cocoon'):
            full_path = os.path.join(folder, fname)
            file_time = os.path.getmtime(full_path)
            if file_time > latest_time:
                latest_time = file_time
                latest_cocoon = full_path
    
    if not latest_cocoon:
        return [0.0, 0.0]  # Default quantum state
        
    try:
        with open(latest_cocoon, 'r') as f:
            data = json.load(f)['data']
            return data.get('quantum_state', [0.0, 0.0])
    except Exception as e:
        print(f"Warning: Could not read quantum state from {latest_cocoon}: {e}")
        return [0.0, 0.0]

def simple_neural_activator(quantum_vec, chaos_vec):
    # Lightweight thresholds: feels like a tiny neural net inspired by input!
    q_sum = sum(quantum_vec)
    c_var = np.var(chaos_vec)
    activated = 1 if q_sum + c_var > 1 else 0
    return activated

def codette_dream_agent(quantum_vec, chaos_vec):
    # Blend them using pseudo-random logic—a "mutated" universe!
    dream_q = [np.sin(q * np.pi) for q in quantum_vec]
    dream_c = [np.cos(c * np.pi) for c in chaos_vec]
    return dream_q, dream_c

def philosophical_perspective(qv, cv):
    # Synthesizes a philosophy based on state magnitude and spread
    m = np.max(qv) + np.max(cv)
    if m > 1.3:
        return "Philosophical Note: This universe is likely awake."
    else:
        return "Philosophical Note: Echoes in the void."

# Meta processing loop
print("\nMeta Reflection Table:\n")
header = "Cocoon File | Quantum State | Chaos State | Neural | Dream Q/C | Philosophy"
print(header)
print('-'*len(header))

for fname in os.listdir(folder):
    if fname.endswith('.cocoon'):
        with open(os.path.join(folder, fname), 'r') as f:
            try:
                dct=json.load(f)['data']
                q=dct.get('quantum_state',[0,0])
                c=dct.get('chaos_state',[0,0,0])
                neural=simple_neural_activator(q,c)
                dreamq,dreamc=codette_dream_agent(q,c)
                phil=philosophical_perspective(q,c)
                quantum_states.append(q)
                chaos_states.append(c)
                proc_ids.append(dct.get('run_by_proc',-1))
                labels.append(fname)
                all_perspectives.append(dct.get('perspectives',[]))
                meta_mutations.append({'dreamQ':dreamq,'dreamC':dreamc,'neural':neural,'philosophy':phil})
                print(f"{fname} | {q} | {c} | {neural} | {dreamq}/{dreamc} | {phil}")
            except Exception as e:
                print(f"Warning: {fname} failed ({e})")

# Also plot meta-dream mutated universes!
if len(meta_mutations)>0:
    dq0=[m['dreamQ'][0] for m in meta_mutations]
    dc0=[m['dreamC'][0] for m in meta_mutations]
    ncls=[m['neural'] for m in meta_mutations]

    plt.figure(figsize=(8,6))
    sc=plt.scatter(dq0,dc0,c=ncls,cmap='spring',s=100)
    plt.xlabel('Dream Quantum[0]')
    plt.ylabel('Dream Chaos[0]')
    plt.title('Meta-Dream Codette Universes')
    plt.colorbar(sc,label="Neural Activation Class")
    plt.grid(True)
    plt.show()
else:
    print("No valid cocoons found for meta-analysis.")
root@Jmachine:/home/raiff/Documents/logs/astro_cocoons# analyze_cocoons.py
bash: analyze_cocoons.py: command not found...
root@Jmachine:/home/raiff/Documents/logs/astro_cocoons# python analyze_cocoons.py
Traceback (most recent call last):
  File "/home/raiff/Documents/logs/astro_cocoons/analyze_cocoons.py", line 11, in <module>
    for fname in os.listdir(folder):
                 ~~~~~~~~~~^^^^^^^^
FileNotFoundError: [Errno 2] No such f