Skip to content

Instantly share code, notes, and snippets.

@dakerfp
Created August 5, 2021 00:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakerfp/f90e8edd77f1fc68a0b808c23374d1ef to your computer and use it in GitHub Desktop.
Save dakerfp/f90e8edd77f1fc68a0b808c23374d1ef to your computer and use it in GitHub Desktop.
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