Advertisement
DrunkenToad

Untitled

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