{"id":17998389,"url":"https://github.com/primaryobjects/flying-unicorn","last_synced_at":"2025-03-26T05:30:46.583Z","repository":{"id":139343242,"uuid":"166676937","full_name":"primaryobjects/flying-unicorn","owner":"primaryobjects","description":"A game designed for a quantum computer.","archived":false,"fork":false,"pushed_at":"2021-08-03T15:44:53.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T06:41:36.620Z","etag":null,"topics":["data-science","game","game-development","grover-algorithm","grovers-algorithm","ibm-q","ibm-quantum-computer","ibm-quantum-experience","python3","qiskit","quantum","quantum-algorithms","quantum-computing","r","superposition"],"latest_commit_sha":null,"homepage":"http://www.primaryobjects.com/Flying_Unicorn__Developing_a_Game_for_a_Quantum_Computer.pdf","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/primaryobjects.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-20T15:29:44.000Z","updated_at":"2021-08-03T15:44:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ef25193-fc18-4886-b364-e2d5cc3f064d","html_url":"https://github.com/primaryobjects/flying-unicorn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fflying-unicorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fflying-unicorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fflying-unicorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Fflying-unicorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primaryobjects","download_url":"https://codeload.github.com/primaryobjects/flying-unicorn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597135,"owners_count":20641858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","game","game-development","grover-algorithm","grovers-algorithm","ibm-q","ibm-quantum-computer","ibm-quantum-experience","python3","qiskit","quantum","quantum-algorithms","quantum-computing","r","superposition"],"created_at":"2024-10-29T21:25:04.341Z","updated_at":"2025-03-26T05:30:46.577Z","avatar_url":"https://github.com/primaryobjects.png","language":"Python","readme":"Flying Unicorn\n==============\n\nFly your magical unicorn up into the sky and reach the castle gates!\n\nFlying Unicorn is a game developed for a quantum computer, using the [QisKit](https://qiskit.org/) quantum programming framework. The game is designed to exlore the properties of superposition and uncertainty.\n\nThe game is played in a text-based UI, where the player chooses an action to fly up or down at each turn. The amount of altitude at each turn is randomly determined, based upon a quantum bit (qubit). Additionally, a randomly occurring mini-game where the player has to guess a secret unicorn jewel from a large collection, uses an implementation of [Grover's search](https://en.wikipedia.org/wiki/Grover%27s_algorithm), a quantum algorithm that can find a key within a list of elements faster than any classical algorithm (O(sqrt(n)) versus O(n)).\n\nFor comparison, a classical (non-quantum) version of the game is also available for play at the link below.\n\n[Play Flying Unicorn](https://repl.it/repls/SillyCrazyGlitch)\n\n[Flying Unicorn: Developing a Game for a Quantum Computer](http://www.primaryobjects.com/Flying_Unicorn__Developing_a_Game_for_a_Quantum_Computer.pdf)\n\n[An Introduction to Quantum Computing](http://www.primaryobjects.com/2019/01/07/an-introduction-to-quantum-computing/)\n\n## Usage\n\nThe classic version of the game may be ran as follows.\n\n```bash\npython unicorn-classic.py\n```\n\nThe quantum version of the game may be ran as shown below. You'll need to edit `config.ini` to set your IBMQ `key` in order to call their API. You can obtain a key from your [IBMQ Account](https://quantumexperience.ng.bluemix.net/qx/account). See also the qiskit documentation for [Getting Started](https://github.com/Qiskit/qiskit-api-py#getting-started).\n\n```bash\nexport PYTHONWARNINGS=\"ignore:Unverified HTTPS request\"\npython3.6 unicorn.py\n```\n\n## Gameplay\n\n```text\n================\n Flying Unicorn\n================\n\nYour majestic unicorn, Twilight Bow, is ready for flight!\nAfter a long night of preparation and celebration, it's time to visit the castle in the clouds.\nUse your keyboard to fly up or down on a quantum computer, as you ascend your way into the castle.\n\n\n=====================\n-[ Altitude 0 feet ]-\nTwilight Bow is waiting for you on the ground.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.03s\n{'0': 949, '1': 51}\n\n=====================\n-[ Altitude 51 feet ]-\nTwilight Bow is floating gently above the ground.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 900, '1': 100}\n\n=====================\n-[ Altitude 100 feet ]-\nTwilight Bow is floating gently above the ground.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 862, '1': 138}\n\n=====================\n-[ Altitude 138 feet ]-\nA mischievous quantum cloud blocks your way and challenges you to a game!\nHe has stolen a magical unicorn jewel from the castle!\nIf you can guess which jewel is the real one before the cloud, you'll be rewarded.\nIf you lose, you'll face a penalty.\nDo you want to play his game? [yes,no]: y\nThe mischievous cloud blinks his eyes. You hear a crack of thunder. A unicorn jewel has been chosen.\nPsst. The secret is 2\nRound 1. Which unicorn jewel is the real one? [amethyst,sapphire,emerald,jade]: emerald\nYou guessed wrong.\nRunning on the simulator.\nRequest completed in 0.0m 0.08s\n{'0111': 4, '1100': 2, '0010': 50, '1111': 5, '1011': 7, '0000': 3, '0011': 4, '0001': 4, '0100': 3, '0110': 3, '0101': 4, '1101': 1, '1110': 2, '1000': 3, '1001': 2, '1010': 3}\nThe mischievous cloud guesses sapphire.\nHaha, I win, says the mischievous cloud!\nDon't say I didn't warn you! After all, I live in the quantum world! =)\nAltitude - 100\n\n=====================\n-[ Altitude 38 feet ]-\nTwilight Bow is floating gently above the ground.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 914, '1': 86}\n\n=====================\n-[ Altitude 86 feet ]-\nA mischievous quantum cloud blocks your way and challenges you to a game!\nHe has stolen a magical unicorn jewel from the castle!\nIf you can guess which jewel is the real one before the cloud, you'll be rewarded.\nIf you lose, you'll face a penalty.\nDo you want to play his game? [yes,no]: y\nThe mischievous cloud blinks his eyes. You hear a crack of thunder. A unicorn jewel has been chosen.\nPsst. The secret is 10\nRound 1. Which unicorn jewel is the real one? [amethyst,sapphire,emerald,jade]: sapphire\nYou guessed correct!\nAltitude + 100\n\n=====================\n-[ Altitude 186 feet ]-\nTwilight Bow is hovering just above the evergreen sea of trees.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 738, '1': 262}\n\n=====================\n-[ Altitude 262 feet ]-\nTwilight Bow is approaching the first misty cloud layer.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 625, '1': 375}\n\n=====================\n-[ Altitude 375 feet ]-\nTwilight Bow has soared through the misty pink clouds.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.01s\n{'0': 473, '1': 527}\n\n=====================\n-[ Altitude 527 feet ]-\nTwilight Bow You can barely see the evergreen sea of trees from this high up.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 236, '1': 764}\n\n=====================\n-[ Altitude 764 feet ]-\nTwilight Bow You can see the first glimpse of the golden castle gates just above you.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'0': 14, '1': 986}\n\n=====================\n-[ Altitude 986 feet ]-\nTwilight Bow swiftly glides through the mystical castle gate. You're almost there.\n[up,down,quit]: u\nYou soar into the sky.\nRunning on the simulator.\nRequest completed in 0.0m 0.02s\n{'1': 1000}\nCongratulations! Twilight Bow soars into the castle gates!\nThe game ended in 10 rounds. You won, great job! :)\n```\n\n## Quantum Computing Metrics\n\nTiming metrics for programs executed on the QisKit simulator versus IBM Q Experience can be found in the [data](data) folder. The directory contains the raw data files of program executions on both platforms and across multiple machines, along with an analytics program used for producing the summary dataset and charts, as shown below.\n\nThe metrics include:\n\n```text\nmachine name\nminimum seconds\nmean seconds\nmaximum seconds\n```\n\nMachines include ibmqx4, ibmq_16_melbourne, and the QisKit simulator.\n\n## Results\n\nA summary of the timing metrics for executing a quantum program on the QisKit simulator versus IBM Q Experience is shown below.\n\n![Mean Quantum Computing Execution Times in seconds](data/metrics.png)\n\n```text\n               type runs   min        mean    max\n1         simulator  175  0.06   0.1300571   0.25\n2            ibmqx4   94 53.81  58.2200000  90.23\n3 ibmq_16_melbourne   33 59.87 141.4306061 627.30\n4  IBM Q Experience  127 53.81  79.8416535 627.30\n```\n\n## Metrics Conclusion\n\nThe results record significant wait times for programs executed on IBM Q Experience versus the simulator.\n\nAuthor\n----\nKory Becker\nhttp://www.primaryobjects.com/kory-becker","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fflying-unicorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimaryobjects%2Fflying-unicorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Fflying-unicorn/lists"}