diff --git a/main b/main index 108298b..b679ada 100755 Binary files a/main and b/main differ diff --git a/main.cpp b/main.cpp index efe6ff6..b00fc35 100644 --- a/main.cpp +++ b/main.cpp @@ -12,13 +12,16 @@ const int infection_chance = 50; // 50% de chance de se faire infecté si non tué par l'attaque const int death_chance = 20; // 20% de chance de mourir de l'attaque -void attack(int humans, int zombies, int *new_humans, int *new_zombies) { +void attack(int *humans, int *zombies) { if (rand() % 100 < death_chance) { - *new_humans = humans - 1; - *new_zombies = zombies; + *humans = *humans - 1; + *zombies = *zombies; } else if (rand() % 100 < infection_chance) { - *new_humans = humans - 1; - *new_zombies = zombies + 1; + *humans = *humans - 1; + *zombies = *zombies + 1; + } else { + *humans = *humans; + *zombies = *zombies; } } @@ -29,9 +32,9 @@ void loop(int hour, int humans, int zombies) { std:printf("hour: %d| zombies: %d| humans: %d \n", hour, zombies, humans); - for (int n = 0; n < new_zombies; n++) { + for (int n = 0; n < zombies; n++) { if (rand() % 100 < attack_chance) { - attack(humans, zombies, &new_humans, &new_zombies); + attack(&new_humans, &new_zombies); } }