Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simple Rock Paper Scissor Game
- # First player to five wins
- # Player selects his and the computer selection is random
- import random
- hand_list = ('Rock','Paper','Scissors')
- win_list = [['Rock', 'Scissors'], ['Paper', 'Rock'], ['Scissors', 'Paper']]
- def play_game():
- count = 0
- p_wins = 0
- c_wins = 0
- while p_wins < 4 or c_wins < 4:
- # Player Selection
- p = input("\nWhat is your selection? \n 1:Rock \n 2:Paper \n 3:Scissors")
- p = int(p)- 1
- while p < 0 or p > 2:
- print("Try Again")
- p = input("\n What is your selection? \n 1:Rock \n 2:Paper \n 3:Scissors")
- p = int(p)- 1
- p_selection = hand_list[p]
- # Computer Selection
- i = random.randint(0,2)
- c_selection = hand_list[i]
- # Display Results
- print("Player chooses: {} \nComputer chooses: {}".format(p_selection,c_selection))
- played = [p_selection, c_selection]
- if p_selection == c_selection:
- print("\nTie Match")
- print("Player:{} Computer: {}".format(p_wins,c_wins))
- elif played in win_list:
- print ("\nPlayer wins this game")
- c_wins
- p_wins +=1
- print("Player:{} Computer: {}".format(p_wins,c_wins))
- else:
- print("\nComputer wins this game ")
- p_wins
- c_wins += 1
- print("Player:{} Computer: {}".format(p_wins,c_wins))
- if p_wins > 4:
- print("Player Wins!{} to {}".format(p_wins,c_wins))
- break
- if c_wins >4:
- print("Computer Wins! Better Luck next time")
- break
- print("Welcome to Rock Paper Scissor!")
- print("First One to Five Wins!")
- play_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement