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: