rely on deriving traits instead
This commit is contained in:
30
src/agent.rs
30
src/agent.rs
@@ -6,7 +6,7 @@ use std::f32::consts::TAU;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
// A single Physarum agent. The x and y positions are continuous, hence we use floating point numbers instead of integers.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Agent {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
@@ -17,11 +17,7 @@ pub struct Agent {
|
||||
|
||||
impl Display for Agent {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{{\n(x,y): ({},{})\nangle: {}\npopulation id: {}\ni: {}}}",
|
||||
self.x, self.y, self.angle, self.population_id, self.i,
|
||||
)
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,25 +89,3 @@ impl Agent {
|
||||
self.y = wrap(self.y + step_distance * sin(self.angle), height as f32);
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Agent {
|
||||
fn clone(&self) -> Agent {
|
||||
Agent {
|
||||
x: self.x,
|
||||
y: self.y,
|
||||
angle: self.angle,
|
||||
population_id: self.population_id,
|
||||
i: self.i,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Agent {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.x == other.x
|
||||
&& self.y == other.y
|
||||
&& self.angle == other.angle
|
||||
&& self.population_id == other.population_id
|
||||
&& self.i == other.i
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user