Author | DuMa |
Submission date | 2019-02-09 16:44:17.001381 |
Rating | 4970 |
Matches played | 244 |
Win rate | 51.64 |
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
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
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