Rand Op

AuthorkAworu
Submission date2019-05-09 18:59:04.049663
Rating6068
Matches played216
Win rate57.87

Use rpsrunner.py to play unranked matches on your computer.

Source code:

#!/usr/bin/env python

import random

# keep track of the opponent choice history, pick one of them at random and
# beat it. Play a random choice instead 25% of the time.
if input == "":
    history = []
    output = random.choice(["R", "P", "S"])
else:
    history.append(input)
    x = {"S": "R", "R": "P", "P": "S"}[random.choice(history)]
    y = random.choice(["R", "P", "S"])
    output = x if random.randint(1, 4) > 1 else y