This commit is contained in:
Simon Gardling
2021-04-01 13:02:37 -04:00
parent 930432aefe
commit d09c8e9c9a
4 changed files with 32 additions and 26 deletions

View File

@@ -161,9 +161,22 @@ impl Grid {
#[inline]
pub fn tick(&mut self) {
let self_immutable = self.clone();
let (width, height) = (self.width, self.height);
let PopulationConfig {
sensor_distance,
sensor_angle,
rotation_angle,
step_distance,
..
} = self.config;
let self_imut = self.clone(); // Create immutable copy of self before ticking agents (this is a very bad solution, needs to be improved)
self.agents.par_iter_mut().for_each(|agent| {
agent.tick(&self_immutable);
agent.tick(&self_imut,
sensor_distance, sensor_angle,
rotation_angle, step_distance,
width, height);
});
}