Author | AntiDog |
Submission date | 2018-08-08 13:07:29.893950 |
Rating | 5126 |
Matches played | 269 |
Win rate | 51.3 |
Use rpsrunner.py to play unranked matches on your computer.
import random
#pick_by_winrate
output = ""
if input == "":
output = "P"
oponentmoves = ""
lastIn = "P"
wins = {}
else:
def beats(x,y):
if x == "R":
if y == "S": return True
if x == "P":
if y == "R": return True
if x == "S":
if y == "P": return True
return False
if lastOut != "" and lastIn != "":
if beats(lastOut, lastIn):
id = ""+lastIn+lastOut
if id in wins:
wins[id] += 1
else:
wins[id] = 1
r = 0
p = 0
s = 0
best_wr = 0
best = random.choice(["R","P","S"])
for w in wins:
if len(w) < 2:
continue
if w[0] == input and wins[w] > best_wr:
best_wr = wins[w]
best = w[1]
if r > p and r > s and r >0:
output = "P"
elif p > s and p > r and p >0:
output = "S"
elif s > p and s > r and s >0:
output = "R"
if output == "":
output = random.choice(["R","P","S"])
lastIn = input
lastOut = output