This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed class Health(val infectious: Boolean, val visiblyInfectious: Boolean) { | |
def evolve(implicit randomGenerator: RandomIntGenerator, config: MySimConfig): Option[HealthChange] = | |
this match { | |
case Healthy => | |
if (randomGenerator.randomBelow(101) <= config.transmissibilityPct) | |
Some(new HealthChange(0, Incubatious)) | |
else None | |
case Incubatious => | |
Some(new HealthChange(6, Sick)) | |
case Sick => | |
if (randomGenerator.randomBelow(101) <= config.mortalityPct) | |
Some(new HealthChange(14 - 6, Dead)) | |
else None | |
case Dead => | |
None | |
case Immune => | |
Some(new HealthChange(18 - 16, Healthy)) | |
case Vaccinated => | |
None | |
} | |
} | |
// infected? visibly? | |
object Healthy extends Health(false, false) | |
object Incubatious extends Health(true, false) | |
object Sick extends Health(true, true) | |
object Dead extends Health(true, true) | |
object Immune extends Health(true, false) | |
object Vaccinated extends Health(false, false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment