Rock Paper Scissors

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=[]):
    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%

If you meet the requirements, then it looks good. If you consistently get these results then it appears that you have met the requirements. If you want something with more machine learning in it, look through the posts in the forums on this project and there are several different ideas. Google can help too, even though most of the RPS machine learning deals with image recognition of hands playing RPS.

1 Like

Wow, how did you come up with that? Its so simplistic I can’t see how it beats all the models, but yeah, scores high. Great job. I just submitted the project and now browsing to see how it stacks up… my loops of probability-building pattern searches seems silly now, haha, especially seeing as they hardly beat abbey.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.