meg_dm_001

Authormeg_dm
Submission date2017-07-25 20:24:27.749040
Rating3708
Matches played206
Win rate36.89

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

Source code:

import random


def getbeats(expected_move):
  if expected_move == "R":
      return("P")
  elif expected_move == "P":
      return("S")
  else:
      return("R")

def getmost(moves):
   num_r = moves.count("R")
   num_p = moves.count("P")
   num_s = moves.count("S")
   if num_r > num_p and num_r > num_s:
	return("R") 
   elif num_p > num_s:
	return("P") 
   else:
	return("S") 
     


if input == "": # initialize variables for the first round
    last_move = ""
    cnt = 0
    N = 4
    hist = []
    myhist = []
    for i in range(N):
        hist.append(random.choice(["R","P","S"]))
        myhist.append(random.choice(["R","P","S"]))
else:
    cnt = cnt + 1
    last_move = input
    hist.append(last_move)

 
if hist[-1] == myhist[-1]:
    expected_move = random.choice(["R","P","S"])
else:
    expected_move = getmost(hist[-N:])

mymove = getbeats(expected_move)

myhist.append(mymove)
output = mymove