forked from Maxluli/RustyPropagation
Fixed bug appeared in the last merge
This commit is contained in:
@@ -50,7 +50,6 @@ impl Population{
|
||||
//One solution to this issue would be to have if else else statements but in this case for example 20% would be lower with the last because its 20% on the remaining population and not of the all
|
||||
//In other words I did it that way but it can be changed just its not the right method to have perfect ratios
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let mut i: i32 = 0;
|
||||
for x in self.humans.iter_mut() {
|
||||
if rng.gen_range(0..CORRECTED_PERCENTAGE) < self.start_infected_ratio as i32
|
||||
@@ -77,6 +76,7 @@ impl Population{
|
||||
let mut stats: [i32;4] = [0,0,0,0];
|
||||
// stats[0] Normal stats[1] Infected stats[2] Immune stats[3] Dead
|
||||
|
||||
/*
|
||||
for h in self.humans.iter() {
|
||||
match h.present_state{
|
||||
State::Normal => {stats[0] += 1;}
|
||||
@@ -85,7 +85,21 @@ impl Population{
|
||||
State::Dead => {stats[3] += 1;}
|
||||
}
|
||||
}
|
||||
// for pos in &people_to_check {
|
||||
*/
|
||||
|
||||
for x in 0..self.width{
|
||||
for y in 0..self.height{
|
||||
let idx = human_idx(x as i32, y as i32, self.width as i32);
|
||||
match self.humans[idx].present_state{
|
||||
State::Normal => {stats[0] += 1;}
|
||||
State::Infected => {people_to_check.push(Point{x:x,y:y});stats[1]+=1;}
|
||||
State::Immune => {stats[2] += 1;}
|
||||
State::Dead => {stats[3] += 1;}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//for pos in &people_to_check {
|
||||
for pos in people_to_check.iter() {
|
||||
//people_to_check.iter().map(|pos|{
|
||||
//get all the other people next to me and check if i die cure or infect
|
||||
@@ -169,7 +183,7 @@ impl Population{
|
||||
};
|
||||
for infected_position in &people_to_infect {
|
||||
// println!("To infect: {:?}", infected_position);
|
||||
//people_to_infect.iter().map(|infected_position|{
|
||||
//people_to_infect.iter().map(|infected_position|{
|
||||
let infected_index = human_idx(infected_position.x, infected_position.y, self.width);
|
||||
// let _ = infected_position.x;
|
||||
//DEBUG
|
||||
@@ -194,6 +208,7 @@ impl Population{
|
||||
//DEBUG
|
||||
//println!("Killed someone");
|
||||
};
|
||||
|
||||
stats
|
||||
}
|
||||
pub fn roll(&self,probability:u32)->bool{
|
||||
|
||||
Reference in New Issue
Block a user