Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. """This program plays a game of Rock, Paper, Scissors between two Players,
  2. and reports both Player's scores each round."""
  3.  
  4. moves = ['rock', 'paper', 'scissors']
  5.  
  6. """The Player class is the parent class for all of the Players
  7. in this game"""
  8.  
  9.  
  10. class Player:
  11.     def move(self):
  12.         return 'rock'
  13.  
  14.     def learn(self, my_move, their_move):
  15.         pass
  16.  
  17.  
  18. def beats(one, two):
  19.     return ((one == 'rock' and two == 'scissors') or
  20.             (one == 'scissors' and two == 'paper') or
  21.             (one == 'paper' and two == 'rock'))
  22.  
  23.  
  24. class Game:
  25.     def init(self, p1, p2):
  26.         self.p1 = p1
  27.         self.p2 = p2
  28.  
  29.     def play_round(self):
  30.         move1 = self.p1.move()
  31.         move2 = self.p2.move()
  32.         print(f"Player 1: {move1}  Player 2: {move2}")
  33.         self.p1.learn(move1, move2)
  34.         self.p2.learn(move2, move1)
  35.  
  36.     def play_game(self):
  37.         print("Game start!")
  38.         for round in range(3):
  39.             print(f"Round {round}:")
  40.             self.play_round()
  41.         print("Game over!")
  42.  
  43.  
  44. if name == 'main':
  45.     game = Game(Player(), Player())
  46.     game.play_game()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement