Rock paper scissor project from machine learning certification

Hey everyone,
I was doing the rock, papers and scissors project, I was able to beat kris, mrugesh and quincy with above 60% win while I am not able to manage a win for more than 50.20% against abbey. Please suggest if there’s a better way to beat him.

Here is his code.

def abbey(prev_opponent_play,
              "RR": 0,
              "RP": 0,
              "RS": 0,
              "PR": 0,
              "PP": 0,
              "PS": 0,
              "SR": 0,
              "SP": 0,
              "SS": 0,

    if not prev_opponent_play:
        prev_opponent_play = 'R'

    last_two = "".join(opponent_history[-2:])
    if len(last_two) == 2:
        play_order[0][last_two] += 1

    potential_plays = [
        prev_opponent_play + "R",
        prev_opponent_play + "P",
        prev_opponent_play + "S",

    sub_order = {
        k: play_order[0][k]
        for k in potential_plays if k in play_order[0]

    prediction = max(sub_order, key=sub_order.get)[-1:]

    ideal_response = {'P': 'S', 'R': 'P', 'S': 'R'}
    return ideal_response[prediction]

PS:- It is mandatory to have atleast 60% win to pass the project.

1 Like