Skip to main content

SubstrateImpl

Struct SubstrateImpl 

Source
pub struct SubstrateImpl { /* private fields */ }
Expand description

In-memory substrate implementation.

The substrate is the extracellular matrix — the shared environment all agents sense and modify. It holds signals (for chemotaxis), a knowledge graph (for stigmergy and Hebbian wiring), and traces (for indirect coordination).

Implementations§

Source§

impl SubstrateImpl

Source

pub fn new() -> Self

Source

pub fn get_document(&self, id: &DocumentId) -> Option<&Document>

Get a document by ID (convenience method bypassing trait).

Source

pub fn all_documents(&self) -> Vec<&Document>

Get all documents (convenience method).

Source

pub fn graph(&self) -> &PetTopologyGraph

Get a reference to the underlying topology graph.

Source

pub fn graph_mut(&mut self) -> &mut PetTopologyGraph

Get a mutable reference to the underlying topology graph.

Source

pub fn all_signals(&self) -> &[Signal]

Get all signals (for diagnostics/visualization).

Source

pub fn total_trace_count(&self) -> usize

Total number of traces across all locations.

Source

pub fn traces_near( &self, position: &Position, radius: f64, trace_type: &TraceType, ) -> Vec<&Trace>

Get all traces of a given type within a radius of a position.

Trait Implementations§

Source§

impl Default for SubstrateImpl

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Substrate for SubstrateImpl

Source§

fn signals_near(&self, position: &Position, radius: f64) -> Vec<&Signal>

Read all signals within a radius of a position.
Source§

fn emit_signal(&mut self, signal: Signal)

Emit a signal into the substrate.
Source§

fn decay_signals(&mut self, rate: f64, removal_threshold: f64)

Decay all signals by a rate (0.0-1.0). Signals below threshold are removed.
Source§

fn add_node(&mut self, data: NodeData) -> NodeId

Add a node to the knowledge graph.
Source§

fn get_node(&self, id: &NodeId) -> Option<&NodeData>

Get a node by ID.
Source§

fn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData)

Add or update an edge between two nodes.
Source§

fn get_edge(&self, from: &NodeId, to: &NodeId) -> Option<&EdgeData>

Get edge data between two nodes.
Source§

fn neighbors(&self, node: &NodeId) -> Vec<(NodeId, &EdgeData)>

Get all neighbors of a node with their edge data.
Source§

fn remove_edge(&mut self, from: &NodeId, to: &NodeId)

Remove an edge.
Source§

fn all_nodes(&self) -> Vec<NodeId>

Get all node IDs.
Source§

fn all_edges(&self) -> Vec<(NodeId, NodeId, &EdgeData)>

Get all edges as (from, to, data) triples.
Source§

fn node_count(&self) -> usize

Number of nodes in the graph.
Source§

fn edge_count(&self) -> usize

Number of edges in the graph.
Source§

fn deposit_trace(&mut self, location: &SubstrateLocation, trace: Trace)

Deposit a trace at a location.
Source§

fn traces_at(&self, location: &SubstrateLocation) -> Vec<&Trace>

Read traces at a location.
Source§

fn decay_traces(&mut self, rate: f64, removal_threshold: f64)

Decay all traces by a rate. Traces below threshold are removed.
Source§

fn add_document(&mut self, doc: Document)

Place a document in the substrate.
Source§

fn get_document(&self, id: &DocumentId) -> Option<&Document>

Get a document by ID.
Source§

fn undigested_documents(&self) -> Vec<&Document>

Get all undigested documents.
Source§

fn consume_document(&mut self, id: &DocumentId) -> Option<String>

Mark a document as digested and return its content.
Source§

fn all_documents(&self) -> Vec<&Document>

Get all documents.
Source§

fn current_tick(&self) -> Tick

Current simulation tick.
Source§

fn advance_tick(&mut self)

Advance the tick counter.

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.