tick: simplify parameter passing

This commit is contained in:
2025-03-28 17:27:53 -04:00
parent ec7cce80b4
commit b8f1e28eed
2 changed files with 24 additions and 43 deletions

View File

@@ -7,10 +7,10 @@ use std::fmt::{Display, Formatter};
/// A population configuration.
#[derive(Debug, Clone, Copy)]
pub struct PopulationConfig {
sensor_distance: f32,
step_distance: f32,
sensor_angle: f32,
rotation_angle: f32,
pub sensor_distance: f32,
pub step_distance: f32,
pub sensor_angle: f32,
pub rotation_angle: f32,
deposition_amount: f32,
}
@@ -90,25 +90,8 @@ impl Grid {
}
pub fn tick(&mut self) {
let (width, height) = (self.width, self.height);
let PopulationConfig {
sensor_distance,
sensor_angle,
rotation_angle,
step_distance,
..
} = self.config;
self.agents.par_iter_mut().for_each(|agent| {
agent.tick(
&self.buf,
sensor_distance,
sensor_angle,
rotation_angle,
step_distance,
width,
height,
);
agent.tick(&self.buf, self.config, self.width, self.height);
});
self.deposit_all();
}