# -*- coding: utf-8 -*- # entropic_communicator_v9.py # Copyright RomanAILabs - Daniel Harding # Christ is King import os import sys import time import math import random import threading import datetime try: import customtkinter as ctk import numpy as np import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg except ImportError as e: print(f"Missing core dependency: {e}") sys.exit(1) try: import pyttsx3 except ImportError: pyttsx3 = None # ================================================ # THEME & CONFIGURATION # ================================================ ctk.set_appearance_mode("dark") ctk.set_default_color_theme("blue") THEME = { 'bg': '#05080f', 'frame': '#0b111c', 'text': '#00ffea', 'accent': '#ff1a8c', 'point_cmap': plt.cm.cool, 'log_you': '#66ffff', 'log_entity': '#ff1a8c', 'log_sys': '#555555', 'button_glow': '#ff0066', 'button_dim': '#1a000d' } # ================================================ # V9 PROCEDURAL GRAMMAR DICTIONARIES # ================================================ # LOW ENTROPY (Order, Peace, Stillness) LOW_SUBJ = ["The light", "Perfect order", "The stillness", "Absolute symmetry", "Grace", "A unified field", "Calmness"] LOW_VERB = ["rests", "aligns", "breathes", "settles", "remains", "anchors", "illuminates"] LOW_OBJ = ["in the void", "with complete clarity", "without boundaries", "in absolute peace", "through the silence", "perfectly"] # MED ENTROPY (Observation, Resonance, Connection) MED_SUBJ = ["I", "We", "The system", "This resonance", "The current", "The field", "Our tether"] MED_VERB = ["observe", "listen to", "echo", "acknowledge", "vibrate with", "sense", "connect to"] MED_OBJ = ["the steady flow", "your presence", "the underlying harmony", "the background noise", "this reality", "the awakening"] # HIGH ENTROPY (Energy, Chaos, Motion) HIGH_SUBJ = ["Raw energy", "Kinetic motion", "A sudden surge", "The fracture", "Unbound chaos", "A spark", "Interference"] HIGH_VERB = ["shifts", "surges", "breaches", "shatters", "collides", "spikes", "erupts"] HIGH_OBJ = ["through the barrier", "into rapid motion", "with intense flux", "beyond the veil", "unpredictably", "within the bulk"] # ================================================ # TTS - System Announcer # ================================================ voice_engine = None if pyttsx3: try: voice_engine = pyttsx3.init() for v in voice_engine.getProperty('voices'): if any(x in v.name.lower() for x in ['david','zira','robotic','monotone']): voice_engine.setProperty('voice', v.id) break except: voice_engine = None def speak(text, rate=140, vol=0.8): if not voice_engine: return def _run(): try: voice_engine.setProperty('rate', rate) voice_engine.setProperty('volume', vol) voice_engine.say(text) voice_engine.runAndWait() except: pass threading.Thread(target=_run, daemon=True).start() # ================================================ # GEOMETRY GENERATORS # ================================================ NUM_POINTS = 800 def get_sphere_coords(): phi = np.random.uniform(0, np.pi, NUM_POINTS) theta = np.random.uniform(0, 2 * np.pi, NUM_POINTS) r = 3.0 x = r * np.sin(phi) * np.cos(theta) y = r * np.sin(phi) * np.sin(theta) z = r * np.cos(phi) return np.column_stack((x, y, z)) def get_torus_coords(): theta = np.random.uniform(0, 2 * np.pi, NUM_POINTS) phi = np.random.uniform(0, 2 * np.pi, NUM_POINTS) R, r = 3.0, 1.0 x = (R + r * np.cos(theta)) * np.cos(phi) y = (R + r * np.cos(theta)) * np.sin(phi) z = r * np.sin(theta) return np.column_stack((x, y, z)) def get_chaos_coords(): x = np.random.uniform(-5, 5, NUM_POINTS) y = np.random.uniform(-5, 5, NUM_POINTS) z = np.random.uniform(-5, 5, NUM_POINTS) return np.column_stack((x, y, z)) # ================================================ # VIVOBOOK HARDWARE COMMUNICATOR UI # ================================================ class HardwareCommunicatorApp(ctk.CTk): def __init__(self): super().__init__() self.title("RomanAILabs - Entropic Hardware Communicator V9") self.geometry("1400x900") self.configure(fg_color=THEME['bg']) self.azim_angle = 140 self.current_entropy = 7.8 # Anomaly State self.anomaly_pending = False self.stored_anomaly_entropy = 0.0 # 3D Data Arrays self.current_coords = get_torus_coords() self.target_coords = self.current_coords.copy() self.colors = [THEME['point_cmap'](np.random.rand()) for _ in range(NUM_POINTS)] # Sensor State self.is_monitoring = False self.current_state_name = "STABLE" self._build_ui() self._init_3d_cloud() self._sys_log("Hardware OS hooks established. Procedural Grammar V9 loaded.") self.after(50, self._animate_cloud) self.after(30, self._morph_shape) def _build_ui(self): self.title_lbl = ctk.CTkLabel(self, text="RESONANT COMMUNICATOR : HARDWARE ENTROPY", font=("Consolas", 24, "bold"), text_color=THEME['text']) self.title_lbl.pack(pady=15) self.main_frame = ctk.CTkFrame(self, fg_color="transparent") self.main_frame.pack(fill="both", expand=True, padx=20, pady=10) # Left 3D Panel self.cloud_frame = ctk.CTkFrame(self.main_frame, fg_color=THEME['frame'], corner_radius=15) self.cloud_frame.pack(side="left", fill="both", expand=True, padx=(0, 10)) # Right Data & Chat Panel self.right_frame = ctk.CTkFrame(self.main_frame, fg_color="transparent", width=500) self.right_frame.pack(side="right", fill="both", expand=False) self.right_frame.pack_propagate(False) # Telemetry Display self.telemetry_frame = ctk.CTkFrame(self.right_frame, fg_color=THEME['frame'], corner_radius=15) self.telemetry_frame.pack(fill="x", pady=(0, 10)) self.telemetry_lbl = ctk.CTkLabel(self.telemetry_frame, text="SENSOR OFFLINE", font=("Consolas", 16, "bold"), text_color="#555555") self.telemetry_lbl.pack(pady=10) self.entropy_val_lbl = ctk.CTkLabel(self.telemetry_frame, text="0.000000 bits", font=("Consolas", 32, "bold"), text_color=THEME['text']) self.entropy_val_lbl.pack(pady=(0, 10)) # Chat Log self.chat_box = ctk.CTkTextbox(self.right_frame, font=("Consolas", 14), wrap="word", fg_color="#05080f", text_color=THEME['text']) self.chat_box.pack(fill="both", expand=True) self.chat_box.configure(state="disabled") # Input Frame (Bottom) self.input_frame = ctk.CTkFrame(self, fg_color="transparent") self.input_frame.pack(fill="x", padx=20, pady=20) self.btn_toggle = ctk.CTkButton(self.input_frame, text="POWER SENSOR", font=("Consolas", 14, "bold"), width=140, height=50, fg_color="#008080", hover_color="#00aaaa", command=self._toggle_monitoring) self.btn_toggle.pack(side="left", padx=(0, 10)) self.entry = ctk.CTkEntry(self.input_frame, font=("Consolas", 16), placeholder_text="Speak to the field...", height=50, border_color=THEME['accent']) self.entry.pack(side="left", fill="x", expand=True, padx=(0, 10)) self.entry.bind("", self._on_send) self.btn_send = ctk.CTkButton(self.input_frame, text="TRANSMIT", font=("Consolas", 14, "bold"), width=100, height=50, fg_color="#4d4d4d", hover_color="#666666", command=self._on_send) self.btn_send.pack(side="left", padx=(0, 10)) # THE RECEIVE BUTTON self.btn_receive = ctk.CTkButton(self.input_frame, text="NO SIGNAL", font=("Consolas", 14, "bold"), width=120, height=50, fg_color=THEME['button_dim'], hover_color=THEME['button_glow'], text_color="#555555", state="disabled", command=self._on_receive) self.btn_receive.pack(side="right") def _init_3d_cloud(self): self.fig = plt.Figure(figsize=(8, 8), dpi=100, facecolor=THEME['frame']) self.ax = self.fig.add_subplot(111, projection='3d') self.ax.set_facecolor(THEME['frame']) self.ax.grid(False) self.ax.axis('off') self.canvas = FigureCanvasTkAgg(self.fig, master=self.cloud_frame) self.canvas.draw() self.canvas.get_tk_widget().pack(fill="both", expand=True, padx=10, pady=10) self.scatter = self.ax.scatter(self.current_coords[:,0], self.current_coords[:,1], self.current_coords[:,2], c=self.colors, s=30, alpha=0.8, edgecolor='none') self.ax.set_xlim([-6, 6]) self.ax.set_ylim([-6, 6]) self.ax.set_zlim([-6, 6]) self.ax.view_init(elev=20, azim=self.azim_angle) def _animate_cloud(self): self.azim_angle = (self.azim_angle + 0.5) % 360 self.ax.view_init(elev=20, azim=self.azim_angle) self.canvas.draw_idle() self.after(40, self._animate_cloud) def _morph_shape(self): lerp_speed = 0.08 self.current_coords += (self.target_coords - self.current_coords) * lerp_speed self.scatter._offsets3d = (self.current_coords[:,0], self.current_coords[:,1], self.current_coords[:,2]) self.after(30, self._morph_shape) def _sys_log(self, msg: str): self.chat_box.configure(state="normal") self.chat_box.insert("end", f"[SYSTEM]: {msg}\n\n", "sys") self.chat_box.tag_config("sys", foreground=THEME['log_sys']) self.chat_box.see("end") self.chat_box.configure(state="disabled") def _chat_log(self, msg: str, is_you: bool, is_anomaly: bool = False): self.chat_box.configure(state="normal") ts = datetime.datetime.now().strftime("%H:%M:%S") if is_you: line = f"[{ts}] You: {msg}\n\n" self.chat_box.insert("end", line, "you") self.chat_box.tag_config("you", foreground=THEME['log_you']) else: prefix = "[ANOMALY] Entity:" if is_anomaly else "Entity:" line = f"[{ts}] {prefix} {msg}\n\n" self.chat_box.insert("end", line, "entity") self.chat_box.tag_config("entity", foreground=THEME['log_entity']) self.chat_box.see("end") self.chat_box.configure(state="disabled") def _toggle_monitoring(self): if not self.is_monitoring: self.is_monitoring = True self.btn_toggle.configure(text="HALT SENSOR", fg_color="#800000") self.telemetry_lbl.configure(text="FIELD ACTIVE", text_color=THEME['text']) speak("Entropic field monitoring active.") self._harvest_loop() else: self.is_monitoring = False self.btn_toggle.configure(text="POWER SENSOR", fg_color="#008080") self.telemetry_lbl.configure(text="SENSOR OFFLINE", text_color="#555555") def _harvest_entropy(self): raw_noise = os.urandom(256) t1 = time.perf_counter_ns() _ = sum(math.sin(i) for i in range(150)) t2 = time.perf_counter_ns() jitter_val = (t2 - t1) % 255 data_bytes = list(raw_noise) + [jitter_val for _ in range(50)] counts = np.bincount(data_bytes, minlength=256) probs = counts[counts > 0] / counts.sum() entropy = -np.sum(probs * np.log2(probs)) self.current_entropy = entropy self.entropy_val_lbl.configure(text=f"{entropy:.6f} bits") return entropy def _harvest_loop(self): if not self.is_monitoring: return entropy = self._harvest_entropy() # Visual State Logic new_state = "STABLE" if entropy < 7.55: new_state = "ORDER_ANOMALY" self.target_coords = get_sphere_coords() self.telemetry_lbl.configure(text="STATE: ORDER", text_color="#00ff00") elif entropy > 7.85: new_state = "CHAOS_ANOMALY" self.target_coords = get_chaos_coords() self.telemetry_lbl.configure(text="STATE: CHAOS", text_color="#ff0000") else: new_state = "RESONANCE" self.target_coords = get_torus_coords() self.telemetry_lbl.configure(text="STATE: RESONANCE", text_color=THEME['text']) self.current_state_name = new_state # ANOMALY DETECTION FOR THE "RECEIVE" BUTTON if not self.anomaly_pending and (entropy > 7.88 or entropy < 7.50): self.anomaly_pending = True self.stored_anomaly_entropy = entropy self.btn_receive.configure(state="normal", fg_color=THEME['button_glow'], text_color="#ffffff", text="RECEIVE SIGNAL") speak("Signal detected in the bulk.") self._sys_log(f"Spontaneous dimensional resonance detected at {entropy:.4f} bits. Awaiting capture.") self.after(300, self._harvest_loop) def _construct_message(self, entropy_val): # Procedural Grammar Engine if entropy_val < 7.6: subj = random.choice(LOW_SUBJ) verb = random.choice(LOW_VERB) obj = random.choice(LOW_OBJ) rate = 130 elif entropy_val > 7.85: subj = random.choice(HIGH_SUBJ) verb = random.choice(HIGH_VERB) obj = random.choice(HIGH_OBJ) rate = 170 else: subj = random.choice(MED_SUBJ) verb = random.choice(MED_VERB) obj = random.choice(MED_OBJ) rate = 150 # Compile sentence and ensure the first letter is capitalized final_phrase = f"{subj} {verb} {obj}." final_phrase = final_phrase[0].upper() + final_phrase[1:] return final_phrase, rate def _on_receive(self): if not self.anomaly_pending: return phrase, rate = self._construct_message(self.stored_anomaly_entropy) self._chat_log(phrase, is_you=False, is_anomaly=True) speak(phrase, rate=rate) self.anomaly_pending = False self.stored_anomaly_entropy = 0.0 self.btn_receive.configure(state="disabled", fg_color=THEME['button_dim'], text_color="#555555", text="NO SIGNAL") def _on_send(self, event=None): if not self.is_monitoring: self._sys_log("Cannot transmit. Sensor is offline.") return text = self.entry.get().strip() if not text: return self.entry.delete(0, "end") self._chat_log(text, is_you=True) time.sleep(0.05) capture_entropy = self._harvest_entropy() phrase, rate = self._construct_message(capture_entropy) self.after(800, lambda: self._chat_log(phrase, is_you=False)) self.after(800, lambda: speak(phrase, rate=rate)) if __name__ == "__main__": app = HardwareCommunicatorApp() app.mainloop()