The ultimate tiebreaker.
Some claim it is random chance.
Some say always lead with paper.
Others claim it’s all in your enemies eyes.
Everyone has some approach.
Me? I decided to take a quantitative approach.
I am of course referring to the age old game of Rock Paper Scissors. Back in my first semester, I decided to take a quantitative approach to the game, utilizing machine learning to create a challenging opponent. I then deployed the algorithms in an android app that keeps a running tally of percent of games won.
Warning: There be technical language and details here
Please excuse the state of the git repo. This was in the days when I was new to git and did not understand everyone can see your git commits….There may be a commits that say “yipp yipp”, “something”, and “The clicker finally fuckin works”.
I wrote the entire program in Java originally with a Java GUI. It was not much trouble to port this to an android app so most of the code is the same between them. I wrote the all the machine learning for the project so no toolboxes are needed.
How I approached the problem:
I figured there are several things that go into an RPS decisions. Namely:
- The amount of a choice used recently (people tend to not throw the same thing over and over)
- Some innate preference of choice (maybe you default to rock)
- Whether a person won, lost, or tied in the past couple games
To account for these aspects, I implemented a logistic regression taking into account several quantitative aspects of recent games. Namely,
- How likely a player is to throw a choice given the percentage of recent games they used that choice
- How likely a player is to throw a choice period
- Given whether they won/tied/lost last game how likely are they to make the choice that would have beaten/tied/lost to their opponent choice last game. (This ends up being 9 features)
Te history of all these features are summed up and fit to logistic regression to determine how much effect each has on choice. Once the weights are updated, they are used to predict what the other player will throw. The computer than throws whatever beats that.
That’s the most important aspects to it. The logistic regression, gradient descent, and GUI are all implementation problems that I won’t go into here, but if you have any questions, feel free to email me!