Author | vladh |
Submission date | 2011-05-25 22:28:31.852285 |
Rating | 3250 |
Matches played | 7215 |
Win rate | 30.03 |
Use rpsrunner.py to play unranked matches on your computer.
# remembers moved and beats the most frequent
# -vladh
import random;
def beat(move):
if move=="R": return "P";
if move=="P": return "S";
if move=="S": return "R";
return None;
def numToMove(num):
if num==0: return "R";
if num==1: return "P";
if num==2: return "S";
return None;
if input=="":
history="";
else:
history+=input;
f=[0,0,0];
for i in history:
if i=="R": f[0]+=1;
if i=="P": f[1]+=1;
if i=="S": f[2]+=1;
output=beat(numToMove(f.index(max(f))));