get_connected
Graph TraversalbothReturns the agents connected to the given agent via a relationship type. Walks the link in either direction, so the same call works whether your agent is the source or the target. The 3-argument form adds a negative offset, returning what those agents looked like one or more timesteps ago — used for modeling delivery delays, propagation lags, or any time-shifted observation. The 3-argument form is currently available in property formulas only; in act methods, use the 2-argument form and read history through agent.get_prop on individual members.
Signature
get_connected(agent, rel_type) -> array get_connected(agent, rel_type, offset) -> array (formula only)
Example
// Direct neighbors
let teammates = get_connected(agent, "belongs_to");
// Filter the result
let engineers = teammates.filter(|a| a.get_prop("role") == "Engineer");
// What the connected factories shipped one tick ago
let last_tick = get_connected(agent, "supplied_by", -1);
sum_prop(last_tick, "shipped")