-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
116 lines (92 loc) · 3.88 KB
/
main.py
File metadata and controls
116 lines (92 loc) · 3.88 KB
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
import time
import os
import sys
from watchdog.observers import Observer
from core import PlasticCortex
from senses import UniversalFeeder
from dashboard import Dashboard
def main():
print("------------------------------------------------")
print(" 🧬 NANO-DAEMON: INTELLIGENT ORGANISM ")
print("------------------------------------------------")
# 1. INITIALIZE THE DASHBOARD
dash = Dashboard()
dash.start()
# 2. BIRTH THE BRAIN
print("🧠 Initializing Hebbian Core...")
brain = PlasticCortex()
# LOAD PERSISTED STATE
print("📂 Loading synapses...")
brain.load_cortex()
# --- STEP 10: Initial Metabolic Sync ---
brain.sync_metabolism(time.localtime().tm_hour)
# 3. CONNECT SENSES
print("👁️ Initializing Sensory Cortex...")
watch_path = "."
feeder = UniversalFeeder(brain)
# ACTIVATE INTERNET SENSE
print("🌐 Connecting Global Senses...")
from senses import InternetSense
web_sense = InternetSense(brain, feeder=feeder)
web_sense.start()
print("👁️ Starting Local Eye...")
observer = Observer()
observer.schedule(feeder, watch_path, recursive=True)
observer.start()
print(f"✅ SENSORY CORTEX ACTIVE. Watching: {os.path.abspath(watch_path)}")
# 4. INITIAL FEEDING
print("🍽️ Starting Initial Feeding Session...")
feeder.feed_all_existing(watch_path)
print("------------------------------------------------")
print(" Your organism is now feeding on information.")
print(" Open http://localhost:8000 to monitor brain state.")
print(" Press Ctrl+C to hibernate.")
print("------------------------------------------------")
try:
last_eaten = 0
last_pulse_time = time.time()
last_consolidation = 0
last_mitosis = 0
while True:
# --- STEP 10: Periodic Metabolic Sync (Hourly) ---
if time.localtime().tm_min == 0 and time.localtime().tm_sec < 5:
brain.sync_metabolism(time.localtime().tm_hour)
# 1. PERIODIC SAVING (Faster for rapid growth)
if feeder.processed_count > last_eaten + 10:
brain.save_cortex()
last_eaten = feeder.processed_count
# 2. CONSOLIDATION CYCLE (DEEPER THINKING) - Every 5 experiences
if feeder.processed_count >= last_consolidation + 5:
brain.consolidate()
last_consolidation = feeder.processed_count
# 3. NEURAL MITOSIS (INFINITE GROWTH) - Every 20 experiences
if feeder.processed_count >= last_mitosis + 20:
brain.grow(256) # Larger growth pulses
last_mitosis = feeder.processed_count
# 4. METABOLIC PULSE & GENERATIVE REPLAY
if time.time() - last_pulse_time > 15:
from senses import update_telemetry
# Generative Replay: Dream and learn from the dream
feeder.hallucinate()
# Ponder on its own state
activation, entropy = brain.reflect()
# --- CURIOSITY RESPONSE ---
# If the dream is too strange/new, consolidate it immediately
if entropy > 0.3:
print("❗ SURPRISE: Organism found a strange thought. Consolidating...")
brain.consolidate()
update_telemetry(
feeder.processed_count,
"🧬 GENERATIVE REPLAY (DREAMING)",
0.5,
entropy
)
last_pulse_time = time.time()
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
print("\n💤 Hibernating...")
brain.save_cortex()
observer.join()
if __name__ == "__main__":
main()