Skip to content
Glen Evenbly edited this page Jun 19, 2024 · 40 revisions
Construction Phase

A puzzle/construction game about manipulating qubits (quantum bits) to solve challenges involving quantum technology and computation. Play in your browser at www.qubitfactory.io.

View the YouTube videos:

Read the corresponding arXiv preprint.

About:

The Qubit Factory is a Zachtronics-style puzzle game about quantum computing. During the game users are challenged to construct circuits in order to manipulate bits and qubits (quantum bits) to find creative solutions to computational tasks, with an emphasis on distinguishing how qubits differ from the familiar bits used in regular computers. The game mechanics are based around authentic quantum theory, components, algorithms and protocols (many of which are vital to the construction and utilization of present-day quantum devices), with the goal of allowing users to gain some (scientifically accurate!) understanding of quantum technology. The Qubit Factory is intended to be a fun and engaging experience that is accessible to those without a prior background in quantum. However, towards the later levels, it will also to provide a significant challenge (and a useful educational resource) to quantum students throughout undergraduate, graduate and post-graduate educational levels.

Controls:

The Qubit Factory can controlled via mouse/trackpad or in combination with keyboard. Below is an overview of the controls during factory construction (controls reference can also be accessed in-game by pressing F1 or through the 'employee handbook'):

  • Select, place, interact with objects: LMB.
  • Erase objects:RMB (or E key then LMB).
  • Rotate gate (while placing): Mouse-scroll (or ◀︎/▶︎ keys).
  • Toggle control-gate states: Double-LMB (or ALT/OPT+LMB).
  • Copy gate(s): SHIFT+LMB (+drag to select larger region).
  • Cut gate(s): CTRL/CMD+LMB (+drag to select larger region).
  • Undo/redo last action: Z/X keys.
  • Select last/next available gate from menu: Q/W keys:.
  • Gate hotkeys (rows 1,2,3): [1-6], SHIFT+[1-6], CTRL+[1-6].
  • Copy factory layout to clipboard: CTRL+C (while in a level).
  • Paste factory from clipboard: CTRL+V (while in a level) .
  • Copy save-file to clipboard: CTRL+C (while in the level select).
  • Paste save-file from clipboard: CTRL+V (while in the level select).

Layout Reference:

During gameplay, the user alternates between phases of constructing factories and then operating them. An overview of these UI interfaces is given below:

Construction Phase

During factory construction the main features that players interact with are:

  • gate selection: for selecting object to place (see Gate hotkeys).
  • eraser tool: for clearing gates and wires (alternative: Right-click or E key).
  • blueprint selection: for storing/selecting different factory designs.
  • undo/redo buttons (alternative: Z and X keys).
  • power-on factory: for beginning factory operation.
Operating Phase

During factory operation players mainly interact with the 5 bottom-center factory control buttons:

  • power-off: reset the factory and return to construction phase.
  • slow-down: reduce factory speed by 0.5x (switches to step-back if paused).
  • pause / resume factory.
  • speed-up: increase factory speed by 2x (switches to step-forward if paused).
  • reset speed: return factory to default speed.

Physics Restrictions:

The Qubit Factory provides accurate simulation of quantum/classical circuits (barring a few small exceptions). However, in order to strike a balance with maintaining accessibility, several restrictions were artificially imposed on the scope of allowed operations and calculations such that, although accurate, it is not a complete quantum circuit simulator (à la something like Quirk). For those familiar with quantum theory, these restrictions include:

  • allowing only real-valued states (i.e. no complex phases).
  • allowing only pure states (i.e. no mixed states).
  • allowing rotation/flip gates only to act at discrete angles in increments of π/8.
  • allowing groups no larger than 6 qubits to be entangled together. Attempting to entangle larger groups will result in the some of the qubits spontaneously decohering.
  • allowing superposition only between spin states of qubits (i.e. no superpositions of a qubit between different spatial locations).

However, despite these limitations, very many important quantum concepts, protocols and algorithms can still be accurately represented in The Qubit Factory including quantum state tomography, quantum error correction, entanglement distillation, quantum repeaters, quantum teleportation, super-dense coding, the Bernstein–Vazirani algorithm and much more!

Notation:

The Qubit Factory is intended to be accessible to users without prior knowledge of quantum circuits, thus it makes use of symbolic representations rather than standard technical circuit notation; here we provide a guide illustrating the connection between the two different representations for those already familiar with the latter (see also the arXiv preprint for additional details). Note that the gates used in The Qubit Factory are also explained in-game via the 'Employee Handbook'.


Flip Gates Fig.1 - (Top) Circuit notation for Z Pauli, X Pauli and Hadamard gates.
(Bottom) Equivalent gates from The Qubit Factory are implemented via setting the `flip` gate along the appropriate axis.

Rotation Gates Fig.2 - (Top) Circuit notation for Y rotations through various angles.
(Bottom) Equivalent rotations in The Qubit Factory can be enacted via setting the 'rotation' gate to the appropriate angle.

Control Gates Fig.3 - (Top) Circuit notation for Controlled Not (CNOT), Controlled Z (CZ), and a CNOT sandwiched between Hadamard gates, such the the control is acting in the X-basis.
(Bottom) Equivalent controlled gates in The Qubit Factory. Notice the the basis in which the control acts can be set directly, thus avoiding the need for additional gates when the control does not act in the Z-basis.

Measurements Fig.4 - (Top) Circuit notation for a Z-basis and X-basis (i.e. Hadamard then Z-basis) measurements. Both measurements produce as output a classical bit (double-line).
(Bottom) Equivalent measurements in The Qubit Factory, where the basis of the measurement corresponds to the orientation of the slit. Both a classical bit (blue) as well as the measured qubits are given as output.

