Submit

Program name:

Your name:

Code:


Console output:

Instructions

Your program will receive input through a global variable called input. input will be a string containing the last move of the opponent ("R", "P", or "S"). In the first round of a match the string will be empty (since the opponent hasn't made any previous moves). Your program will be expected to store its next move in a global variable called output. output should be set to one of the following strings: "R", "P", or "S". Since a RPS match consists of multiple rounds, your program can store local and global variables and use them in subsequent rounds.

Your code must pass system tests before the submission is accepted. The system tests involve compiling the code and testing it on two trial matches. Each trial match consists of 1,000 rounds. System test feedback will be displayed in the console output. Using too much memory or CPU will cause the submission to fail. The CPU limit for a match is five seconds.

By submitting, you agree to release your code into the public domain and waive all copyright. Do not submit copyrighted code that does not belong to you.


Offline Testing

Offline tester: rpsrunner.py

The offline tester allows you to run RPS programs against each other locally on your computer. It should be useful for developing new entries to submit to this site.


Sample Programs

This program will always choose rock:

output = "R"

This program will make random moves:

import random
output = random.choice(["R","P","S"])

This program will examine the opponent's move history to find the most common play. It will then choose the move that beats that play:

if input == "": # initialize variables for the first round
	rockCount = paperCount = scissorsCount = 0
elif input == "R":
	rockCount += 1
elif input == "P":
	paperCount += 1
elif input == "S":
	scissorsCount += 1
if rockCount > paperCount and rockCount > scissorsCount:
	output = "P" # paper beats rock
elif paperCount > scissorsCount:
	output = "S" # scissors beats paper
else:
	output = "R" # rock beats scissors

The secret to creativity is knowing how to hide your sources.

-Albert Einstein