well that didn't work
This commit is contained in:
33
src/model.rs
33
src/model.rs
@@ -130,7 +130,7 @@ impl Model {
|
||||
.map(|i| Agent::new(width, height, i / particles_per_grid, &mut rng, i))
|
||||
.collect(),
|
||||
grids: (0..n_populations)
|
||||
.map(|_| Grid::new(width, height, &mut rng, vec![]))
|
||||
.map(|_| Grid::new(width, height, &mut rng))
|
||||
.collect(),
|
||||
attraction_table,
|
||||
diffusivity,
|
||||
@@ -157,23 +157,6 @@ impl Model {
|
||||
let mut time_per_agent_list: Vec<f64> = Vec::new();
|
||||
let mut time_per_step_list: Vec<f64> = Vec::new();
|
||||
|
||||
|
||||
println!("Doing some population stuff...");
|
||||
let time_1 = Instant::now();
|
||||
let mut i_pop: Vec<Vec<usize>> = Vec::new();
|
||||
for _i in 0..(self.grids.len()) {
|
||||
i_pop.push(vec![]);
|
||||
}
|
||||
for agent in self.agents.iter() {
|
||||
i_pop[agent.population_id].push(agent.i);
|
||||
}
|
||||
|
||||
for i in 0..(self.grids.len()) {
|
||||
self.grids[i].i = i_pop[i].clone();
|
||||
}
|
||||
println!("Took {}ms", time_1.elapsed().as_millis());
|
||||
|
||||
let use_exp_deposit: bool = true;
|
||||
for i in 0..steps {
|
||||
if debug {
|
||||
println!("Starting tick for all agents...")
|
||||
@@ -241,18 +224,8 @@ impl Model {
|
||||
});
|
||||
|
||||
// Deposit
|
||||
if use_exp_deposit {
|
||||
let agent_list = self.agents.clone();
|
||||
self.grids.par_iter_mut().for_each(|grid|{
|
||||
for i in 0..grid.i.len() {
|
||||
let agent = &agent_list[i];
|
||||
grid.deposit(agent.x, agent.y);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for agent in self.agents.iter() {
|
||||
self.grids[agent.population_id].deposit(agent.x, agent.y);
|
||||
}
|
||||
for agent in self.agents.iter() {
|
||||
self.grids[agent.population_id].deposit(agent.x, agent.y);
|
||||
}
|
||||
|
||||
// Diffuse + Decay
|
||||
|
||||
Reference in New Issue
Block a user