# Introducing QLogic : A Quantum Computing Puzzle Game

QLogic is a puzzle game based on quantum bits and the logic gates that are commonly used to develop quantum computing algorithms.

The field of Quantum Computing is pretty counter-intuitive when one starts off in it. While the current technology is flooded with bits that can be 0 or 1 (off or on), quantum computing is all about bits that can be in a 0 state and a 1 state at the same time!

And entering into quantum computing, we immediately start performing mathematical operations on these qubits.

To make the introduction to quantum computing smooth, we developed QLogic, a puzzle game based on quantum bits(qubits) and the logic gates that are commonly used to develop quantum computing algorithms. QLogic abstracts the math and lets a player solve the puzzles purely using intuition, without tackling the complexities of the field.

The game is simple- given qubits in some initial state, the goal is to take them to a target state. The player can select a gate and apply it to any qubit to achieve a state transition. To make things exciting, players are given stars for their solution in each level. Different kinds of levels base stars on different factors- levels based on moves reward you to reach the target state in as few moves as possible. On the other hand, timed levels require you to achieve the final state as fast as possible.

What sets QLogic apart

- Real-time states: Most quantum circuit platforms let a user complete a circuit, and only after hitting run does the user get to know the result. This isn’t the case with QLogic, which shows the states of qubits in real-time. This is possible because we run the algorithms on the qubits in real time to constantly update the state.
- Puzzles: On a circuit-building platform, users need an experiment that they wish to learn. At an initial stage of learning, it is often difficult to design new experiments or understand existing ones to run and draw conclusions. QLogic omits the need to have an experiment in mind and lets the player get acquainted with simulating circuits through puzzles.

## Game Modes

QLogic also offers a Time Attack mode, where the user needs to achieve as many unique states as possible within a time limit. This is a more casual and thrill-based mode that the users can play and aim for high-scores without having to worry too much about the number of gates they apply or about having to get to a target state. Players can play with 2 or 3 qubits, with 60 and 90 seconds respectively.

There is also a playground within the game, which once again stands out from other circuit-building platforms by showing the current state at every step. Again, the player can play around with 1, 2 or 3 qubits, with no time limit or move counter.

## Tech Stack and Code Design

Since QLogic is a game, our first instinct was to use the Unity3D game engine to develop this game. However, another aspect to keep in mind was that the game does not contain too many moving components, which was why we went with React Native for the development. Having chosen React Native, there were certain challenges that we had to overcome, one of which was to implement the animations correctly, since animations in React Native are not as developed as those in Unity.

Another tough decision was to design the code well, so that it was easy to create and add many levels. To do so, we created a json file for the levels, where the details for each level are mentioned. With this design, it is very easy to add levels, without even looking at the actual code. One huge advantage with this sort of design is that we can later let even players create their levels, a feature that we soon plan to incorporate in the game!

## Functioning

An interesting aspect about QLogic is the fact that the code is written for any general state that the qubits might be in. In Quantum computing, there are entangled states, where the qubits start having dependencies on each other. In such a case, our algorithms make sure that we take into account that such situations may arise and handle them accordingly.

Moreover, even control gates are generated using an algorithm to create a matrix so as to generalize the process for whichever qubit is chosen as the control and whichever one is chosen as a target. As a result, we don’t have to worry about having to generate controlled gates for any basic gate. The same code can be used for CX, CZ, CH, or any other gate that may be added in the future.

This entire design for the gates was not easy to come up with. We had to understand the physics behind different possibilities of a control gate- if the control bit and target bit are not adjacent, if the control bit has a larger index than the target bit, etc. However, now that we have generalized the algorithm, we can add qubits to the game without worrying about the control gates. Although there are no more than 3 qubits in any mode of the game, our algorithms would work for any number of qubits!

## Upcoming Features

We are working on an advanced mode that users can enable, for users interested in the more mathematical aspects of quantum computing. We’re also working towards adding more gates and loads of challenging levels!

Do try out the game on the android store and follow us on Instagram and Twitter for latest updates! If you have feedback/suggestions on the game, you can get in touch directly with the QLogic team via our Telegram group.

*This entry was featured in the August edition of the Tech on Campus newsletter. You can read it here.*