Skip to content

Commit

Permalink
clarify conditionals in growAndDie()
Browse files Browse the repository at this point in the history
  • Loading branch information
troyfrever committed Dec 6, 2024
1 parent c2c7419 commit f67eb9f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/fish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,20 +633,22 @@ bool Fish::growAndDie(Model &model) {
}
this->mass = this->mass + g;

// Sample from bernoulli(m) to check if fish should die from mortality risk,
// and check to make sure fish hasn't reached a critically low mass
// check to make sure fish hasn't reached a critically low mass
constexpr float MASS_MIN = 0.381;
if (unit_rand() > m && this->mass > MASS_MIN) {
this->forkLength = forkLengthFromMass(this->mass);
return true;
}

if (this->mass <= MASS_MIN) {
this->dieStarvation(model);
} else {
return false;
}

// Sample from bernoulli(m) to check if fish should die from mortality risk,
const float mortalityProbability = m;
if (unit_rand() <= mortalityProbability) {
this->dieMortality(model);
return false;
}
return false;

this->forkLength = forkLengthFromMass(this->mass);
return true;
}

void Fish::addHistoryBuffers() {
Expand Down

0 comments on commit f67eb9f

Please sign in to comment.