Author | DuMa |
Submission date | 2019-02-11 08:23:24.515913 |
Rating | 5142 |
Matches played | 248 |
Win rate | 49.19 |
Use rpsrunner.py to play unranked matches on your computer.
import random
global PSpinner
global NSpinner
global spinner
global single
global out
global opMoves
global firstTen
global rounds
global LAP
global retestTimer
winP = {"R":"P","S":"R","P":"S"}
if input == "":
firstTen = ["R","P","R","S","P","R","P","R","S","P"]
rounds = 0
single = False
spinner = False
PSpinner = False
NSpinner = False
LAP = False
retestTimer = 20
opMoves = []
out = "R"
elif rounds < 10:
opMoves.append(input)
out = firstTen[rounds]
elif PSpinner:
opMoves.append(input)
out = opMoves[opMoves.__len__()-2]
elif NSpinner:
opMoves.append(input)
out = input
elif single:
opMoves.append(input)
out = winP[input]
elif input == opMoves[opMoves.__len__()-1]:
opMoves.append(input)
same = True
for x in (0,8):
if not (input == opMoves[opMoves.__len__()-x-1]):
same = False
if same:
single = True
elif LAP:
R = False
P = False
S = False
i = 0
while (not R or not P or not S) and not i>opMoves.__len__()-1:
i+=1
if opMoves[opMoves.__len__()-i] == "R" and not R:
if (P and S) or i>opMoves.__len__():
out = "P"
R = True
elif opMoves[opMoves.__len__()-i] == "P" and not P:
if (R and S) or i > opMoves.__len__():
out = "S"
P = True
elif opMoves[opMoves.__len__()-i] == "S" and not S:
if (R and S) or i > opMoves.__len__():
out = "R"
S = True
else:
out = random.choice(["R","P","S"])
elif input == opMoves[opMoves.__len__()-6]:
opMoves.append(input)
same = True
for x in (0,5):
if not (opMoves[opMoves.__len__()-x-2] == opMoves[opMoves.__len__()-x-5]):
same = False
if same:
spinner = True
if spinner:
if winP[input]==opMoves[opMoves.__len__()-2]:
NSpinner = True
out = input
else:
PSpinner = True
out = opMoves[opMoves.__len__() - 2]
else:
LAP = True
else:
out = random.choice(["R", "P", "S"])
output = out
rounds+=1
retestTimer-=1
if retestTimer < 1:
retestTimer = 20
single = False
spinner = False
PSpinner = False
NSpinner = False
LAP = False