rock-paper-scissors/RPS.py

11 lines
399 B
Python
Raw Normal View History

2020-09-29 16:48:01 +02:00
# The example function below keeps track of the opponent's history and plays whatever the opponent played two plays ago. It is not a very good player so you will need to change the code to pass the challenge.
def player(prev_play, opponent_history=[]):
opponent_history.append(prev_play)
guess = "R"
if len(opponent_history) > 2:
guess = opponent_history[-2]
return guess