Author | evolvingstuff |
Submission date | 2011-06-10 22:25:27.878955 |
Rating | 5333 |
Matches played | 5246 |
Win rate | 52.23 |
Use rpsrunner.py to play unranked matches on your computer.
import random
if input == "":
count_in = [1.0, 1.0, 1.0]
count_out = [1.0, 1.0, 1.0]
else:
for i in range(3):
count_in[i] *= 0.92
count_out[i] *= 0.92
if input == "R":
count_in[0] += 1
elif input == "P":
count_in[1] += 1
elif input == "S":
count_in[2] += 1
s1 = sum(count_in)
s2 = sum(count_out)
p1 = [count_in[0]/s1, count_in[1]/s1, count_in[2]/s1]
p2 = [count_out[0]/s2, count_out[1]/s2, count_out[2]/s2]
p3 = [p1[0]*(1-p2[0]), p1[1]*(1-p2[1]), p1[2]*(1-p2[2])]
if random.random() < p3[0] / sum(p3):
output = "P"
count_out[1] += 1
elif random.random() < p3[1] / sum(p3[1:]):
output = "S"
count_out[2] += 1
else:
output = "R"
count_out[0] += 1