rely on deriving traits instead
This commit is contained in:
42
src/grid.rs
42
src/grid.rs
@@ -5,7 +5,7 @@ use rayon::{iter::ParallelIterator, prelude::*};
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
// A population configuration.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct PopulationConfig {
|
||||
pub sensor_distance: f32,
|
||||
pub step_distance: f32,
|
||||
@@ -16,31 +16,9 @@ pub struct PopulationConfig {
|
||||
deposition_amount: f32,
|
||||
}
|
||||
|
||||
impl Clone for PopulationConfig {
|
||||
fn clone(&self) -> PopulationConfig {
|
||||
PopulationConfig {
|
||||
sensor_distance: self.sensor_distance,
|
||||
step_distance: self.step_distance,
|
||||
sensor_angle: self.sensor_angle,
|
||||
rotation_angle: self.rotation_angle,
|
||||
decay_factor: self.decay_factor,
|
||||
deposition_amount: self.deposition_amount,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for PopulationConfig {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{{\nSensor Distance: {},\nStep Distance: {},\nSensor Angle: {},\nRotation Angle: {},\nDecay Factor: {},\nDeposition Amount: {},\n}}",
|
||||
self.sensor_distance,
|
||||
self.step_distance,
|
||||
self.sensor_angle,
|
||||
self.rotation_angle,
|
||||
self.decay_factor,
|
||||
self.deposition_amount
|
||||
)
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +55,7 @@ impl PopulationConfig {
|
||||
}
|
||||
|
||||
// A 2D grid with a scalar value per each grid block. Each grid is occupied by a single population, hence we store the population config inside the grid.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Grid {
|
||||
pub config: PopulationConfig,
|
||||
pub width: usize,
|
||||
@@ -92,20 +70,6 @@ pub struct Grid {
|
||||
pub agents: Vec<Agent>,
|
||||
}
|
||||
|
||||
impl Clone for Grid {
|
||||
fn clone(&self) -> Grid {
|
||||
Grid {
|
||||
config: self.config.clone(),
|
||||
width: self.width,
|
||||
height: self.height,
|
||||
data: self.data.clone(),
|
||||
buf: self.buf.clone(),
|
||||
blur: self.blur.clone(),
|
||||
agents: self.agents.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Grid {
|
||||
// Create a new grid filled with random floats in the [0.0..1.0) range.
|
||||
pub fn new<R: Rng + ?Sized>(
|
||||
|
||||
Reference in New Issue
Block a user