feat: able to give file output

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-11-20 00:20:40 +03:00
parent 930223c0eb
commit 2eb0fff95d
4 changed files with 104 additions and 38 deletions

View file

@ -1,3 +1,5 @@
use core::fmt;
use rand::Rng;
#[derive(Debug, Clone)]
@ -55,3 +57,13 @@ impl FoodSource {
food_sources
}
}
impl fmt::Display for FoodSource {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"fitness = {}\ncoordinates = {:#?}\ntry_counter = {}\n",
self.fitness, self.coordinates, self.try_counter
)
}
}