BasicRPSLearner[v1]

AuthorEmmanuel Harish Menon
Submission date2019-04-14 23:01:45.599513
Rating2410
Matches played246
Win rate24.8

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

Source code:

'''
Program Name: BasicRPSLearner[SubmissionCode]
Program by: Emmanuel Harish Menon
Last Updated: 8:56 AM 15/4/19
  
Explanation:
This program looks back the user's history of winning to determine whether the user favours rock, paper or scissors and makes a pick based on that. However, on the first try, since it does not have any input, it just makes a random guess. This program might have a problem with decision structure and flow because it utilises multiple or statements. 
'''

#importing modules
import random

if input == "": #sets variables
	r = s = p = 0

elif input == "R": #if user input is rock, it increments the rock count by one
	r += 1
elif input == "S": #if user input is scissors, it increments the scissors count by one
	s += 1
elif input == "P": #if user input is paper, it increments the scissors count by one
	p += 1

if p > r or p > s: #if user favours paper, pick scissors
	output = "S"

elif r > p or r > s: #if user favours rock, pick paper
	output = "P"

elif s > r or s > p: #if user favours scissors, pick rock
	output = "R"
else: #if all values are equal or no decision can be reached, random value is picked
	output = random.choice(["R","P","S"])