Team Random Chaos' repository for Qiskit Fall Fest Hackathon, IITR 2021
The classical game of Rock-Paper-Scissors becomes biased when two people play against each other. One may easily catch on to their opponent's strategy if the opponent plays in a regular pattern. One might extend the classical game by introducing new moves as in the game Rock-Paper-Scissors-Lizard-Spock to mitigate this. But even then, the internal psychological biases of the human brain might not let the game be truly random, creating a stand-off.
We propose a solution to this predicament by generating truly random moves using Quantum Random Number Generator. The computer will use the random generated moves to play against a human (who will play by using hand gestures).
- Develop a basic understanding of the quantum computing
- Explore different ways to create a quantum random number generator
- Take image input from user and identify different hand gesture.
- Develop a interface to play Rock-Paper-Scissor-Lizard-Spock against quantum computer.
- Analysing human psychology based strategy against complete randomness.
- Created a Quantum random generator using noise only (over QasmSimulator in Qiskit).
- Linked Qrng with web game .
- Train a classical machine learning model using python to identify different hand gestures for rock, paper, scissors, lizard and spock.
- Developed web interface for game using html, css and javascript.
- For further info: Project Presentation
- Clone this repo into your local machine using the command:
$ git clone https://github.com/tushdon2/Qiskit_Hackathon_IITR_2021.git
- Change your working directory to the cloned repo and create a Virtual Environment. For example, a virtual environment named
venv
can be created using venv by the command:
$ cd Qiskit_Hackathon_IITR_2021
$ python -m venv venv
- Activate the environment:
- use
.\venv\Scripts\activate
command in Windows - use
$ source venv/bin/activate
in MacOS or Linux - It can later be deactivated by using the
deactivate
command
- Install the required libraries and packages from the
requirements.txt
file
$ pip install -r requirements.txt
- Capture dataset images using the capture_dataset_images.py file. For example, to collect 200 images for rock gesture, use:
$ python3 ./src/capture_dataset_images.py rock 200
- Do this for all the gestures: paper, scissors, lizard and spock. Also capture images of mundane stuff to classify as none. Divide the captured images into train, valid and test datasets as shown directory structure:
assets
|
|--data
| |
. |--train
. | |
. | |-- (all images captured for training)
|
|--test (all images captured for testing)
|
|--valid (all images captured for validation of model)
- Run the model_train_and_validate.ipynb and model_test.ipynb Jupyter Notebooks to train, validate and test the generated CNN model (will be stored in model directory in assets folder).
- Run the main.py file to play the game.
$ python3 ./src/main.py
- We have used WebcamJS library to capture images. It's already bundled in the webcamjs directory.
- We have tested the code on Windows with Chrome Version 94.0.4606.81 and Python 3.9.
- Set the default download location of your browser (Chrome advised) to a captures folder inside assets directory and turn off the Ask where to save each file before downloading feature.
- Install Downloads Overwrite Already Existing Files Chrome extension.
- Click on "Configure" to configure the webcam
- Now make the hand gesture of whichever symbol you want to choose (i.e rock, paper, scissor, lizard, spock)
- Click on “Take Snapshot”
- Continue playing until either you or computer scores 5 points
- Whoever scores 5 points first, wins the game
- For starting a new game, reload the game.
- Scissors decapitates Lizard
- Scissors cuts Paper
- Paper covers Rock
- Rock crushes Lizard
- Lizard poisons Spock
- Spock smashes Scissors
- Scissors decapitates Lizard
- Lizard eats Paper
- Paper disproves Spock
- Spock vaporizes Rock
- Rock crushes Scissors, as always.