From 47e09571fc9a025fa2f1f19fa7c38a2358ae76a8 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 28 Mar 2025 17:41:24 -0400 Subject: [PATCH] collect grids instead --- src/model.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/model.rs b/src/model.rs index 746edb4..204c306 100644 --- a/src/model.rs +++ b/src/model.rs @@ -75,13 +75,14 @@ impl Model { } } - let mut grids: Vec = 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,