Skip to main content

Substrate

Trait Substrate 

Source
pub trait Substrate {
Show 23 methods // Required methods fn signals_near(&self, position: &Position, radius: f64) -> Vec<&Signal>; fn emit_signal(&mut self, signal: Signal); fn decay_signals(&mut self, rate: f64, removal_threshold: f64); fn add_node(&mut self, data: NodeData) -> NodeId; fn get_node(&self, id: &NodeId) -> Option<&NodeData>; fn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData); fn get_edge(&self, from: &NodeId, to: &NodeId) -> Option<&EdgeData>; fn neighbors(&self, node: &NodeId) -> Vec<(NodeId, &EdgeData)>; fn remove_edge(&mut self, from: &NodeId, to: &NodeId); fn all_nodes(&self) -> Vec<NodeId>; fn all_edges(&self) -> Vec<(NodeId, NodeId, &EdgeData)>; fn node_count(&self) -> usize; fn edge_count(&self) -> usize; fn deposit_trace(&mut self, location: &SubstrateLocation, trace: Trace); fn traces_at(&self, location: &SubstrateLocation) -> Vec<&Trace>; fn decay_traces(&mut self, rate: f64, removal_threshold: f64); fn add_document(&mut self, doc: Document); fn get_document(&self, id: &DocumentId) -> Option<&Document>; fn undigested_documents(&self) -> Vec<&Document>; fn consume_document(&mut self, id: &DocumentId) -> Option<String>; fn all_documents(&self) -> Vec<&Document>; fn current_tick(&self) -> Tick; fn advance_tick(&mut self);
}
Expand description

The shared environment that all agents sense and modify.

The substrate is the computational analog of the extracellular matrix in biology. It holds:

  • A signal field for chemotaxis (agents sense gradients)
  • A knowledge graph for stigmergy (agents deposit and read structure)
  • Trace storage for indirect coordination

Required Methods§

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.

Implementors§