import random N = 3 thirst = 0 dark = True just_ate = False while True: if not dark and random.random() < 0.25: print('A wind blows out your light!') dark = True # report game state if thirst >= 2*N: print('You have died of thirst.') print('Sucks to be you.') break elif thirst >= N: print('You are thirsty.') if dark == True: print('It is dark.') cmd = input('? ') if cmd == 'quit': print('Bye!') break elif cmd == 'eat': if just_ate: print('You just ate!') print('You pig.') else: print('Nom nom nom.') just_ate = True continue elif cmd == 'drink': print('Glug glug glug buuuuuuuuuuuuuurp!') thirst = 0 elif cmd == 'pray': print('om') elif cmd == 'love': print('Love me do.') elif cmd == 'look': if dark: print('Did I mention that it was dark?') else: print('You are in a maze of twisty little passages, all alike.') elif cmd == 'lantern': if not dark: print("It's already on... duh!") else: # you better not be ryan reynolds print('You are enlightened.') dark = False else: print("I don't know that command.") # update state at end of game turn just_ate = False thirst = thirst + 1