Author | Emmanuel Harish Menon |
Submission date | 2019-04-15 11:59:13.942526 |
Rating | 4530 |
Matches played | 243 |
Win rate | 42.39 |
Use rpsrunner.py to play unranked matches on your computer.
'''
Program Name: MarkovChainLearner[SubmissionCode]
Program by: Emmanuel Harish Menon
Last Updated: 9:47 PM 15/4/19
'''
#import modules
import random
#declare variables
randArrayPicker = "" #used to store a single string from array
randChoiceArray = ["R", "P", "S"] #used to pick a random choice at the start of the program
rockArray = ["R", "R", "R", "R", "R", "R", "P", "P", "S", "S"] #Markov chain probability when at "ROCK" state [R: 60% / P: 20% / S: 20%]
paperArray = ["P", "P", "P", "P", "P", "P", "R", "R", "S", "S"] #Markov chain probability when at "PAPER" state [P: 60% / R: 20% / S: 20%]
scissorsArray = ["S", "S", "S", "S", "S", "S", "P", "P", "R", "R"] #Markov chain probability when at "SCISSORS" state [S: 60% / P: 20% / R: 20%]
if input == "": #if no input has been taken yet, just pick something random
output = randChoiceArray[random.randint(0, 2)]
else:
if input == "R": #if users previous input was rock, use the rockArray to detemine choice
randArrayPicker = rockArray[random.randint(0, 9)]
if randArrayPicker == "R":
output = "P"
elif randArrayPicker == "P":
output = "S"
elif randArrayPicker == "S":
output = "R"
elif input == "S": #if users previous input was scissors, use the scissorsArray to detemine choice
randArrayPicker = scissorsArray[random.randint(0, 9)]
if randArrayPicker == "R":
output = "P"
elif randArrayPicker == "P":
output = "S"
elif randArrayPicker == "S":
output = "R"
elif input == "P": #if users previous input was paper, use the paperArray to detemine choice
randArrayPicker = paperArray[random.randint(0, 9)]
if randArrayPicker == "R":
output = "P"
elif randArrayPicker == "P":
output = "S"
elif randArrayPicker == "S":
output = "R"