Wednesday, April 23, 2014

Test of the GTO brain teaser #1 solution

http://farm4.staticflickr.com/3010/2325449341_b05e02613e_b.jpg
(Source: Ben Pollard)
 
We all know the classic game of rock paper scissors. The game is perfectly even for both players and is pretty much the same as flipping a coin to see which side faces up.

To twist that a bit, consider facing an opponent who has a disadvantage. The opponent must flip a coin without showing it to you. If it is heads, he must play rock. (The opponent must play rock 50 % of the time). Otherwise, he is free to play whatever he wants.

If you win, you gain $100. If you lose, you give $100 to the opponent.

The question is, what strategy do you use to get the most money, given the opponent will adapt to his optimal strategy for each strategy you take?

The brain teaser is given in GTORangeBuilder's blog.

The solution is less straightforward you might think. The first strategy that might come to mind is using paper all the time. After all, the opponent has to use rock half the time, so you have to gain money that way, right?

Unfortunately, not quite. The opponent will start to start scissor all the time to counter your paper. So the end result is just 50/50.

The solution turns out to be very interesting. I learned quite a lot about the Nash equilibrium and indifference criteria, which are used to solve the problem.

It turns out the best strategy is to use paper 2/3 of the time, rock 1/3 of the time, and never play scissors. The opponent, countering this, will play paper 1/3 of the time when he has the choice, scissor 2/3 of the time when he has the choice, and never play rock when he has the choice.

So, how much money will you expect to make per game, or the EV (expected value) of the the game?

It turns out if you use this strategy, you will make $16.66 per game, pretty decent wage.

I decided to test this myself. I wrote a small javascript application to simulated the strategy. You can try it yourself on the right of my blog page. A 1000 trials of repeated trials yields very close to $16.66 dollars ($13-20 average).

You may find that repeatedly using paper will give you about a $30 average gain. That's because the the my written cpu cannot adopt to any strategies you use. You can toggle the cpu's strategy with the 3 fields I provided. You can also toggle your own strategy if you want to automate the playing.

You can see the source code here:
https://gist.github.com/liu916/11239336

Questions, comments? Post them below.