BIG rewrite and changes (too many to list)

This commit is contained in:
Simon Gardling
2021-04-01 11:24:29 -04:00
parent dc2e46c51b
commit 4864ccae75
6 changed files with 42 additions and 30 deletions

View File

@@ -118,23 +118,16 @@ impl Model {
// Combine grids
let grids = &mut self.grids;
combine(grids, &self.attraction_table);
let grids_immutable_1 = &grids.clone();
let agents_tick_time = Instant::now();
// Tick agents
for grid in grids.iter_mut() {
grid.agents.par_iter_mut().for_each(|agent| {
agent.tick(&grids_immutable_1[agent.population_id]);
});
grid.tick();
}
// Deposit
let grids_immutable_2 = &grids.clone();
for grid in grids_immutable_2.iter() {
for agent in grid.agents.iter() {
self.grids[agent.population_id].deposit(agent.x, agent.y);
}
for grid in self.grids.iter_mut() {
grid.deposit_all();
}
// Diffuse + Decay