Author | Dihn |
Submission date | 2017-12-08 18:03:05.752750 |
Rating | 5284 |
Matches played | 321 |
Win rate | 48.6 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
moves=""
def count_substring(str, sub):
if len(str) == 0:
return 0
if str[0:len(sub)] == (sub):
return 1 + count_substring(str[1:], sub)
else:
return 0 + count_substring(str[1:], sub)
rockcount=0
papercount=0
scissorscount=0
last_2= moves[-2:]
last_3= moves[-3:]
last_4= moves[-4:]
if rockcount > papercount and rockcount > scissorscount:
output = "P"
elif papercount > scissorscount and papercount > rockcount:
output = "S"
elif scissorscount > papercount and scissorscount > rockcount:
ouput = "R"
else:
output = random.choice(["R", "P", "S"])
moves = moves + input