check only normal people

This commit is contained in:
2022-05-03 23:17:45 +02:00
parent fb6e9e82b3
commit 3a41670fea
+4 -3
View File
@@ -108,6 +108,8 @@ impl Population {
pub fn propagate(&mut self) -> [i32; 4] {
let mut people_to_check: Vec<Point> =
Vec::with_capacity((self.width * self.height) as usize);
let mut possible_infected: Vec<Point> =
Vec::with_capacity((self.width * self.height) as usize);
let mut people_to_infect: Vec<Point> =
Vec::with_capacity((self.width * self.height) as usize);
let mut people_to_cure: Vec<Point> =
@@ -120,6 +122,7 @@ impl Population {
for h in self.humans.iter() {
match h.present_state {
State::Normal => {
possible_infected.push(Point{ x: h.x, y: h.y});
stats[0] += 1;
}
State::Infected => {
@@ -150,8 +153,7 @@ impl Population {
}
}
}
for pos in self.humans.iter() {
if pos.present_state == State::Normal {
for pos in possible_infected.iter() {
let infected: bool = self.is_inside_and_infected(
Point {
x: pos.x - 1,
@@ -204,7 +206,6 @@ impl Population {
people_to_infect.push(Point { x: pos.x, y: pos.y });
}
}
}
for infected_position in people_to_infect.iter() {
// println!("To infect: {:?}", infected_position);