[Question]
  [
Given two string inputs of "Rock", "Paper", or "Scissors", determine the outcome of the [RPS round](https://en.wikipedia.org/wiki/Rock%E2%80%93paper%E2%80%93scissors). Output 1 if the first player wins, -1 if the second player wins, or 0 for a tie.
```
Rock Rock -> 0
Rock Paper -> -1
Rock Scissors -> 1
Paper Rock -> 1
Paper Paper -> 0
Paper Scissors -> -1
Scissors Rock -> -1
Scissors Paper -> 1
Scissors Scissors -> 0
```
You must use the exact strings "Rock", "Paper", and "Scissors" as inputs. You may choose whether the first players' choice is (consistently) given first or second. You may alternatively take them as a single input with a single-character or empty separator. The input is guaranteed one of the 9 possible pairings of the three choices in your input format.
The output should be a number 1, 0, or -1, or its string representation. Floats are fine. So are `+1`, `+0,` and `-0`.
Related: [Coding an RPS game](https://codegolf.stackexchange.com/q/11188/20260)
---
**Leaderboard:**
```
var QUESTION_ID=106496,OVERRIDE_USER=20260;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/106496/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
# Groovy, ~~67~~ ~~56~~ 50 Bytes
```
{a,b->Math.sin(1.3*((int)b[0]-(int)a[0])).round()}
```
[Try it online!](https://tio.run/nexus/groovy#@19QlJlXkpOnoKFRnaiTpGun65tYkqFXnJmnYaKloQGU00yMNojVBbOSgCxNfbCCAE9NvaL80rwUDc1aTQ2loPzkbCUdpYDEgtQiJU3N//8B "Groovy – TIO Nexus")
Turns out that the rock, paper, scissors game has a pretty cool property.  
Given strings a and b, take the first letter of each, this results in two of the following: `R,P,S`
The exhaustive list of possible values are (When 2 choices are combined):
```
XX=ASCII=Y=Wanted output
RR=82-82=0=0
PP=80-80=0=0
SS=83-83=0=0
RS=82-83=-1=1
RP=82-80=2=-1
PS=80-83=-3=-1
PR=80-82=-2=1
SR=83-82=1=-1
SP=83-80=3=1
```
Reorganizing the list to:
```
-3->-1
-2->1
-1->1
0->0
1->-1
2->-1
3->1
```
Gives us a sequence that looks inversely sinusoidal, and you can actually represent this formula as approximately (and by approximately I mean just barely enough to work, you could get an equation that is dead on but costs more bytes):
```
-sin((4*a[0]-b[0])/PI).roundNearest() = sin(1.3*(b[0]-a[0])).roundNearest()
```
The simplification of 4/pi to 1.3 was suggested first by ***@flawr*** and then tested by ***@titus*** for a total savings of 6 bytes.
[![Equation Explanation](https://i.stack.imgur.com/2mmIc.png)](https://i.stack.imgur.com/2mmIc.png)
Using groovy's double rounding properties, this results in the correct output for rock-paper-scissors.
---
# [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes (non-compete)
```
Ç¥13T/*.½ò
```
[Try it online!](https://tio.run/##MzBNTDJM/f//cPuhpYbGIfpaeof2Ht70/3@0epC6jnqAeiwA "05AB1E – Try It Online")
Same answer ported to 05AB1E using the new commands added 10/26/2017.
[Answer]
# C, ~~50~~ 35 bytes
```
#define f(i)*(short*)(i+7)%51%4%3-1
```
Call `f` with a string containing both players, without separator, and it will return whether the first one wins.
### Explanation:
By looking at the nine possible strings, it turns out that the letter pairs on columns 7 and 8 are unique:
```
       vv
RockPaper
PaperScissors
ScissorsRock
RockRock         // Sneakily taking advantage of the terminating zero
PaperPaper
ScissorsScissors
RockScissors
PaperRock
ScissorsPaper
       ^^
```
The offset and savage cast to `short*` retrieve these letter pairs, and interpret them as numbers:
```
29285
29545
21107
107
25968
21363
29555
27491
20595
```
Then it was a matter of brute-force to find the `51` and `4` remainders, which applied successively reduce these numbers to:
```
3 0 0 1 1 1 2 2 2
```
Which is just perfect to tack yet another remainder at the end, and offsetting the result.
[See it live on Coliru](http://coliru.stacked-crooked.com/a/e0257ab24cffd76d)
[Answer]
# MATLAB/[Octave](https://www.gnu.org/software/octave/), ~~63 54~~ 52 bytes
It is very convenient that the ASCII-codes of the first letters of `Rock,Paper,Scissors` are `R=82,P=80,S=83`. If we subtract `79` we get conveniently `3,1,4`, which we will use now as matrix indices: Here a 4x4-matrix is hardcoded, where the `i,j`-th entry corresponds to the outcome if you plug in the values from just before:
```
     1   2   3   4
  +---------------
1 |  0   0   1  -1
2 |  0   0   0   0
3 | -1   0   0   1
4 |  1   0  -1   0
```
```
A(5,5)=0;A(4:7:18)=1;A=A-A';@(x,y)A(x(1)-79,y(1)-79)
```
[Try it online!](https://tio.run/nexus/octave#@@@oYapjqmlrYO2oYWJlbmVooWlraO1o66jrqG7toFGhU6npqFGhYaipa26pUwmhNf@nZBYXaCTmFWuoB@UnZ6vrqAckFqQWqWtq/gcA "Octave – TIO Nexus")
[Answer]
# [Python](https://docs.python.org/), ~~40~~ 30 bytes
```
lambda x,y:(len(2*x+y)^67)%3-1
```
[Try it online!](https://tio.run/nexus/python3#S1OwVYj5n5OYm5SSqFChU2mlkZOap2GkVaFdqRlnZq6paqxr@D8tv0ghUSEzT0E9KD85W11HQT0gsSC1CMQITs4sLs4vKla34uIEKUsirIyzoCgzr0RDXbVYAYh07RRUU9QVVBU0EnUUknQU0sC0pqbmfwA "Python 3 – TIO Nexus")
### Background
I've started with the function template
```
lambda x,y:(len(a*x+b*y)^c)%d-e
```
and ran a brute-force search for suitable parameters using the following program, then picked one with a minimal-length implementation.
```
RPS = 'Rock Paper Scissors'.split()
g = lambda x,y:2-(94>>len(6*x+y)%7)%4
r = range(1,10)
R = range(100)
def f(a, b, c, d, e):
    h = lambda x,y:(len(a*x+b*y)^c)%d-e
    return all(g(x, y) == h(x, y) for x in RPS for y in RPS)
[
    print('%2d ' * 5 % (a, b, c, d, e))
    for e in r
    for d in r
    for c in R
    for b in r
    for a in r
    if f(a, b, c, d, e)
]
```
[Try it online!](https://tio.run/nexus/python3#ZY/BasMwEETP1lfMRVhylZKEtKUB5xuCcywtyJLsmKqykV2wvt6VG0PT5PZm2ZndmYrjCTnSolWfOMrOeJxU0/et79PHvrPNwDip44aVX6WWGEXYb1fsdXc4WOPYczY@BE5fON0RH7e8dLVhG7FZc1L86XWURJsKFZMCpYAS0AKG70ly/h/O5lgZY8ss8A/FqV4ZkngzfHsHaS2r2SgQOPIc5wWr1mNE4zCXmUVYRLz6RpLON25gKd1qpMjwBIqbNzhJZpuZbf7C@orVb9yFy6u5XLi5L0bep@kH "Python 3 – TIO Nexus")
[Answer]
# Pure Bash, 31
Borrowing [@Dennis's formula](https://codegolf.stackexchange.com/a/106530/11259):
```
a=$1$1$2
echo $[(${#a}^67)%3-1]
```
[Try it online](https://tio.run/nexus/bash#K8/IzElVKEpNTLFWSMnnKk4tUVAJcg3wifyfaKtiCIRGXKnJGfkKKtEaKtXKibVxZuaaqsa6hrH/U/LzUv8H5SdnKwQkFqQWcYFJheDkzOLi/KJiLhhDAaSEC6wOzIIog2iBq4HrAqvDNAPZBrApAA).
---
Previous answer:
# Pure Bash, 43 35
```
echo $[(7+(${#2}^3)-(${#1}^3))%3-1]
```
* Get the string length of each arg (`4`, `5`, `8` respectively for Rock, Paper, Scissors)
* XOR each with 3 to give `7`, `6`, `11` (which when taken mod 3 give `1`, `0`, `2`)
* Then subtract and fiddle with mod 3 to get the desired result.
[Try it online](https://tio.run/nexus/bash#K8/IzElVKEpNTLFWSMnnKk4tUVAJcg3wifyfmpyRr6ASrWGuraFSrWxUG2esqQtiGYJYmqrGuoax/1Py81L/B@UnZysEJBakFnGBSYXg5Mzi4vyiYi4YQwGkhAusDsyCKINogauB6wKrwzQD2QawKQA).
[Answer]
# Mathematica, 32 bytes
```
Mod[{1,-1}.(Length/@#-3)!,3,-1]&
```
Unnamed function taking an ordered pair of lists of characters, such as `{{"R","o","c","k"},{"P","a","p","e","r"}}`, and returning `-1|0|1`.
I wanted the code to avoid not only the three input words, but also the way-too-long function name `ToCharacterCode`; so I worked with the length `4,5,8` of the input words instead, and looked for a short function of those lengths that gave distinct answers modulo 3. (Integer division by 2 is mathematically promising, but those functions have too-long names in Mathematica.)
It turns out that taking the factorial of (the length – 3) gives the answers `1,2,120`, which are `1,-1,0` modulo 3. Then we just compute, modulo 3, the difference of the two values (via the dot product `{1,-1}.{x,y} = x-y`, which is a good way when the two values are in a list).
[Answer]
# Ruby, 36 35 30 bytes
```
a=->a,b{(a+b)[12]?a<=>b:b<=>a}
```
[Try it on ideone.com](https://repl.it/FGkY/1)
Test output:
```
a=->a,b{(a+b)[12]?a<=>b:b<=>a}
 
puts a.call("Rock", "Rock")
puts a.call("Rock", "Paper")
puts a.call("Rock", "Scissors")
puts a.call("Paper", "Rock")
puts a.call("Paper", "Paper")
puts a.call("Paper", "Scissors")
puts a.call("Scissors", "Rock")
puts a.call("Scissors", "Paper")
puts a.call("Scissors", "Scissors")
0
-1
1
1
0
-1
-1
1
0
```
Takes advantage of the fact that 7 of the 9 correct results are generated just by doing a lexicographic comparison using the spaceship operator `<=>`. The `(a+b)[12]` just reverses the inputs to the comparison if the inputs are `Paper` and `Scissors` (and also `Scissors` `Scissors` - but that's `0` either way round).
With thanks to Horváth Dávid for saving me a character, and thanks to G B for saving me another 5.
[Answer]
# [Python](https://docs.python.org/), ~~39~~ ~~36~~ ~~34~~ 33 bytes
```
lambda x,y:2-(94>>len(6*x+y)%7)%4
```
[Try it online!](https://tio.run/nexus/python2#S1OwVYj5n5OYm5SSqFChU2llpKthaWJnl5Oap2GmVaFdqalqrqlq8j8tv0ghUSEzT0E9KD85W11HQT0gsSC1CMQITs4sLs4vKla34uIEKUsirIyzoCgzr0RDXbVYAYh07RRUU9QVVBU0EnUUknQU0sC0pqbmfwA "Python 3 – TIO Nexus")
### How it works
Let's take a look at a few values of the length of six copies of **x** and one copy of **y** modulo **7**.
```
                                l(x,y) =:
x        y        len(x) len(y) len(6*x+y)%7
--------------------------------------------
Rock     Rock          4      4            0
Rock     Paper         4      5            1
Rock     Scissors      4      8            4
Paper    Rock          5      4            6
Paper    Paper         5      5            0
Paper    Scissors      5      8            3
Scissors Rock          8      4            3
Scissors Paper         8      5            4
Scissors Scissors      8      8            0
```
We can encode the outcomes (**{-1, 0, 1}**) by mapping them into the set **{0, 1, 2, 3}**. For example, the mapping **t ↦ 2 - t** achieves this and is its own inverse.
Let's denote the outcome of **x** and **y** by **o(x, y)**. Then:
```
x        y        l(x,y) o(x,y) 2-o(x,y) (2-o(x,y))<<l(x,y)
-----------------------------------------------------------
Rock     Rock          0      0        2                10₂
Rock     Paper         1     -1        3               110₂
Rock     Scissors      4      1        1            010000₂
Paper    Rock          6      1        1          01000000₂
Paper    Paper         0      0        2                10₂
Paper    Scissors      3     -1        3             11000₂
Scissors Rock          3     -1        3             11000₂
Scissors Paper         4      1        1            010000₂
Scissors Scissors      0      0        2                10₂
```
Luckily, the bits in the last columns all agree with each other, so we can OR them to form a single integer **n** and retrieve **o(x, y)** as **2 - ((n ≫ o(x,y)) % 4)**. The value of **n** is **94**.
[Answer]
## [Retina](https://github.com/m-ender/retina), ~~35~~ 31 bytes
```
G`k P|r S|s R
*\)`.+
-
D`\w+
 .
```
[Try it online!](https://tio.run/nexus/retina#U9VwT@AC4v/uCdkKATVFCsE1xQpBXFoxmgl62ly6XC4JMeXaXAp6//8H5SdnK4AILjArILEgtQjCDE7OLC7OLyrmAotB1ECYEEUQNlwVjAFRCOdB1MK5MAYA "Retina – TIO Nexus")
### Explanation
This works in two steps. First, we print the minus signs for the relevant inputs. Then we print a `0` for ties and a `1` otherwise.
```
G`k P|r S|s R
*\)`.+
-
```
This is two stages. The `)` in the second stage groups them together, the `*` makes them a dry run (which means the input string will be restored after they were processed, but the result will be printed) and `\` suppresses printing of a trailing linefeed. The two stages together will print a `-` if applicable.
The first stage is a `G`rep stage which only keeps the line if it contains either `k P`, `r S`, or `s R`. These correspond to the cases where we need to output `-1`. If it's not one of those cases, the input will be replaced with an empty string.
The second stage replaces `.+` (the entire string, but only if it contains at least one character) with `-`. So this prints a `-` for those three cases and nothing otherwise.
```
D`\w+
 .
```
This is two more stages. The first stage is a `D`eduplication. It matches words and removes duplicates. So if and only if the input is a tie, this drops the second word.
The second stage counts the number of matches of  `.`, which is a space followed by any character. If the input was a tie, and the second word was removed, this results in `0`. Otherwise, the second word is still in place, and there's one match, so it prints `1` instead.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~18~~ ~~17~~ ~~15~~ ~~10~~ 9 bytes
6 bytes saved with *Digital Trauma's* [input length trick](https://codegolf.stackexchange.com/a/106508/47066) 
```
€g3^Æ>3%<
```
Takes input as `[SecondPlayersChoice,FirstPlayersChoice]`
[Try it online!](https://tio.run/nexus/05ab1e#@/@oaU26cdzhNjtjVZv//6PVg/KTs9V11AMSC1KL1GMB)
or [Validate all test-cases](https://tio.run/nexus/05ab1e#@290eHFZpU7lo6Y16cZxh9vsjFVtdP7/j1YPyk/OVtdRD0gsSC0C0sHJmcXF@UXF6rEA)
**Alternative 9 byte solution:** `íø¬ÇÆ>3%<`
**Explanation**
```
€g          # length of each in input
  3^        # xor 3
    Æ       # reduce by subtraction
     >      # increment
      3%    # modulus 3
        <   # decrement
```
**Previous 15 byte solution**
```
A-D{„PSÊiR}Ç`.S
```
[Try it online!](https://tio.run/nexus/05ab1e#@@@o61L9qGFeQPDhrsyg2sPtCXrB//8H5SdnByQWpBYBAA) or [Validate all test-cases](https://tio.run/nexus/05ab1e#@290eHFZpU6ll6OuS/WjhnkBwYe7MoNqD7cn6AXr1P7/H60elJ@cra6jHpBYkFoEpIOTM4uL84vUYwE)
**Explanation**
```
 A-               # remove the lowercase alphabet from the input (leaves a 2 char string)
   D{             # sort a copy of the leftover
     „PSÊ         # check if the copy isn't "PS" (our special case)
         iR}      # if true, reverse the string to get the correct sign
            Ç`    # convert the two letters to their character codes
              .S  # compare their values
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
L€Iµ-*×Ṡ
```
[Try it online!](https://tio.run/nexus/jelly#@@/zqGmN56GtulqHpz/cueD/o4Y5QfnJ2UAqILEgtQhIBydnFhfnFxU/apj7cOd0o0NbvYE6ju453A6kHu6YlwWkgKoUdO0UgCoi/wMA "Jelly – TIO Nexus") (test suite, casts to integer for clarity)
### How it works
```
L€Iµ-*×Ṡ  Main link. Argument: A (string array)
L€        Take the length of each string.
  I       Increments; compute the forward difference of the length.
   µ      Begin a new chain with the difference d as argument.
    -*    Compute (-1)**d.
      ×Ṡ  Multiply the result with the sign of d.
```
[Answer]
## CJam, ~~15~~ ~~14~~ 12 bytes
```
rW=rW=-J+3%(
```
Take the ascii code of the last character of each string, then returns:
`(a1 - a2 + 19) % 3 - 1`
Test it [here](http://cjam.aditsu.net/#code=rW%3DrW%3D-J%2B3%25(&input=Rock%20Paper)!
[Answer]
# [Python 2](https://docs.python.org/2/), ~~46~~ 40 bytes
```
lambda x,y:+(x!=y,-1)[x[0]+y[0]in'RPSR']
```
[Try it online!](https://tio.run/nexus/python2#hYpBDoMgFAXX9hSvC/IhYtJuTewZDC6tC9CSkLZgoAs5PdVeoMnkzVuMRYd7eem3WTQ2mduab@cuy@Yqxm28THXex3lS/aBoKjZEaDgPUmF@kgT1en3E4wyzSynERO2pOjLzP6vW6PyHE0vYaW5gC4GBawkjYX8WQpQv "Python 2 – TIO Nexus")
With many thanks to @Dennis for letting me borrow his Try it online test code and for saving me 6 bytes.
**Edit**
@hashcode55 - Pretty much as you describe. (x!=y,-1) is a two element sequence and [x[0]+y[0]in'RPSR'] is computing which element to take. If the first letter of x + the first letter of y is in the character list then it will evaluate to True or 1 so (x!=y,-1)[1] will be returned. If it is not then (x!=y,-1)[0]. This is where it gets a bit tricky. The first element is in itself effectively another if. If x!=y then the first element will be True otherwise it will be False so if x[0]+y[0]in'RPSR' is false then either True or False will be returned depending on whether x==y. The + is a bit sneaky and thanks again to @Dennis for this one. The x!=y will return a literal True or False. We need a 1 or a 0. I still don't quite know how but the + does this conversion. I can only assume that by using a mathematical operator on True/False it is forcing it to be seen as the integer equivalent. Obviously the + in front of the -1 will still return -1.
Hope this helps!
[Answer]
## JavaScript (ES6), ~~46~~ 38 bytes
```
(a,b)=>(4+!b[4]+!b[5]-!a[4]-!a[5])%3-1
```
Makes use of the fact that Rock-Paper-Scissors is cyclic. JavaScript has neither spaceship nor balanced ternary operators, otherwise the answer would be `(a,b)=>((b<=>'Rock')-(a<=>'Rock'))%%3`.
Edit: Saved 8 bytes thanks to @WashingtonGuedes.
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~14~~ 13 bytes
```
TTt_0vic1Z)d)
```
[Try it online!](https://tio.run/nexus/matl#@x8SUhJvUJaZbBilmaL5/3@1enByZnFxflGxuoJ6QGJBapF6LRcA "MATL – TIO Nexus") Or [verify all test cases](https://tio.run/nexus/matl#S/gfElISb1CWmWwYpZmi@d8l5H@1elB@cra6AoSq5YLzAxILUouQBYKTM4uL84uKwWIQWSRdMAGENpgIij44B0krkhhCN5IgkgFcXAA).
### Explanation
If the ASCII code of the initial letter of the first string is subtracted from that of the second string we get the value in the **D** column below. Taking modulo 5 gives the value **M**. The final value in parentheses is the desired result, **R**.
```
                        D        M     R
                       ---      ---   ---
Rock Rock          ->   0   ->   0   ( 0) 
Rock Paper         ->  −2   ->   3   (−1)
Rock Scissors      ->   1   ->   1   ( 1)
Paper Rock         ->   2   ->   2   ( 1)
Paper Paper        ->   0   ->   0   ( 0)
Paper Scissors     ->   3   ->   3   (−1)
Scissors Rock      ->  −1   ->   4   (−1)
Scissors Paper     ->  −3   ->   2   ( 1)
Scissors Scissors  ->   0   ->   0   ( 0)
```
Thus if we compute **D** and then **M**, to obtain **R** we only need to map 0 to 0; 1 and 2 to 1; 3 and 4 to −1. This can be done by indexing into an array of five entries equal to 0, 1 or −1. Since indexing in MATL is 1-based and modular, the array should be `[1, 1, −1, −1, 0]` (the first entry has index 1, the last has index 5 or equivalently 0). Finally, the modulo 5 operation can luckily be avoided, because it is implicitly carried out by the modular indexing.
```
TT     % Push [1 1]
t_     % Duplicate, negate: pushes [−1 −1]
0      % Push 0
v      % Concatenate vertically into the 5×1 array [1; 1; −1; −1; 0]
i      % Input cell array of strings
c      % Convert to 2D char array, right-padding with zeros if necessary
1Z)    % Take the first column. Gives a 2×1 array of the initial letters
d      % Difference
)      % Index into array. Implicit display
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 12 bytes
```
0XXWW]rcrc-=
```
The two inputs are space-separated. Their order is reversed with respect to that in the challenge text.
[Try it online!](https://tio.run/nexus/cjam#@28QEREeHluUXJSsa/v/f1B@crYCiAAA "CJam – TIO Nexus") Or [verify all test cases](https://tio.run/nexus/cjam#q/5vEBERHh5blFyUrGv7v6DWUut/UH5ytgKI4ApILEgtgjCDkzOLi/OLiiE8sBKwLFQNhA1XBOGCVcHEoArhXLhaGAMA).
### Explanation
Translation of my [MATL answer](https://codegolf.stackexchange.com/a/106520/36398). This exploits the fact that in CJam `c` (convert to char) applied on a string takes its first character. Also, the array for the mapping is different because indexing in CJam is 0-based.
```
0XXWW    e# Push 0, 1, 1, -1, -1
]        e# Pack into an array
rc       e# Read whitespace-separated token as a string, and take its first char
rc       e# Again
-        e# Subtract code points of characters
=        e# Index into array. Implicitly display
```
[Answer]
#  Python 3, 54 bytes
```
lambda o,t:(o!=t)*[-1,1]['RPS'['PS'.find(t[0])]!=o[0]]
```
[Try it online!](https://tio.run/nexus/python3#DcXBDoAQGADgV@G/oKnl2uYdTEc5KNmswsz7y@X7ApLo6K/7Tu9Q5m2jGcvGJjMLLqwhWu3EkMESYvK0mdUyi2Ue215qTI0GCjpfD3BQrtwVGOs/)
[Answer]
# Java 7, 82 bytes
```
int c(String...a){int x=(a[0].charAt(1)-a[1].charAt(1))%5/2;return x%2==x?x:x/-2;}
```
**Ungolfed:**
```
int c(String... a){
   int x = (a[0].charAt(1) - a[1].charAt(1)) % 5 / 2;
   return x%2 == x
           ? x
           : x / -2;
}
```
**Explanation:**
* The second letters are `o`, `a` and `c`, with the ASCII decimals `111`, `97` and `99`.
* If we subtract these from each other for the test cases we have the following results:
	+ `0` (Rock, Rock)
	+ `14` (Rock, Paper)
	+ `12` (Paper, Scissors)
	+ `-14` (Paper, Rock)
	+ `0` (Paper, Paper)
	+ `-2` (Paper, Scissors)
	+ `-2` (Scissors, Rock)
	+ `2` (Scissors, Paper)
	+ `0` (Scissors, Scissors)
* If we take modulo 5 for each, we get `4`, `2`, `-4`, `-2`, `-2`, `2`.
* Divided by 2 `x` is now the following for the test cases:
	+ x=0 (Rock, Rock)
	+ x=2 (Rock, Paper)
	+ x=1 (Paper, Scissors)
	+ x=-2 (Paper, Rock)
	+ x=0 (Paper, Paper)
	+ x=-1 (Paper, Scissors)
	+ x=-1 (Scissors, Rock)
	+ x=1 (Scissors, Paper)
	+ x=0 (Scissors, Scissors)
* Only the `2` and `-2`are incorrect, and should have been `-1` and `1`instead. So if `x%2 != x` (everything above `1` or below `-1`) we divide by `-2` to fix these two 'edge-cases'.
**Test code:**
[Try it here.](https://ideone.com/nyNDZq)
```
class M{
  static int c(String...a){int x=(a[0].charAt(1)-a[1].charAt(1))%5/2;return x%2==x?x:x/-2;}
  public static void main(String[] a){
    String R = "Rock",
           P = "Paper",
           S = "Scissors";
    System.out.println(c(R, R)); // 0
    System.out.println(c(R, P)); // -1
    System.out.println(c(R, S)); // 1
    System.out.println(c(P, R)); // 1
    System.out.println(c(P, P)); // 0
    System.out.println(c(P, S)); // -1
    System.out.println(c(S, R)); // -1
    System.out.println(c(S, P)); // 1
    System.out.println(c(S, S)); // 0
  }
}
```
**Output:**
```
0
-1
1
1
0
-1
-1
1
0
```
[Answer]
# dc, 18
```
1?Z9+2/rZ1+2/-3%-p
```
[Try it online](https://tio.run/nexus/bash#K8/IzElVKEpNTLFWSMnnSk3OyFdQUglyDfCJVFKoUUhJVtBNVVD/b2gfZaltpF8UZQgkdY1VdQv@q3Ol5Oel/o8Oyk/OjlWIDkgsSC2K5YLSCtHByZnFxflFxUAhOFMBopgLpgfKg2mBGYGkHskUqB7s5qLbDjEZAA).
Note that the two args are passed (space-separated) on one line to STDIN. The args are contained in square brackets `[ ]` as this is how `dc` likes its strings.
`dc` has *very* limited string handling, but it turns out one of the things you can do is use the `Z` command to get a string length, which luckily is distinct for "Rock", "Paper" and "Scissors", and can be fairly simply arithmetically manipulated to give the desired result.
[Answer]
# PHP, 34 bytes
```
<?=md5("BMn$argv[1]$argv[2]")%3-1;
```
[Answer]
# JavaScript, ~~37~~, ~~32~~, 31 bytes
```
a=>b=>a==b?0:!(a+b)[12]^a>b||-1
```
If a equals b, output zero.
Otherwise, xor the result of checking if length not greater than 12 (comparison of Scissors and Paper) with the comparison of a greater than b.  
If this returns 1, return it.
If it returns 0, use the OR operator to replace with -1.
[Answer]
# [Perl 5](https://www.perl.org/) `-p`, 24 bytes
```
$_=/kS|rR|sP/-/kP|rS|sR/
```
The input should be on stdin without separators, e.g.:
```
echo PaperRock | perl -pe'$_=/kS|rR|sP/-/kP|rS|sR/'
```
The first regexp searches for first player win, the second for his loss. The difference is printed.
[Try it online!](https://tio.run/##K0gtyjH9/18l3lY/O7imKKimOEBfVz87oKYouKY4SP///6D85GwQ5gIRAYkFqUVgVnByZnFxflExF1gIrADMgqgAk3AlMAZYFYwDUQjjweh/@QUlmfl5xf91C3IA "Perl 5 – Try It Online")
[Answer]
# Pyth, 16
```
t%+7h.+mx3ldQ3
```
Probably could be shorter.
```
        x3ld      # lambda to get string length then XOR with 3
       m    Q     # map over the input (array of 2 strings)
     .+           # difference of the two results
    h             # flatten one-element array
  +7              # add 7
 %           3    # mod 3
t                 # subtract 1 and implicit print
```
[Online](https://pyth.herokuapp.com/?code=t%25%2B7h.%2Bmx3ldQ3&test_suite=1&test_suite_input=%5B%22Rock%22%2C%20%22Paper%22%5D%0A%5B%22Paper%22%2C%20%22Scissors%22%5D%0A%5B%22Scissors%22%2C%20%22Rock%22%5D%0A%5B%22Rock%22%2C%20%22Rock%22%5D%0A%5B%22Paper%22%2C%20%22Paper%22%5D%0A%5B%22Scissors%22%2C%20%22Scissors%22%5D%0A%5B%22Rock%22%2C%20%22Scissors%22%5D%0A%5B%22Scissors%22%2C%20%22Paper%22%5D%0A%5B%22Paper%22%2C%20%22Rock%22%5D&debug=0).
[Answer]
# C#, ~~85~~ 84 bytes
Saved 1 byte, thanks to TheLethalCoder
```
a=>b=>a==b?0:(a[0]=='R'&b[0]=='S')|(a[0]=='P'&b[0]=='R')|(a[0]=='S'&b[0]=='P')?1:-1;
```
It accepts two strings as an input, and outputs an integer. There is a tie, if the two strings are equal, otherwise it checks for the first charachter of the strings, in order to determine, which player wins.
[Answer]
## Batch, 116 bytes
```
@if %1==%2 echo 0&exit/b
@for %%a in (RockScissors PaperRock ScissorsPaper)do @if %%a==%1%2 echo 1&exit/b
@echo -1
```
[Answer]
## Perl, 33 bytes
32 bytes of code + `-p` flag.
```
$_=/(.+) \1/?0:-/k P|r S|s R/||1
```
To run it:
```
perl -pe '$_=/(.+) \1/?0:-/k P|r S|s R/||1' <<< "Rock Paper"
```
*Saved 3 bytes by using the regex of Martin Ender's Retina [answer](https://codegolf.stackexchange.com/a/106502/55508). (my previous regex was `/R.*P|P.*S|S.*R/`)*
**Explanation:**
First, `/(.+) \1/` checks if the input contains twice the same word, if so, the result is `0`. Otherwise, `/k P|r S|s R/` deals with the case where the answer is `-1`. If this last regex is false, then `-/k P|r S|s R/`is false, so we return `1`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
L€^3Iæ%1.
```
This uses the algorithm from [@DigitalTrauma's Bash answer](https://codegolf.stackexchange.com/a/106508/12012).
[Try it online!](https://tio.run/nexus/jelly#@@/zqGlNnLHn4WWqhnr/HzXMCcpPzgZSAYkFqUVAOjg5s7g4v6j4UcPchzunGx3a6g1Uf3TP4XYglQXEQCUKunYKQOnI/wA "Jelly – TIO Nexus")
### How it works
```
L€^3Iæ%1.  Main link. Argument: A (string array)
L€         Take the length of each string.
  ^3       XOR the lengths bitwise with 3.
    I      Increments; compute the forward difference of both results.
     æ%1.  Balanced modulo 1.5; map the results into the interval (-1.5, 1.5].
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 19 bytes
```
-Ms(4*(Uc -Vc)/MP¹r
```
[Try it here!](http://ethproductions.github.io/japt/?v=1.4.3&code=LU1zKDQqKFVjIC1WYykvTVC5cg==&input=IlJvY2siICJTY2lzc29ycyI=)
Inspired by [carusocomputing's solution](https://codegolf.stackexchange.com/a/106505/61613)
Old 53-byte Solution
```
W=Ug c X=Vg c W¥X?0:W¥82©X¥83?1:W¥80©X¥82?1:W¥83©X¥80?1:J
```
[Try it online!](https://tio.run/nexus/japt#@x9uG5qsEGEblqwQfmhphL2BFZCyMDq0MgJIGdsbgrkGEK4RlGsM4RoAuV7//ysF5SdnKykoBSQWpBYpAQA)
Thanks again, ETHproductions!
[Answer]
# PHP, ~~55~~ 53 bytes
```
<?=(3-(ord($argv[2])%6%4-ord($argv[1])%6%4+3)%3*2)%3;
```
* takes the ascii values of the first letters (from command line arguments): 82,80,83
* %6: 4,2,5
* %4: 0,2,1
* difference (b-a):
	+ PS:1-2,SR:2-0,RP:2-0 -> -1 or 2; +3,%3 -> 2
	+ SP:2-1,RS:0-2,PR:0-2 -> -2 or 1; +3,%3 -> 1
	+ RR,PP,SS:0; +3,%3: 0
* (3-2\*x): -1,1,3
* %3: -1,1,0
**sine version, ~~49~~ 46 bytes**
```
<?=2*sin(1.3*(ord($argv[2])-ord($argv[1])))|0;
```
a golfed port of [carusocomputing´s answer](https://codegolf.stackexchange.com/a/106505#106505):
3 bytes saved by @user59178
[Answer]
## Python 2, 32 bytes
```
lambda*l:cmp(*l)*(1|-('R'in`l`))
```
[Try it online](https://tio.run/nexus/python2#hYoxDgIhFAXr9RSvIR8I2tlsomcwa2uxH1YSIgsEvD@KFzCZZKYYjwsePfJuN9ZxdnuROio9fDobWiikNa6q@1zBCAm0ZPciA7pxedYRdxday7XRfJjGZv9vU6khvSWJhi/HK8RGEJBsYA38z0qp/gE)
A fairly short "natural" solution, though not as short as Dennis's [brute-forced solution](https://codegolf.stackexchange.com/a/106530/20260).
The `cmp(*l)` compares the inputs lexicographically, giving -1, 0, or +1 for smaller, equal, and greater. This gives the right negated answer on each pair of `"Paper", "Rock", "Scissors"` except on Paper vs Scissors in either order. To fix that, we multiply by -1 on any input without an 'R' in the string rep. This also flips Scissors vs Scissors and Paper vs Paper, but those gave 0 anyway. 
Thanks to xsot for saving a byte with the `(1|-(_))` construct to turn a Bool into ±1. This is shorter than the alternatives.
```
lambda*l:cmp(*l)*cmp(.5,'R'in`l`)
lambda*l:cmp(*l)*(-1)**('R'in`l`)
lambda*l:cmp(*l)*(1-2*('R'in`l`))
```
]