Designing Rock Paper Scissors Game

Back to old school

Posted by Chandu on May 22, 2020

Have you all remember the rock paper scissors game that we used to play in our childhood. I know this is not very common game in Indian house holds 😂.

One good day while out of blue I got a thought to develop this game on our mobile devices.

Mobile devices are very ubiqutous now a days. All most all have one mobile devices in their hand. So, I'm very much keen about mobile techologies. Because of many reason from which I'd list down a few of them:

  • Data is the new oil and they give lot of data.
  • In my opinion the next big technology will be IoT. It may be because of 5G or any other factor. Already lot of big technology and manufacturing companies are using it alot
  • The list goes on

The list is not comprehensive but it gives you an overall picture.

Brainstroming

The big picture of my game is to build a game that can be played with two remotely connected people.

Here we go. I thought about the game rules. The use has to point his mobile's camera to their hand. On count of 3 the user makes a guesture. My algorithm should recognise the gesture and classify it into one of the rock , paper, scissor or None of the above.

Initially, thinking of a two player game. One will be the winner. Alright! Now I'll explain about my finding on the algorithm and planning.

Research

Recognising the Hand Guesture

Thinking on what to do next and how do I proceed 🤔. I googled a lot. Then my results are the following:

  • I found lot of results for recognising hand gestures using opencv. Well! Most of my result were in python. But thank god OpenCV has a very good documentation for Java as well.
  • Then the other way that I found out for doing this is using Machine Learning to classify images.
  • The OpenCV Way

    I've to found out that recognising the hand guesture is a little bit easy using OpenCV. Many have done experiments on recognising the Hand guestures using OpenCV. Most of them recognised the numbers using hand guestures. Other than numbers few tried recognising the symbols like Ok👍. Perfect👌 etc.,

    I'll tell you how it works:

    1. We detect a particular colour in the frame.
    2. We detect countour(edges) and hulls in the image.
    3. Using the angle between the hulls we will determine how many fingers and opened. If there are 2 fingers opened, it will be scissors, if 5 it's paper and if it's 0 it's stone.

    But this needs a plane background with less disturbance. I can make a game, but I don't know how well it will be received. On this conclusion I thought of the Machine Learning way

    The Machine Learning way

    With remarks from opencv I started looking into tensorflow lite

    Communicating with two users

    And there are lot of things to cover in this blog. I'll keep updating this blog.