"""" Kyle Lin for GWC """ from random import randint choices = ["Rock", "Paper", "Scissors"] wins = 0 loses = 0 turns = 0 bridge = 1 print("Super Mario: Rock-Paper-Scissors Edition") print("") print("Welcome Mario! Princess Peach is stuck in her castle and you must save her before Bowser reaches her. Luckily, you are ahead of Bowser, but on your journey to the castle, before crossing a bridge, you must verse a troll in a round of Rock-Paper-Scissors. If the troll beats you in Rock-Paper-Scissors, you must go back to the previous bridge. In the case of a tie or if you lose at the first bridge, you will remain at that same bridge. The castle is located after bridge 3, however, you can only lose up to 3 rounds of Rock-Paper-Scissors before Bowser catches up to you and captures Princess Peach. Best of luck to you Mario!") def get_troll_hand(): return choices[randint(0, 2)] def get_outcome(mario_hand, troll_hand): if mario_hand == troll_hand: return "Tie" if mario_hand == "Rock": if troll_hand == "Scissors": return "Win" else: return "Lose" if mario_hand == "Scissors": if troll_hand == "Paper": return "Win" else: return "Lose" if mario_hand == "Paper": if troll_hand == "Rock": return "Win" else: return "Lose" while loses < 3 and bridge < 4: print("") print "You are currently at Brdige # ", bridge mario = input("Pick 0) Rock 1) Paper 2) Scissors: ") print mario if mario not in ['0', '1', '2']: print("Invalid choice, please pick again.") else: mario = choices[int(mario)] troll = get_troll_hand() print mario, "vs.", troll outcome = get_outcome(mario, troll) if outcome == "Win": print "Congrats, Mario! You have crossed Bridge #", bridge wins += 1 bridge += 1 elif outcome == "Tie": print "Troll Tie! You will not be crossing Bridge #", bridge, "at this time." else: if bridge == 1: message = "You will be staying at this Bridge." else: bridge -= 1 message = "You will be moving back to Bridge # " + str(bridge) + "." print "Oh no you lost!", message loses += 1 turns += 1 if loses == 3: print("") print("Sorry Mario, Bowser has caught up to you and Princess Peach can no longer be saved.") else: print("") print("Congrats, Mario! You have beat Bowser to the Castle and have saved Princess Peach!") """ Winning Test Case You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 0 Rock vs. Rock Troll Tie! You will not be crossing Bridge # 1 at this time. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 1 Paper vs. Paper Troll Tie! You will not be crossing Bridge # 1 at this time. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 2 Scissors vs. Paper Congrats, Mario! You have crossed Bridge # 1 You are currently at Brdige # 2 Pick 0) Rock 1) Paper 2) Scissors: 1 Paper vs. Scissors Oh no you lost! You will be moving back to Bridge # 1. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 1 Paper vs. Rock Congrats, Mario! You have crossed Bridge # 1 You are currently at Brdige # 2 Pick 0) Rock 1) Paper 2) Scissors: 2 Scissors vs. Paper Congrats, Mario! You have crossed Bridge # 2 You are currently at Brdige # 3 Pick 0) Rock 1) Paper 2) Scissors: 2 Scissors vs. Paper Congrats, Mario! You have crossed Bridge # 3 Congrats, Mario! You have beat Bowser to the Castle and have saved Princess Peach! """ """ Losing Test Case You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 0 Rock vs. Paper Oh no you lost! You will be staying at this Bridge. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 1 Paper vs. Paper Troll Tie! You will not be crossing Bridge # 1 at this time. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 2 Scissors vs. Rock Oh no you lost! You will be staying at this Bridge. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 3 Invalid choice, please pick again. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 1 Paper vs. Paper Troll Tie! You will not be crossing Bridge # 1 at this time. You are currently at Brdige # 1 Pick 0) Rock 1) Paper 2) Scissors: 2 Scissors vs. Rock Oh no you lost! You will be staying at this Bridge. Sorry Mario, Bowser has caught up to you and Princess Peach can no longer be saved. """
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question