Rock Paper Scissors Predictor

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.

Screenshot_20171122-000452

Implementation

Warning: There be technical language and details here

The repo

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:

  1. The amount of a choice used recently (people tend to not throw the same thing over and over)
  2. Some innate preference of choice (maybe you default to rock)
  3. 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,

  1. How likely a player is to throw a choice given the percentage of recent games they used that choice
  2. How likely a player is to throw a choice period
  3. 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!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s