Skip to main content

SubstrateEngine

Struct SubstrateEngine 

Source
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

Source

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).

Source

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].

Source

pub fn phases(&self) -> Vec<f32>

Read all Kuramoto phases as a flat f32 array.

Source

pub fn witness_array(&self) -> [f32; 4]

Current witness as [R, entropy, converged, step].

Source

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.

Source

pub fn set_phase(&mut self, index: usize, theta: f32, omega: f32) -> bool

Set Kuramoto phase and natural frequency for atom at index.

Source

pub fn set_expert( &mut self, index: usize, intent: f32, activation: f32, gate: f32, ) -> bool

Set expert projection (intent routing) for atom at index.

Source

pub fn set_neighbor( &mut self, index: usize, slot: usize, neighbor_index: u16, ) -> bool

Set graph neighbor at a slot for atom at index.

Source

pub fn atom_count(&self) -> usize

Number of atoms.

Source

pub fn step_count(&self) -> u32

Current step number.

Source

pub fn stride(&self) -> usize

Stride in bytes per atom.

Source

pub fn converged(&self) -> bool

Whether the substrate has converged (R >= 0.9).

Source

pub fn order_parameter(&self) -> f32

Current order parameter R.

Source

pub fn embeddings_flat(&self) -> Vec<f32>

All embeddings as a flat f32 array (n * 384 elements).

Source

pub fn extract_sematon(&self, source: &str) -> String

Extract a sematon from the current substrate state. Payload = centroid embedding. Returns JSON string of FoldedSematon.

Source

pub fn atom_shape_hash(&self, index: usize) -> Option<u32>

Read the shape hash for atom at index.

Source

pub fn set_coupling_params(&mut self, k_base: f32, gravity_scale: f32)

Update coupling parameters (k_base, gravity_scale).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.