Advertisement
MacSG

Template Lab9_3

Apr 1st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.59 KB | None | 0 0
  1. import random
  2.  
  3. def getName():
  4.     pass
  5.  
  6. def playGame(str1, str2):
  7.     pass
  8.  
  9. #Main Program
  10.   #Input
  11. player_1 = input("Enter the first’s player name: ")
  12. player_2 = input("Enter the first’s player name: ")
  13.   #Start
  14. print("Start Game")
  15.  
  16. count = 1
  17. player_1_score = 0
  18. player_2_score = 0
  19. mylist = ["Rock", "Paper", "Scissor"]
  20. while True:
  21.  
  22.     #Print Round
  23.     print("  Round %s:"%count)
  24.     #Random Hand
  25.     hand_1 = random.choice(mylist)
  26.     hand_2 = random.choice(mylist)
  27.  
  28.    
  29.     if hand_1 == "Rock":
  30.         if hand_2 == "Scissor":
  31.             player_1_score += 1
  32.         elif hand_2 == "Paper":
  33.             player_2_score += 1
  34.         elif hand_2 == "Rock":
  35.             pass
  36.        
  37.     elif hand_1 == "Scissor":
  38.         if hand_2 == "Paper":
  39.             player_1_score += 1
  40.         elif hand_2 == "Rock":
  41.             player_2_score += 1
  42.         elif hand_2 == "Scissor":
  43.             pass
  44.        
  45.     elif hand_1 == "Paper":
  46.         if hand_2 == "Rock":
  47.             player_1_score += 1
  48.         elif hand_2 == "Scissor":
  49.             player_2_score += 1
  50.         elif hand_2 == "Paper":
  51.             pass
  52.     #Printer
  53.     print("  -- %s -> %s"%(player_1,hand_1))
  54.     print("  -- %s -> %s"%(player_2,hand_2))    
  55.     print("  %s:%s = %d:%d"%(player_1,player_2,player_1_score,player_2_score))
  56.    
  57.     #End Loop
  58.     count += 1
  59.     if count > 5 and (player_1_score >= 3 or player_2_score >= 3):
  60.         break
  61.    
  62. if player_1_score > player_2_score:
  63.     winner = player_1
  64. else:
  65.     winner = player_2
  66. print("  %s is the winner of the game."%winner)
  67. print("End Game")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement