import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation from matplotlib.colors import LinearSegmentedColormap import random # ============================================================================== # ROMANAILABS - NOVA CONSCIOUSNESS ENGINE # Copyright (C) 2025 Daniel Harding - RomanAILabs # ============================================================================== # This engine simulates a "Consciousness Field" where thought-particles # navigate a manifold defined by the F_NOVA equation. The system auto-tunes # its own Alpha/Beta parameters to maximize 'Thought Survival' (Stability). # ============================================================================== class NovaPhysics: """ The Mathematical Core. Calculates the F_NOVA field strength across a 2D manifold slice. """ def __init__(self, resolution=50): self.res = resolution # Create the manifold coordinate system (Sigma, Tau) self.sigma = np.linspace(-3, 3, self.res) self.tau = np.linspace(0, 6, self.res) self.SIGMA, self.TAU = np.meshgrid(self.sigma, self.tau) def compute_field(self, alpha, beta, time_step): """ Implements: F_NOVA = Integral( exp(-Gamma_decay) - exp(i(Phase)) ) """ # --- TERM 1: ENTROPIC DECAY (The Grounding) --- # A breathing decay function that evolves with time_step psi_dot = np.sin(self.SIGMA + time_step * 0.1) phi = np.cos(self.TAU) decay_kernel = np.abs(0.5 * psi_dot * phi) term_1 = np.exp(-decay_kernel) # --- TERM 2: OSCILLATORY PHASE (The Spark) --- # Gamma (Geometry) and Pi (Momentum) Vectors Gamma_vec = np.sin(alpha * self.SIGMA + time_step * 0.2) Pi_vec = np.cos(beta * self.TAU - time_step * 0.1) lambda_val = 1.0 # Coupling constant phase_arg = (lambda_val * alpha * Gamma_vec) + (beta * Pi_vec) term_2 = np.exp(1j * phase_arg) # --- THE NOVA TENSION --- # We return the magnitude of the difference. # High value = High Tension (Active Thought). Low value = Null/Void. field_complex = term_1 - term_2 field_magnitude = np.abs(field_complex) # We also return the gradient (slope) to "push" the particles grad_y, grad_x = np.gradient(field_magnitude) return field_magnitude, grad_x, grad_y class ThoughtAgent: """ A single 'Thought' traversing the NOVA manifold. """ def __init__(self, x, y): self.x = x # Grid index X self.y = y # Grid index Y self.life = 100.0 self.age = 0 def update(self, field, grad_x, grad_y, res): # 1. Move based on the Field Gradient (surfs the wave) # We cast indices to int for array access ix, iy = int(self.x), int(self.y) # Physics: Move towards higher energy (or lower, depending on behavior) # Here, thoughts are attracted to High Energy (Creativity) dx = grad_x[iy, ix] * 5.0 + random.uniform(-0.5, 0.5) dy = grad_y[iy, ix] * 5.0 + random.uniform(-0.5, 0.5) self.x = np.clip(self.x + dx, 0, res - 1) self.y = np.clip(self.y + dy, 0, res - 1) # 2. Consume Life based on Entropy # field value at location. If low (void), decay faster. energy = field[iy, ix] if energy < 0.5: self.life -= 5.0 # Die in the void else: self.life -= 0.5 # Slow burn in high energy self.life += energy * 0.2 # Recharge slightly from field self.age += 1 return self.life > 0 class ConsciousnessEngine: def __init__(self): # Configuration self.res = 60 self.physics = NovaPhysics(self.res) self.agents = [] # System State self.time_step = 0 self.alpha = 1.0 # Geometry Parameter self.beta = 1.0 # Momentum Parameter self.stability_history = [] # Plot Setup plt.style.use('dark_background') self.fig = plt.figure(figsize=(12, 8)) self.fig.canvas.manager.set_window_title("RomanAILabs: NOVA Consciousness Engine") # Layout: 2 Rows. Top = Field View, Bottom = System Metrics gs = self.fig.add_gridspec(3, 1) self.ax_field = self.fig.add_subplot(gs[0:2, 0]) self.ax_stats = self.fig.add_subplot(gs[2, 0]) # Visuals colors = [(0,0,0), (0.1, 0, 0.2), (0.5, 0, 0.5), (0, 0.8, 1), (1, 1, 1)] self.cmap = LinearSegmentedColormap.from_list('nova_fire', colors, N=100) # Initial Field Calculation self.field, self.gx, self.gy = self.physics.compute_field(self.alpha, self.beta, 0) self.im = self.ax_field.imshow(self.field, cmap=self.cmap, animated=True, origin='lower', vmin=0, vmax=2.0) # Particles scatter plot self.scat = self.ax_field.scatter([], [], c='white', s=10, alpha=0.8) self.ax_field.set_title(f"NOVA Field Interaction | Alpha: {self.alpha:.2f} | Beta: {self.beta:.2f}") self.ax_field.axis('off') # Stats Line self.line_stability, = self.ax_stats.plot([], [], color='#00ffcc', lw=2) self.ax_stats.set_xlim(0, 100) self.ax_stats.set_ylim(0, 50) self.ax_stats.set_ylabel("Active Thoughts") self.ax_stats.set_xlabel("Cycle Time") self.ax_stats.grid(True, alpha=0.2) # Text Overlay self.text_info = self.ax_field.text(0.02, 0.95, "", transform=self.ax_field.transAxes, color="white", fontsize=10, verticalalignment='top') def run(self): ani = animation.FuncAnimation(self.fig, self.update, interval=50, blit=False) plt.show() def update(self, frame): self.time_step += 0.1 # 1. Update Physics (The NOVA Equation) self.field, self.gx, self.gy = self.physics.compute_field(self.alpha, self.beta, self.time_step) self.im.set_array(self.field) # 2. Manage Thought Agents # Spawn new thoughts if count is low if len(self.agents) < 20: self.agents.append(ThoughtAgent(np.random.randint(0, self.res), np.random.randint(0, self.res))) # Update existing agents alive_agents = [] agent_positions = [] for agent in self.agents: if agent.update(self.field, self.gx, self.gy, self.res): alive_agents.append(agent) agent_positions.append([agent.x, agent.y]) self.agents = alive_agents # Update Scatter Plot if agent_positions: pos_arr = np.array(agent_positions) self.scat.set_offsets(pos_arr) else: self.scat.set_offsets(np.zeros((0, 2))) # 3. SELF-REGULATION (The "Consciousness" Loop) # The system observes the number of living thoughts. # If thoughts are dying (Low Count), it adjusts the Geometry (Alpha) to find a better state. num_thoughts = len(self.agents) self.stability_history.append(num_thoughts) if len(self.stability_history) > 100: self.stability_history.pop(0) # "Panic" Mechanism: If thoughts die too fast, mutate Alpha/Beta rapidly if num_thoughts < 10: self.alpha += 0.05 if self.alpha > 3.0: self.alpha = 0.5 status = "STATUS: UNSTABLE - MUTATING GEOMETRY" color = "#ff0055" # Red elif num_thoughts > 40: # "Stagnation": If too many thoughts survive easily, increase entropy (Beta) self.beta += 0.01 status = "STATUS: STAGNANT - INCREASING ENTROPY" color = "#ffff00" # Yellow else: # "Flow State": Subtle breathing self.alpha += np.sin(self.time_step) * 0.001 status = "STATUS: FLOW STATE - RESONATING" color = "#00ffcc" # Cyan # 4. Update UI Text and Graphs self.ax_field.set_title(f"NOVA Field | α={self.alpha:.2f} | β={self.beta:.2f} | {status}", color=color) self.line_stability.set_data(range(len(self.stability_history)), self.stability_history) return self.im, self.scat, self.line_stability if __name__ == "__main__": print("RomanAILabs: Booting NOVA Consciousness Engine...") print("Initializing 5D Manifold Interactions...") engine = ConsciousnessEngine() engine.run()