
Show HN: Play rock paper and scissors against a untrained neural network - atum47
https://github.com/victorqribeiro/jokenpo
======
QuadmasterXLII
I hate to say it, but I’m not sure it’s playing fair. I used random.org to
play truly randomly, and the “neural network” beat me to 10 pts 6 times in a
row.

~~~
jchw
The thing is, if you are playing randomly, that makes it easier to predict
what you’re (not) going to do next. A good random distribution would give
fewer runs, which means your choice is less likely to be the last choice you
picked and somewhat less likely to be other recent values. It can at least tie
by choosing scissors if it thinks you will not pick rock.

This is kind of a shot in the dark because I am not familiar with RPS
strategy, but I think it makes sense.

~~~
EGreg
That sounds like the gambler’s fallacy. Less runs than what? Most truly random
input haa far more runs than what people “think” is random, and in fact that’s
one of the statistical tests for whether a data set was random.

You’re essentially saying that a good neural network can predict the next
value of a good random number generator. Good luck with that one!

Maybe while you’re at it, have neural networks invert cryptographically secure
hash functions :)

~~~
jchw
Here’s what I’m thinking: The neural network doesn’t have to be correct about
which one you pick, it has to be correct about which you don’t pick. Only one
option they pick is a loss, so if the other party can be somewhat certain you
won’t pick a specific option, it can at least tie. So if a randomizer has
pretty even distribution, I think it can win more than half the time, because
it can gather roughly how likely the same choice is to be played in a row.

I’m basically suggesting a predictable distribution can be exploited in RPS.

Honestly, the bot could always be winning against the RNG by dumb luck. More
experimentation would be needed to be sure. I am just making guesses.

~~~
misterman101
> I think it can win more than half the time, because it can gather roughly
> how likely the same choice is to be played in a row.

With a random choice, the chance of playing the same choice in a row is 1/3\.
This does not give you any advantage over having no information (where each
choice has a 1/3 chance.)

I think the misunderstanding is in > a randomizer has pretty even distribution

Having an even distribution over a long time does not make any specific choice
less random.
[https://en.wikipedia.org/wiki/Gambler%27s_fallacy](https://en.wikipedia.org/wiki/Gambler%27s_fallacy)

------
veselin
I have "beaten" it. Play initially like you would - typically a human would
change his choice often. The network would learn from you and gain a lead of
say 10 points. After this, if you pick something that gives you a win start
sticking to it while it gives you a win. You will quickly regain the lost
points and gain a small lead. This seems to work every time I try it. After 60
moves I always lead a bit. Btw, the game gets slow then.

Not sure a bigram or trigram model would not do better than the neural
network.

------
atum47
I have merged the first pull request that changes to the prediction first
training after.

~~~
sambroner
Nice. Seems to beat me. I performed significantly better when I used
random.org to generate numbers than when I played with my own attempt at
randomness.

------
resist_futility
Screw up the NN by selecting the same thing over and over at first. Then start
alternating between two values choosing a new set of values when it starts
guessing correctly again. Rinse. Repeat.

------
sagebird
I wonder about an arms race between two advanced AI’s which play RPS.

I can’t fully put my head around this, but what would it be like if each AI
could read the architecture of the other’s brain before each move. The AI’s
would be permitted to reconfigure themselves as they play. An “obvious”
strategy may be to simulate your opponent and ask what they are likely to
play. Though, simulating their behavior is likely to involve you simulating
someone else simulating your behavior, ad-infinium, until your computing
resources bottom out. It is like fighting the man in the mirror who can choose
to mirror you or not.

~~~
make3
don't you just end up with a (discrete) uniform distribution on both sides?
anything else can be exploited by the opponent

~~~
mikeash
Yep, RPS is only interesting to the extent that the players are imperfect.
It’s most interesting as an illustration of how bad people are at behaving
randomly.

------
atum47
This is my awstats after being featured here. Can someone tell how efficient
is my code being served? I have no other numbers (or default values) to
compare.

day | visits | pages | hits | bytes

26 Jul 2019 | 4,688 | 16,507 | 60,489 | 163.89 MB

------
thdxr
Hm in my limited testing of not looking at the screen and selecting as
randomly as I could I was surprised to find it not end 50/50

Not enough trials or is there something else going on here?

~~~
quickthrower2
2 things to consider...

1\. Humans aren't good at random, try using a RNG or dice.

2\. If you toss 10 coins, what is the probability of 5 heads and 5 tails? It
isn't very likely, even though it's the most likely outcome.

~~~
mbrumlow
I let rand play it 500 times the results are as followed.

Player: 144, Computer: 179, Tie: 177,

Although I think I got more equal results when I did 1000 iterations, but
failed to record that one.

[https://youtu.be/g9Zo771HYpM](https://youtu.be/g9Zo771HYpM)

------
thirdmeow
Wow it's surprisingly good

~~~
camjohnson26
Check the other comments, looks like it's cheating by reading the human's
input before guessing.

~~~
atum47
no, it's not.

------
atum47
now with a new interface, thanks to
[https://github.com/ocjojo](https://github.com/ocjojo)

------
bobblywobbles
I expected to lose against a computer.

I was right.