Teleportation Fig.5 - (Top) Circuit notation for an implmentation of the quantum teleportation protocol.
(Bottom) An equivalent circuit in The Qubit Factory, which includes 'incinerators' (denoted by fire icons) that function to remove bits/qubits that are no longer needed.

FAQs:

How was The Qubit Factory made? Did you use game-making software or some other framework?

  • Glen Evenbly: The game was written using vanilla javascript (and is my first significant project in javascript), and uses SVG-based graphics on the HTML5 canvas. In my job as a research scientist I otherwise usually program in Python or Julia.

Why are Chrome/Edge/Brave/Opera suggested as the preferred browsers for QubitFactory? Why are Firefox/Safari not preferred?

  • The game was mostly developed/tested on Chrome, so Chrome (or other Chromium-based browsers) should offer the best experience. Limited testing was done on Firefox/Safari (and some browser specific compatibility issues were resolved) so QubitFactory should be, to our best knowledge, still fully functional on these other browsers.
  • Prior to early 2024 the Firefox did not support the readText method, so pre-2024 versions of Firefox will not support the CTRL-V functionality to paste a level / save-file from the clipboard.
  • QubitFactory appears to be more performant on Chromium (steadily maintaining 120fps on macbook or windows laptop/desktop), while giving lower fps when using Firefox/Safari on the same hardware. The reasons for this are not obvious, but some limited benchmarking revealed that certain operations involving the HTML5 canvas were more than 100x slower on Firefox/Safari than on Chromium. Switching to the 'simple' graphics mode in the options menu (which removes much of the gradients/shadows/transparencies) can boost performance if this is an issue.
  • Glen Evenbly: While trying to get things to work properly on Safari the "Why can't you just be normal!" meme sprung to mind more than once.

What inspired the development of The Qubit Factory?

  • Glen Evenbly: One of my favorite PC games from childhood was The Incredible Machine, a 1993 puzzle game about building Rube-Goldberg style machines in order to solve various tasks. Since then, this genre of game has seen quite a modern resurgence due to awesome developers like Zachtronics. The aspect of these games that I personally enjoy most is, given a small set of tools and components, in finding a creative solution to an open-ended task (which is also why I enjoy being a research scientist!). So for a while I had been considering making my own version of such a game, and basing the game on quantum computation was a natural choice for me (and is a topic that I am eager about promoting). Also, having taught quantum mechanics at both college undergraduate and graduate-level, I was motivated to try to build a tool that could help facilitate a more intuitive understanding of this otherwise very counter-intuitive topic; one that I would have found useful while teaching.

A common feature in Zachtronics games is, upon completion of a level, to present players with statistics comparing their solution against the aggregate of other players solutions (e.g. in terms of time taken or total space used). Could a similar feature be implemented in QubitFactory?

  • This feature, while certainly desirable, adds many additional complications such that it is unlikely to be implemented. Currently QubitFactory is only client-side javascript; implementing this feature would require a server-side component to collect and aggregate data (as well the code to communicate with said server).

Do you have other recommendations for quantum-inspired games?

  • The Quantum Flytrap is an interesting puzzle game based on an accurate realization of quantum optics. Many other quantum games and activities can be found here.

Where did you get the music for the game?

Where did you get the graphics for the game?

  • Most of the graphics were made from scratch using SVG paths, but some of the background textures are from SVGbackgrounds.com.

Why is the javascript code minified?

  • Glen Evenbly: Ostensibly this is in order to make the game load slightly faster. In practice this may also be because the codebase is an embarrassing mess and I was not inclined to do a major refactor. I would be amenable to releasing the full code if enough people were interested, but I imagine that it would be difficult for anyone to work with.

Gameplay FAQs:

Can the game be changed such that the bonus star criteria is displayed at the start of each level?

  • Glen Evenbly: This was something that was requested during the beta testing. However, after some thought, I decided to keep it such that the bonus star criteria is displayed only when the factory is powered on (noting that players can power-on the factory whenever they like). In many cases finding a solution that earns the bonus-star is significantly more difficult than a regular solution, such that I believe that it often makes more sense for the player to attempt the regular solution first before attempting the bonus challenge.

How is priority determined when multiple bits/qubits are attempting to enter the same tile?

  • For the case of wire crossings there is no set priority (but bits that moved during the previous tick will generally have priority over those that were stationary). For the case of (bit or qubit) combiners priority is given to inputs clockwise from the output direction.

Can the qubits within an entangled state be reordered?

  • Yes (although this was a late addition so is not documented within the game itself). Pressing the left/right arrow keys after selecting a qubit will decrement/increment its order within an entangled state.

Troubleshooting:

Encounter a bug or have suggestions for improvements? Either open an issue on the repo or email [email protected].

If you encounter a crash then a solution could be to check that your browser is up-to-date (since The Qubit Factory makes use of some Javascript features that may not be compatible with older browser versions). When reporting a crash it would be helpful if you could include the error message output to the browser console (usually accessed by F12).

If you are experiencing low frame rates then please try switching to the 'simple graphics' setting from the options menu, which removes much of the gradient / transparency effects in order to improve performance (see also the FAQ).

Disclaimer:

The Qubit Factory is set within a fictional reality about robots doing robotty things in a robot factory. The character dialog contained within, written wholly by developer Glen Evenbly, is intended to be humorous and satirical. The opinions, views and practices of characters from within The Qubit Factory do not reflect those of the developers or the developers' employer.

License:

The Qubit Factory is licensed under Apache 2.0.