Rock, Polyglot, Scissors Write a program that is a polyglot in three languages that plays rock–paper–scissors.

The input for any version of the program is always one of the strings rock or paper or scissors.

In the first language the program must output the rock–paper–scissors choice that beats the input:

Input     Output
rock      paper
paper     scissors
scissors  rock


In the second language the program must output the rock–paper–scissors choice that ties the input:

Input     Output
rock      rock
paper     paper
scissors  scissors


In the third language the program must output the rock–paper–scissors choice that loses to the input:

Input     Output
rock      scissors
paper     rock
scissors  paper


The shortest code in bytes wins. Tiebreaker is higher-voted answer.

The inputs and/or outputs may optionally have a trailing newline but otherwise should only be the plain rock/paper/scissors strings. You may use uppercase ROCK, PAPER, SCISSORS if desired.

You may not use different versions of the same language (e.g. Python 2 and 3).
Python, brainfuck and JavaScript, 103 99 bytes Yay under 100 bytes!

0,[.5,];p=["rock","scissors","paper"]
1//1;lambda x:p[p.index(x)-1];"""
x=&gt;p[-~p.indexOf(x)%3]//"""


In Python, this defines a function which beats the input, in brainfuck it's just a simple cat program, and in JavaScript it loses. Here's a version which gives the functions a name, f, and also prompts for input in JavaScript and Python 3:

0,[.5,];p=["rock","scissors","paper"]
1//1;f=lambda x:p[p.index(x)-1];"""
f=x=&gt;p[-~p.indexOf(x)%3]//"""

1//1;"""
console.log(f(prompt())) // JavaScript
1//1"""; print(f(input())) # Python


Try it online (older version): Python,
 brainfuck, JavaScript

Explanation:

In Python, """...""" is a multiline string, which can be used as any token. When placed stand-alone it doesn't do anything at all. I use this to "hide" the JavaScript code from Python. The same goes for the (0,[.5,]) bit, it's just a tuple containing a 0 and a list of 5, and also the 1//1 part, // in Python is integer division, but starts a comment in JavaScript. Here's the code stripped of these tokens:

p=["rock","scissors","paper"]
lambda x:p[p.index(x)-1]


The first line is pretty self-explanatory, it just defines the list p to contain the different choices in rock-paper-scissors. The second line defines an unnamed function which takes one argument, x, and gives back the choice that beats x (eg. the previous element in p)



In JavaScript, // denotes a single-line comment. Similarly to Python, single tokens are ignored, so the code stripped of these tokens is:

p=["rock","scissors","paper"]
x=&gt;p[-~p.indexOf(x)%3]


This works similarly to Python, by first setting the list p to contain the choices and then defining an anonymous function that gives the losing choice. -~x is the same as x+1 but with higher precedence so that I can skip the parens.



In brainfuck, every character except +-,.[]&lt;&gt; are removed, leaving this:

,[.,][,,]
[.-]
&gt;[-.]


The command , reads one byte of input, . prints it and [...] loops while the value is non-zero. What this program does then is read the input and printing it one character at a time until the character \0 is found. Since we don't have that in the code, we can ignore the rest of the program. In effect, this just echoes back whatever the user types in, effectively tying them.