I'm stuck in Rock Paper Scissor Project and it's frustrating

Tell us what’s happening:
no matter how hard i try different approaches to beat all the bots, I’m not reaching above 60% benchmark. I tried to look upto 11 previous opponent play but still no success. btw my code is like abbey’s but can see more history.

Your code so far
def player(prev_play, opponent_history=):
rps = ‘RPS’
potential_plays =
play_order={}

if prev_play == '':
    prev_play = 'P'
opponent_history.append(prev_play)

for l1 in rps:
    for l2 in rps:
        for l3 in rps:
            for l4 in rps:
                for l5 in rps:
                    for l6 in rps:
                        for l7 in rps:
                            potential_plays.append(prev_play+l1+l2+l3+l4+l5+l6+l7)
                            for l8 in rps:
                                play_order[l1+l2+l3+l4+l5+l6+l7+l8] = 0
                    
play_order = [play_order]

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

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'}
guess = ideal_response[prediction]

return guess

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0.

Challenge: Rock Paper Scissors

Link to the challenge:

The only variable that is keeps its value between calls to player() is the opponent_history, which means your play_order is all zeroes every time. You’ll need to reconstruct your play_order from the opponent_history every time player() is called.

Also, there’s a pretty steep diminishing returns curve with adding more history. Abbey is a Markov chain player of length 2 which means the right length 2 or a length 3 chain can beat her. Correctly implemented, this algorithm increases in complexity rapidly.

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