BasicRPSLearner[v2]

AuthorEmmanuel Harish Menon
Submission date2019-04-15 09:31:48.985961
Rating3729
Matches played249
Win rate37.35

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

Source code:

'''
Program Name: BasicRPSLearner[SubmissionCode]
Program by: Emmanuel Harish Menon
Last Updated: 7:30 PM 15/4/19

This edit changes the ors in the if statements to ands
'''

#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 and p > s: #if user favours paper, pick scissors
	output = "S"

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

elif s > r and 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"])