#![allow(clippy::type_complexity)]
use crate::{agent::Agent, model::Model, types::AgentId};
pub fn collect_step<A, M, AgentRow, ModelRow>(
model: &M,
agent_ids: &[AgentId],
agent_report: Option<&dyn Fn(&A, &M) -> AgentRow>,
model_report: Option<&dyn Fn(&M) -> ModelRow>,
agent_data: &mut Vec<AgentRow>,
model_data: &mut Vec<ModelRow>,
) where
A: Agent,
M: Model<Agent = A>,
{
if let Some(report) = agent_report {
for &id in agent_ids {
if let Some(agent) = model.agent(id) {
agent_data.push(report(&agent, model));
}
}
}
if let Some(report) = model_report {
model_data.push(report(model));
}
}