pub struct SubstrateEngine { /* private fields */ }Expand description
The substrate engine: N atoms, a layout, and physics parameters. Single-owner — WASM is single-threaded so this is safe as a JS-side object.
Implementations§
Source§impl SubstrateEngine
impl SubstrateEngine
Sourcepub fn new(n: usize, full_layout: bool, k_base: f32, gravity_scale: f32) -> Self
pub fn new(n: usize, full_layout: bool, k_base: f32, gravity_scale: f32) -> Self
Create a new substrate with n atoms.
full_layout: true = all 4 projections (1592 bytes/atom),
false = minimal Splat+Kuramoto (1548 bytes/atom).
Sourcepub fn tick(
&mut self,
bass: f32,
mid: f32,
high: f32,
entropy: f32,
dt: f32,
) -> [f32; 4]
pub fn tick( &mut self, bass: f32, mid: f32, high: f32, entropy: f32, dt: f32, ) -> [f32; 4]
Run one physics step. Returns [R, entropy, converged (0.0/1.0), step].
Sourcepub fn witness_array(&self) -> [f32; 4]
pub fn witness_array(&self) -> [f32; 4]
Current witness as [R, entropy, converged, step].
Sourcepub fn set_embedding(&mut self, index: usize, embedding: &[f32]) -> bool
pub fn set_embedding(&mut self, index: usize, embedding: &[f32]) -> bool
Set the 384-dim embedding for atom at index.
Returns false if index out of bounds or embedding wrong length.
Sourcepub fn set_phase(&mut self, index: usize, theta: f32, omega: f32) -> bool
pub fn set_phase(&mut self, index: usize, theta: f32, omega: f32) -> bool
Set Kuramoto phase and natural frequency for atom at index.
Sourcepub fn set_expert(
&mut self,
index: usize,
intent: f32,
activation: f32,
gate: f32,
) -> bool
pub fn set_expert( &mut self, index: usize, intent: f32, activation: f32, gate: f32, ) -> bool
Set expert projection (intent routing) for atom at index.
Sourcepub fn set_neighbor(
&mut self,
index: usize,
slot: usize,
neighbor_index: u16,
) -> bool
pub fn set_neighbor( &mut self, index: usize, slot: usize, neighbor_index: u16, ) -> bool
Set graph neighbor at a slot for atom at index.
Sourcepub fn atom_count(&self) -> usize
pub fn atom_count(&self) -> usize
Number of atoms.
Sourcepub fn step_count(&self) -> u32
pub fn step_count(&self) -> u32
Current step number.
Sourcepub fn order_parameter(&self) -> f32
pub fn order_parameter(&self) -> f32
Current order parameter R.
Sourcepub fn embeddings_flat(&self) -> Vec<f32>
pub fn embeddings_flat(&self) -> Vec<f32>
All embeddings as a flat f32 array (n * 384 elements).
Sourcepub fn extract_sematon(&self, source: &str) -> String
pub fn extract_sematon(&self, source: &str) -> String
Extract a sematon from the current substrate state. Payload = centroid embedding. Returns JSON string of FoldedSematon.
Sourcepub fn atom_shape_hash(&self, index: usize) -> Option<u32>
pub fn atom_shape_hash(&self, index: usize) -> Option<u32>
Read the shape hash for atom at index.
Sourcepub fn set_coupling_params(&mut self, k_base: f32, gravity_scale: f32)
pub fn set_coupling_params(&mut self, k_base: f32, gravity_scale: f32)
Update coupling parameters (k_base, gravity_scale).