This program has been disqualified.
Author | Tom M |
Submission date | 2011-12-10 11:32:41.761118 |
Rating | 6547 |
Matches played | 78 |
Win rate | 66.67 |
# weighted output based on previous plays from both opponent and self
# if no decision is reached initially, shorten the lookback string and continue
import random
import re
import math
lookback = 5
style=1
themweight=3
usweight=2
if input == "":
inputstring=""
myprev=""
Rweight = 1
Pweight = 1
Sweight = 1
inputstring = inputstring+input
if len(inputstring) < lookback:
output = random.choice(["R","P","S"])
else:
while True:
Rweight = 1
Pweight = 1
Sweight = 1
if lookback>2:
lookback-=1
last4 = inputstring[-lookback:]
mylast4 = myprev[-lookback:]
pattern = re.compile(last4+".")
rock = pattern.search(inputstring[:-lookback])
mypattern = re.compile(mylast4+".")
myrock = mypattern.search(myprev[:-lookback])
if rock:
for x in pattern.findall(inputstring[:-lookback]):
if x[lookback:]=="R":
Pweight += themweight
if x[lookback:]=="P":
Sweight += themweight
if x[lookback:]=="S":
Rweight += themweight
if myrock:
for y in mypattern.findall(myprev[:-lookback]):
if y[lookback:]=="R":
Sweight += usweight
if y[lookback:]=="P":
Rweight += usweight
if y[lookback:]=="S":
Pweight += usweight
selection = random.choice(["R","P","S"])
z = random.uniform(0,200)
if selection=="R":
if z < math.fabs(random.gauss(0,Rweight)):
output = "R"
break
elif selection=="P":
if z < math.fabs(random.gauss(0,Pweight)):
output = "P"
break
elif selection=="S":
if z < math.fabs(random.gauss(0,Sweight)):
output = "S"
break
myprev = myprev+output