Random Tilt 2

Authorflug
Submission date2019-06-02 21:59:55.070823
Rating4941
Matches played231
Win rate48.05

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

Source code:

import random
choice1 = random.choice(["1","2","3"])

if input == "":
   saveinput = ""
   saveoutput = ""
   rounds=0
   won=0
   lost=0
   draw=0
   choice1 = random.choice(["1","2","3", "4"]) 
   winlist = []
   lastChange=0  
else:
    rounds += 1;
   
if saveoutput==input:
   draw += 1
   winlist.append(0)
elif (input == "R" and saveoutput == "S") or (input == "S" and saveoutput == "P") or (input == "P" and saveoutput == "R"): 
   lost += 1
   winlist.append(-1)   
else:
    won += 1
    winlist.append(1)
    
recents = 10
minChange = 8
decisionPoint = 0
recentTot = 0

for x in range(recents):
    if (rounds-x>0):
        recentTot += winlist[rounds-x]
    
if (recentTot < decisionPoint and rounds - lastChange > minChange):
   choice2 = choice1
   while choice1 == choice2:
         choice2 = random.choice(["1","2","3", "4"])
   lastChange=rounds
           
    
        
       

if choice1 == "1":
   output = random.choice(["R","R","R","R","R","P","S"])
if choice1 == "2":
   output = random.choice(["R","P","P","P","P","P","S"])
if choice1 == "3":
   output = random.choice(["R","P","S","S","S","S","S"])
if choice1 == "4":
   output = random.choice(["R","P","S"])

saveinput = input  
saveoutput = output