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) -> u64;
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§
Sourcefn signals_near(&self, position: &Position, radius: f64) -> Vec<&Signal>
fn signals_near(&self, position: &Position, radius: f64) -> Vec<&Signal>
Read all signals within a radius of a position.
Sourcefn emit_signal(&mut self, signal: Signal)
fn emit_signal(&mut self, signal: Signal)
Emit a signal into the substrate.
Sourcefn decay_signals(&mut self, rate: f64, removal_threshold: f64)
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.
Sourcefn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData)
fn set_edge(&mut self, from: NodeId, to: NodeId, data: EdgeData)
Add or update an edge between two nodes.
Sourcefn get_edge(&self, from: &NodeId, to: &NodeId) -> Option<&EdgeData>
fn get_edge(&self, from: &NodeId, to: &NodeId) -> Option<&EdgeData>
Get edge data between two nodes.
Sourcefn neighbors(&self, node: &NodeId) -> Vec<(NodeId, &EdgeData)>
fn neighbors(&self, node: &NodeId) -> Vec<(NodeId, &EdgeData)>
Get all neighbors of a node with their edge data.
Sourcefn remove_edge(&mut self, from: &NodeId, to: &NodeId)
fn remove_edge(&mut self, from: &NodeId, to: &NodeId)
Remove an edge.
Sourcefn all_edges(&self) -> Vec<(NodeId, NodeId, &EdgeData)>
fn all_edges(&self) -> Vec<(NodeId, NodeId, &EdgeData)>
Get all edges as (from, to, data) triples.
Sourcefn node_count(&self) -> usize
fn node_count(&self) -> usize
Number of nodes in the graph.
Sourcefn edge_count(&self) -> usize
fn edge_count(&self) -> usize
Number of edges in the graph.
Sourcefn deposit_trace(&mut self, location: &SubstrateLocation, trace: Trace)
fn deposit_trace(&mut self, location: &SubstrateLocation, trace: Trace)
Deposit a trace at a location.
Sourcefn traces_at(&self, location: &SubstrateLocation) -> Vec<&Trace>
fn traces_at(&self, location: &SubstrateLocation) -> Vec<&Trace>
Read traces at a location.
Sourcefn decay_traces(&mut self, rate: f64, removal_threshold: f64)
fn decay_traces(&mut self, rate: f64, removal_threshold: f64)
Decay all traces by a rate. Traces below threshold are removed.
Sourcefn add_document(&mut self, doc: Document)
fn add_document(&mut self, doc: Document)
Place a document in the substrate.
Sourcefn get_document(&self, id: &DocumentId) -> Option<&Document>
fn get_document(&self, id: &DocumentId) -> Option<&Document>
Get a document by ID.
Sourcefn undigested_documents(&self) -> Vec<&Document>
fn undigested_documents(&self) -> Vec<&Document>
Get all undigested documents.
Sourcefn consume_document(&mut self, id: &DocumentId) -> Option<String>
fn consume_document(&mut self, id: &DocumentId) -> Option<String>
Mark a document as digested and return its content.
Sourcefn all_documents(&self) -> Vec<&Document>
fn all_documents(&self) -> Vec<&Document>
Get all documents.
Sourcefn current_tick(&self) -> u64
fn current_tick(&self) -> u64
Current simulation tick.
Sourcefn advance_tick(&mut self)
fn advance_tick(&mut self)
Advance the tick counter.