rely on deriving traits instead

This commit is contained in:
2025-03-24 16:42:14 -04:00
parent f1b9f9ad30
commit 735a820799
4 changed files with 11 additions and 102 deletions

View File

@@ -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
}
}