Created
August 5, 2021 00:13
-
-
Save dakerfp/f90e8edd77f1fc68a0b808c23374d1ef to your computer and use it in GitHub Desktop.
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
from enum import Enum | |
from random import randint | |
class Weather(Enum): | |
CLEAR = auto() | |
CLOUDY = auto() | |
RAINY = auto() | |
def next(self): | |
d6 = randint(1,6) | |
if self.value is Weather.CLEAR: | |
if d6 == 6: | |
return Weather.CLOUDY | |
else: | |
return Weather.CLEAR | |
if self.value is Weather.CLOUDY: | |
if d6 <= 2: | |
return Weather.CLEAR | |
else if d6 >= 5: | |
return Weather.RAINY | |
else: | |
return Weather.CLOUDY | |
if self.value is Weather.RAINY: | |
if d6 <= 2 or d6 >= 5: | |
return Weather.RAINY | |
else: | |
return Weather.CLOUDY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment