Author | ding |
Submission date | 2017-12-14 06:21:59.381090 |
Rating | 4954 |
Matches played | 317 |
Win rate | 48.9 |
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:]
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"])
rockcount=0
papercount=0
scissorscount=0
last_3= moves[-3:]
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"])
rockcount=0
papercount=0
scissorscount=0
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