tick: simplify parameter passing
This commit is contained in:
27
src/grid.rs
27
src/grid.rs
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user