Author | sdfsdf |
Submission date | 2013-03-31 05:26:08.678137 |
Rating | 7075 |
Matches played | 715 |
Win rate | 71.89 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input=="":
model = { 'PP': {'P':0,'R':0,'S':0},
'PR': {'P':0,'R':0,'S':0},
'PS': {'P':0,'R':0,'S':0},
'RP': {'P':0,'R':0,'S':0},
'RR': {'P':0,'R':0,'S':0},
'RS': {'P':0,'R':0,'S':0},
'SP': {'P':0,'R':0,'S':0},
'SR': {'P':0,'R':0,'S':0},
'SS': {'P':0,'R':0,'S':0},}
reply = { 'P':'SP','R':'RP','S':'SR'}
output = random.choice(['R','P','S'])
past = ""
else:
temp = input+output
if past =="":
past=temp
else:
model[past][input]+=1
past=temp
sum = model[temp]['P']+model[temp]['S']+model[temp]['R']
if sum==0:
output = random.choice(['R','P','S'])
else:
str = ('P'*model[temp]['P'])+('R'*model[temp]['R'])+('S'*model[temp]['S'])
expect = random.choice(str)
output = random.choice(reply[expect])
past=temp