我正在用Python开发一种石头剪刀,我被卡住了。
我做了一个在(石头,布,剪刀)之间循环的课,我想让计算机知道这是以前的游戏。
例如(第一轮电脑玩摇滚,下一轮玩纸牌)
但我不知道如何调用learn函数来使其工作class Player:
def __init__(self):
self.score = 0
def move(self):
return 'rock'
def learn(self, my_move, their_move):
self.my_move = my_move
self.their_move = their_move
def beats(one, two):
return ((one == 'rock' and two == 'scissors') or
(one == 'scissors' and two == 'paper') or
(one == 'paper' and two == 'rock'))
class Game:
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
def play_round(self):
move1 = input("Pick something!\n")
move2 = self.p2.move()
print(f"Player 1: {