collect grids instead

This commit is contained in:
2025-03-28 17:41:24 -04:00
parent 16887c9712
commit 47e09571fc

View File

@@ -75,13 +75,14 @@ impl Model {
}
}
let mut grids: Vec<Grid> = Vec::new();
for _ in 0..n_populations {
let agents = (0..particles_per_grid)
.map(|_| Agent::new(width, height, &mut rng))
.collect();
grids.push(Grid::new(width, height, &mut rng, agents));
}
let grids = (0..n_populations)
.map(|_| {
let agents = (0..particles_per_grid)
.map(|_| Agent::new(width, height, &mut rng))
.collect();
Grid::new(width, height, &mut rng, agents)
})
.collect();
Model {
population_grids: grids,