Q:

Can you use modulus to make 0 > 2?

I wanted to create a rock-paper-scissors game that didn't use a lot of conditionals, and I was wondering if there were any mathematical way of representing the cycle of rock-paper-scissors. So Rock beats Paper beats Scissors beats Rock, or Rock > Paper > Scissors > Rock. If you assigned numbers to these, it wouldn't work: 0 > 1 > 2 > 0. But I was wondering if there were some way you could use modulus function to make this work? I understand that if you had a series of integers and modded them by 3 you would get a repeating cycle of 0, 1, 2, e.g. 60 % 3 = 0; 61 % 3 = 1; 62 % 3 = 2, 63 % 3 = 0, etc.
Do you think there could be any way to make this programmable using mods? I'm interested to know if there's an algorithm or some way to use this to create a cycle where 0>1>2>0. Just a warning, though, I don't study maths or know a lot about complex maths, so if you know of a way to do this, I'd really appreciate it if you tried not to overwhelm me with maths terms!

A:

Since there are only three options the simplest thing to do is an equality check rather than a less than sort of comparison, which is possibly what long tom meant.
Specifically, $x\equiv y+1$ modulo three if and only if $x$ beats $y$. Swap $x,y$ to check the other way round. If neither was true, it was a tie.

A:

Codify Rock by 0, Scissors by 1, and Paper by 2. Notice that, modulo $3$, option $k$ beats option $k+1$ and is beaten by option $k-1$. So, if $x$ and $y$ are the choices of player 1 and 2, respectively, then compute $k=x-y$ modulo $3$. Then player 2 wins iff $k=1$, player 1 wins iff $k=-1$, and they tie iff $k=0$. This easily generalizes to cycles of any length. Thus, after correctly codifying the options by numbers (actually elements of the group $\mathbb Z_n$), all you need to do is compute the difference, compute modulo $n$, check whether the result is $0$ (resulting in a tie), or is it in the range 1 to floor(n/2) (player 2 wins), or else player 1 wins (some care needed according to the parity of $n$ and the rules of the game). 

