Machine Learning with Python Projects - Rock Paper Scissors

My only problem with this challenge is : Are my all guess returns same for all 4 different opponents ? I want to check the pattern of my opponents moves in our player function. But it only returns the guesses for the first if statement(for the first opponent) even for the other opponents. Please don’t write direct codes I really want to solve this without any big help

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15

Challenge: Machine Learning with Python Projects - Rock Paper Scissors

Link to the challenge:

I’m not sure what you’re asking, but I’ve got answers anyway. You can use different strategies for each opponent if you like. You have access to both the current play and the opponent history in the arguments to each player function, so you should be able to analyze or output that history however you like.

Look at the player code for mrugesh or abbey in RPS_game.py for more details.

Sir my problem is let’s say that I have created an if block for abbey and quincy depending on the pattern. If my function recognizes abbey first and returns guesses for abbey are they also guess for quincy ? When I test this code with verbose true I saw that returns are same for the opponents but my goal is to differ them depending on their pattern.
if opponent_history[:6] == [“”, “R”, “P”, “P”, “S”, “R”]:
choices = [“P”, “S”, “S”, “R”, “P”]
guess = choices[counter[0] % len(choices)]
counter[0] += 1
return guess

#mrugesh
elif opponent_history[-10:] == ["", "R", "R", "R", "R", "R", "R", "R", "R", "R"]:
  if len(my_history) > 9:
    last_ten = my_history[-10:]
    least_frequent = min(set(last_ten), key=last_ten.count)
    if least_frequent == '':
      least_frequent = "P"

    guess = least_frequent
    my_history.append(guess)
    return guess
  else:
    guess = "P"
    my_history.append(guess)
    return guess

There’s many ways to change your response based on the player. You can do a pattern analysis and try to determine a player. You can see if the players always play in the same order. You can use “other means” to determine the player. Or, you can create a strategy that beats all the players.

The difficulty with pattern analysis will be that the players may provide different responses depending on your history of plays, so you can’t use a static array of their responses to match them. You would have to analyze the responses to find the pattern.

Thank you very much and lastly are the players share the same response history from me ?

Two of the players record your play history to predict your next play. So they will attempt to adapt to your plays as you attempt to adapt to them.