Author | jfp |
Submission date | 2011-06-09 22:06:51.634596 |
Rating | 4838 |
Matches played | 5323 |
Win rate | 41.54 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
output = "S"
algo = random.choice(["a", "b", "c"])
if algo == "a":
# Play randomly.
output = random.choice(["S", "R", "P"])
elif algo == "b":
# Play the move that would have won last time.
if input == "R":
output = "P"
elif input == "P":
output = "S"
else:
output = "R"
elif algo == "c":
# Play the same move again.
output = output