rock_paper_scissors.rb

At Brighton Ruby Conference 2017 there was a amazing lightning talk by Dorothy Wingrove which told the story of a Rock Paper Scissors championship which took place in the 90’s. What at first seemed like a trivial application to build suddenly had a new world of complexity to it. If you haven’t seen the talk I encourage you to watch it before continuing.

https://brightonruby.com/2017/ruby-paper-scissors-dot-wingrove/

On the train back from Brighton the conversation started. How hard can it be? Surely it doesn’t need to be that complicated? And so the first carwow rock paper championship was born. On Friday’s at carwow we’re encouraged to work on something different, usually a bit of tech debt but you’re really given free reign to work on something which is fun, makes your job easier or learning and growing your technical skills. This mostly fell into the fun category.

After a time we decided on a date and a few rules. In total there were 7 participants myself included.

I spent some time be beforehand building a small app for the challenge, the app would take Rock Paper Scissor bots and pit them against each other any number of times, each subsequent game would receive an array of all the other players previous moves. The app can be found here

https://github.com/stephenlloyd/rps_tournament (feel free to use/share)

Choosing the rules for the tournament were a bit arbitrary but we decided 2 hours was enough time to create an interesting solution.

Over the 2 hours we had our finished bots, annoyingly in all the set up and finishing the challenger app I only had about 15 minutes to do my

[:r, :p, :s ].shuffle.sample

(internal joke, `.sample` would have yielded the same results). A few people tried to implement the winning result from the official tournament, others had their own custom strategies which played against their opponents last move (good against a static bot).

When the time came to run the bots against each other we were faced with a choice, do we run them 100, 1000, 5000 times. What was best? Of course we didn’t discuss this and just ran them over and over again until we got the results we were happy with. I failed in 1 key area, defining what it means to win, It’s not as straightforward as who beat the most people, it’s really who won the most games in total. My solution only beat the AlwaysRockBot 2 in 3 times whereas Jade’s could only ever lose a maximum of once against such a bot, clearly hers was better in that area. We must have run app 10 times before we all decided the next and last run would return the final result and crown the winner of the inaugural carwow rock paper scissors championship who was our CTO David. Each time we ran the app someone else won apart from one persons who will remain nameless. The key takeaway is that it’s really hard to beat a random bot and I encourage you all the hold the same tournament where you work, just define how to calculate the winner upfront.

The official results