Author | DuMa |
Submission date | 2019-02-05 19:21:25.905227 |
Rating | 2844 |
Matches played | 258 |
Win rate | 27.52 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input=="":
myMoves = []
options = ["R","P","S"]
opMoves = []
pattern = ["P","P","P"]
out=random.choice(options)
myMoves.append(out)
output=out
matches=0
patternNr=0
else:
opMoves.append(input)
if matches<20:
if patternNr>2:
patternNr=0
out=pattern[patternNr]
output=out
myMoves.append(out)
matches+=1
patternNr+=1
else:
Dkeep=0
if matches>20:
for x in range(len(opMoves)-10,len(opMoves)-1):
if myMoves[x]=="P" and opMoves[x]=="S":
Dkeep+=1
elif myMoves[x]=="S" and opMoves[x]=="R":
Dkeep+=1
elif myMoves[x]=="R" and opMoves[x]=="P":
Dkeep+=1
if Dkeep>6:
for y in range(0,2):
pattern[y]=random.choice(options)
matches=0
if patternNr>2:
patternNr=0
out=pattern[patternNr]
output=out
myMoves.append(out)
matches+=1
patternNr+=1