!(https://hackernoon.com/hn-images/1*-kXKTNdqiVhB5y-8YB1oZw.png)\n\nThere are many things you’ll be able to do with a [quantum computer](https://hackernoon.com/tagged/quantum-computer). Messing around and doing something fun is one of them.\n\nOver the past few years, I have been one of the main misusers of quantum computers. Among my projects are [simple games](https://medium.com/@decodoku/the-history-of-games-for-quantum-computers-a1de98859b5a) and [quantum superpositions of smileys](https://medium.com/qiskit/making-a-quantum-computer-smile-cee86a6fc1de). Others have also done similar things, including [quantum music](https://soundcloud.com/alexiskirke/alexis-kirke-talks-quantum-on-futureproofing-bbc-radio-4). Together they demonstrate many ways to use this new [technology](https://hackernoon.com/tagged/technology) for something creative.\n\nSo I had an idea. I’d take the quantum heart of each of these projects, and abstract it out to a simple class or function in Python. This set of tools would then allow even more people to make even more creative quantum projects, without needing to worry about the technicalities of programming the devices themselves. It could provide an easy way for quantum novices to do quantum things for hackathons and game jams.\n\nI liked this idea, and thought about it quite a lot. It was a nice idea to think about. I didn’t actually _do_ anything about it, though. I needed something to spur me on. I needed a deadline. So I committed myself to making the first ever quantum game for the [Ludum Dare 42](https://ldjam.com/) game jam.\n\nOn the day before the game jam, I quickly hacked together some basic tools from my first few quantum games. The project had finally started! The [github repo](https://github.com/quantumjim/creative) had been made, and had more things in than just a README.\n\nThen I just needed to wait for the theme of the jam to be revealed. At the stroke of midnight, as Friday became Saturday, it came.\n\n!(https://pbs.twimg.com/media/DkRN1g4U8AAnrvg.jpg:large)\n\nThere was no way I could think of to make a ‘Running out of space’ game with any of my existing quantum tools, so I needed something new.\n\nWhen thinking about the word ‘space’, my mind quickly lept to ‘Hilbert space’. This is the space of possible states for the qubits in a quantum computer. Usually we start out with all our qubits set to `0`. So if we had 5 qubits, we'd start with the state `000000`. This is just a single point in the Hilbert space.\n\nA short quantum program can then start to explore nearby states, like the ones that differ on only a single bit: `0001`, `0010`, `00100,` etc. These states, as well as all the quantum superpositions of them that we can also create, form a small region within the Hilbert space. Then, as we make our program ever longer, we create more possible states and slowly explore more and more of the Hilbert space.\n\nThat’s basically the exact opposite of the theme for Ludum Dare 42. We are supposed to be running out of space, not expanding! So let’s run our programs in reverse. Start with something that can create crazy complicated quantum states, and then delete a few lines of quantum code from the end of it. Keep on doing this, and the output for our program will describe a slowly shrinking region of the Hilbert space.\n\nThat’s the basic quantum idea. Now how to make it into a game. To me, it lends itself quite natural to something like _Hunt the Wumpus_. This is an early precursor to games like the _Legend of Zelda_, where the player explores a labyrinth, trying to find a monster while avoiding dangers. With _Hunt the Wumpus_, it is all text based on the command line. That also suits me quite well, as I didn’t have enough time to do much in the way of graphics.\n\n!(https://hackernoon.com/hn-images/1*CJQMUGVsSYKVdCM-sIQspg.png)\n\nNow for the narrative. Quantum mechanics is famous for being a bit odd, and there are many interpretations of what is going on. A popular one is the [many worlds interpretation](https://en.wikipedia.org/wiki/Many-worlds_interpretation), which basically states that quantum superpositions should be thought of as parallel universes.\n\nI’m not convinced by this interpretation myself, but sci-fi has shown is time and time again that it makes for good storylines. So we’ll say that the large and complex quantum state we begin with represents a multiverse. As the program used to create it gets undone, this multiverse slowly collapses in on itself. If left to continue, only one universe would remain.\n\nThe player’s job is to save the multiverse! They must hop between neigbouring universes, avoiding ones that have collapsed, and trying to find the cause of the problem: the Quantpus. Once they find it, everything can be saved.\n\nWith this basic idea, I created the game (Actually I came up with the idea while making the game, resulting in dead-ends and spaghetti code. But reality doesn’t always make a good narrative.) The quantum program required was written as a new tool in my creative package. Like all the rest, it was written using the [QISKit](https://qiskit.org/) quantum SDK (which has [its own publication](https://medium.com/qiskit) here on Medium)\n\nI then ran many different instances of the quantum program on one of IBM’s [real prototype quantum devices](https://quantumexperience.ng.bluemix.net/qx/devices). The data from these runs was saved so that it could be used in the game, giving players the genuine experience of playing on a real quantum computer without them needing to bother setting up the connection. The rest of the program was then just normal Python for normal computers, handling all the inputs and outputs, victories and losses.\n\nThe final product is still quite raw and buggy, but there is a game in there somewhere. And it’s a game that actually runs on a quantum computer. I’m pretty confident in saying that Ludum Dare has never had one of them before. If you want to play it, check it out [here](https://www.pythonanywhere.com/gists/8b4bf629020b0dc11ecea09b73f57479/Running-out-of-Hilbert-space.py/ipython3/).