I made it! I don’t think it was a fair win, but I did it!
I cleaned both play_order
2 times.
One thing I thought about today was to print the results after every 100 games, to see where I wasn’t winning.
I don’t know if it was fair. I mean, supposedly, it shouldn’t be like that. But I don’t know. I cheated? Maybe, after a while, I try to do that again, without cheating.
Thanks for everything @jeremy.a.gray!!
opponent_history=["R"]
play_order=[{
"RRR": 0, "RRP": 0, "RRS": 0,
"RPR": 0, "RPP": 0, "RPS": 0,
"RSR": 0, "RSP": 0, "RSS": 0,
"PRR": 0, "PRP": 0, "PRS": 0,
"PPR": 0, "PPP": 0, "PPS": 0,
"PSR": 0, "PSP": 0, "PSS": 0,
"SRR": 0, "SRP": 0, "SRS": 0,
"SPR": 0, "SPP": 0, "SPS": 0,
"SSR": 0, "SSP": 0, "SSS": 0
}]
play_order2=[{
"RR": 0, "RP": 0, "RS": 0,
"PR": 0, "PP": 0, "PS": 0,
"SR": 0, "SP": 0, "SS": 0,
}]
n = 0
def player(prev_play):
global opponent_history
global play_order
global play_order2
global n
n += 1
if not prev_play:
prev_play = "R"
opponent_history=["R"]
play_order=[{
"RRR": 0, "RRP": 0, "RRS": 0,
"RPR": 0, "RPP": 0, "RPS": 0,
"RSR": 0, "RSP": 0, "RSS": 0,
"PRR": 0, "PRP": 0, "PRS": 0,
"PPR": 0, "PPP": 0, "PPS": 0,
"PSR": 0, "PSP": 0, "PSS": 0,
"SRR": 0, "SRP": 0, "SRS": 0,
"SPR": 0, "SPP": 0, "SPS": 0,
"SSR": 0, "SSP": 0, "SSS": 0
}]
play_order2=[{
"RR": 0, "RP": 0, "RS": 0,
"PR": 0, "PP": 0, "PS": 0,
"SR": 0, "SP": 0, "SS": 0,
}]
if n == 401:
play_order=[{
"RRR": 0, "RRP": 0, "RRS": 0,
"RPR": 0, "RPP": 0, "RPS": 0,
"RSR": 0, "RSP": 0, "RSS": 0,
"PRR": 0, "PRP": 0, "PRS": 0,
"PPR": 0, "PPP": 0, "PPS": 0,
"PSR": 0, "PSP": 0, "PSS": 0,
"SRR": 0, "SRP": 0, "SRS": 0,
"SPR": 0, "SPP": 0, "SPS": 0,
"SSR": 0, "SSP": 0, "SSS": 0
}]
play_order2=[{
"RR": 0, "RP": 0, "RS": 0,
"PR": 0, "PP": 0, "PS": 0,
"SR": 0, "SP": 0, "SS": 0,
}]
if n == 802:
play_order=[{
"RRR": 0, "RRP": 0, "RRS": 0,
"RPR": 0, "RPP": 0, "RPS": 0,
"RSR": 0, "RSP": 0, "RSS": 0,
"PRR": 0, "PRP": 0, "PRS": 0,
"PPR": 0, "PPP": 0, "PPS": 0,
"PSR": 0, "PSP": 0, "PSS": 0,
"SRR": 0, "SRP": 0, "SRS": 0,
"SPR": 0, "SPP": 0, "SPS": 0,
"SSR": 0, "SSP": 0, "SSS": 0
}]
play_order2=[{
"RR": 0, "RP": 0, "RS": 0,
"PR": 0, "PP": 0, "PS": 0,
"SR": 0, "SP": 0, "SS": 0,
}]
opponent_history.append(prev_play)
last_two = "".join(opponent_history[-2:])
last_three = "".join(opponent_history[-3:])
if len(last_two) == 2:
play_order2[0][last_two] += 1
if len(last_three) == 3:
play_order[0][last_three] += 1
potential_plays = [
prev_play + "P",
prev_play + "R",
prev_play + "S",
last_two + "P",
last_two + "R",
last_two + "S"
]
sub_order = {
k: play_order[0][k]
for k in potential_plays if k in play_order[0]
}
sub_order2 = {
l: play_order2[0][l]
for l in potential_plays if l in play_order2[0]
}
dsa = []
zyx = {}
for key,value in sub_order.items():
dsa.append(value)
zyx[value] = key
ideal_response = {'P': 'S', 'R': 'P', 'S': 'R'}
if sub_order[zyx[max(dsa)]] > 60:
prediction = max(sub_order, key=sub_order.get)[-1:]
elif sub_order[zyx[max(dsa)]] > 58:
prediction = min(sub_order, key=sub_order.get)[-1:]
elif sub_order[zyx[max(dsa)]] > 55:
prediction = max(sub_order, key=sub_order.get)[-1:]
elif sub_order[zyx[max(dsa)]] > 53:
prediction = min(sub_order, key=sub_order.get)[-1:]
elif sub_order[zyx[max(dsa)]] > 5:
prediction = max(sub_order, key=sub_order.get)[-1:]
else:
prediction = max(sub_order2, key=sub_order2.get)[-1:]
return ideal_response[prediction]