So the thing is, I don’t know how to make this one with several strategies, and while the code satisfies the requirements, it doesn’t feel like that was the objective of the project so I would appreciate any advice
here is my code.
def player(prev_play, opponent_history=[]):
opponent_history.append(prev_play)
guess = 'R'
if len(opponent_history) > 5:
guess = opponent_history[-3]
if opponent_history[-3] ==opponent_history[-1]:
if opponent_history[-1]== 'R':guess='P'
elif opponent_history[-1]== 'S':guess='R'
elif opponent_history[-1]== 'P':guess='S'
if opponent_history[-6:-3] ==opponent_history[-3:]:
if opponent_history[-1]== 'R':guess='S'
elif opponent_history[-1]== 'S':guess='P'
elif opponent_history[-1]== 'P':guess='R'
return guess
and these are the results
Final results: {'p1': 797, 'p2': 201, 'tie': 2}
Player 1 win rate: 79.85971943887775%
Final results: {'p1': 499, 'p2': 249, 'tie': 251}
Player 1 win rate: 66.71122994652407%
Final results: {'p1': 142, 'p2': 0, 'tie': 857}
Player 1 win rate: 100.0%
Final results: {'p1': 830, 'p2': 4, 'tie': 165}
Player 1 win rate: 99.52038369304557%