15 ms·
Show HN: Play rock paper and scissors against a untrained neural network
- thirdmeow 7y agoWow it's surprisingly good
- r-w 7y agoOr we’re surprisingly bad…
- camjohnson26 7y agoCheck the other comments, looks like it's cheating by reading the human's input before guessing.
- atum47 7y agono, it's not.
- thdxr 7y agoHm 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 7y ago2 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 7y agoI 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
- bobblywobbles 7y agoI expected to lose against a computer. I was right.
- QuadmasterXLII 7y agoI 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.
- QuadmasterXLII 7y agoLooking at the source code, the move you are about to make is included in the training dataset. This can be confirmed by playing “scissors scissors scissors rock” and then looking at the variables x and y in the console, which will include the surprise rock. The code updates x and y, then trains the model, and then makes a prediction. “Fair” code would make a prediction, then update x and y and train the model This explains the behavior mentioned in the comments where the computer gets an impressive early lead due to the players next move being one of only a few datapoints it learns from, then backs off to a more plausible advantage as the leaked data is diluted by past data.
- atum47 7y agoafter the player makes a move the nn makes ones and add it to it's training data. the move the player does after that is added as a counter move to the nn move. this way I treat the data as time series.
- atum47 7y agoI think it's fair, cause it's like the neural network is thinking "after I play rock the player plays paper" and train with that data
- j-pb 7y agoBut that's not what you're coding. If you trained it with every possible next move and response then you would learn that kind of relationship (though you would also overfit on the existing moves), but this way you just give it a peek into the probability distribution of the players moves, one thats so accurate that it comes from the future...
- sagebird 7y agoI 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 7y agodon't you just end up with a (discrete) uniform distribution on both sides? anything else can be exploited by the opponent
- mikeash 7y agoYep, 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.
- timfoden 7y agoThere's a site where AIs play RPS on an ongoing basis http://www.rpscontest.com/ http://www.rpscontest.com/. Source code of the entrants is available. My best bot (called paper6) http://www.rpscontest.com/entry/5640686850277376 http://www.rpscontest.com/entry/5640686850277376 wins on average 67% of the time, but the top bots win around 80% of matches.
- resist_futility 7y agoScrew 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.
- veselin 7y agoI 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 7y agoI have merged the first pull request that changes to the prediction first training after.
- sambroner 7y agoNice. 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.
- atum47 7y agonow with a new interface, thanks to https://github.com/ocjojo https://github.com/ocjojo
- atum47 7y agoThis 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