Author | flug |
Submission date | 2019-06-03 04:24:32.584528 |
Rating | 1961 |
Matches played | 251 |
Win rate | 19.12 |
Use rpsrunner.py to play unranked matches on your computer.
import random
choice1 = random.choice(["1","2","3"])
if input == "":
saveinput = ""
saveoutput = ""
rounds=0
won=0
lost=0
draw=0
choice1 = random.choice(["1","2","3", "4"])
winlist = []
lastChange=0
else:
rounds += 1;
if saveoutput==input:
draw += 1
winlist.append(0)
elif (input == "R" and saveoutput == "S") or (input == "S" and saveoutput == "P") or (input == "P" and saveoutput == "R"):
lost += 1
winlist.append(-1)
else:
won -= 1
winlist.append(1)
recents = 10
minChange = 10
decisionPoint = -1
recentTot = 0
for x in range(recents):
if (rounds-x>0):
recentTot += winlist[rounds-x]
if (recentTot < decisionPoint and rounds - lastChange > minChange):
choice2 = choice1
while choice1 == choice2:
choice2 = random.choice(["1","2","3"])
lastChange=rounds
choice1=choice2
#So this is the failsafe . . . if we're losing too badly we just switch
#to random
semirecents = 40
semiminChange = 40
semidecisionPoint = -5
semirecentTot = 0
for x in range(semirecents):
if (rounds-x>0):
semirecentTot += winlist[rounds-x]
if (semirecentTot < semidecisionPoint):
choice1 = 4
if choice1 == "1":
output = random.choice(["R","R","R","R","R","P","S"])
if choice1 == "2":
output = random.choice(["R","P","P","P","P","P","S"])
if choice1 == "3":
output = random.choice(["R","P","S","S","S","S","S"])
if choice1 == "4":
output = random.choice(["R","P","S"])
saveinput = input
saveoutput = output