ENGINEERING DEEP-DIVE · C++17 · QUANTUM++ / EIGEN
Real quantum simulation for game combat, in C++ and proven statistically.
In my game Moon-Knight, I designed combat mechanics that were built on quantum computing principles trying to demonstrate how this technology could change this media. At the beginning I only designed them and couldn't code them, but I started programming this combat system using a C++17 library that wraps Quantum++ and Eigen that models qubits, gates, measurements, and noise. It then exposes an API so designers could tune them without knowing what quantum computing is.This page is the engineering behind the design.
The primary decision of the whole toolkit is that the core register stores a density matrix and not a state vector. Because a state vector can only represent pure states and my mechanics, like Instability, require decoherence: a sphere whose outcome is randomised the longer it stays in flight. A density matrix is the only thing that could express a partially mixed state.
01 · Design to physics
As a designer, when I developed the abilities I wanted to say 'this sphere is 70% likely to amplify.' However, when I started this work, I needed a Ry rotation angle. The connection between these two is to give a probability p that returns the angle that measures the outcome and matches it to p. The design works in the sense that the projectile is undecided between four effects while it is cast and the environmental noise is a flat 25/25/25/25 as long as it is cast.
02 · The physics
The sphere decays through real quantum noise that was coded from actual physics. When it's measured the outcome is a genuine collapse. It locks the outcome on purpose instead of creating randomness, without breaking video game rules.
03 · The proof
What differentiates my designed quantum inspired mechanics from this work is that it is measurable. Each ability is validated by a Monte Carlo control. It runs a thousand times and checks the frequency and compares it to the analytic prediction. The parry mechanic, Inversion, rotates an attack Damage parameter with a Heal, using a NOT gate at the right time, so it follows the Born rule. The endpoints are deterministic and the interior points land within one or two standard errors of sin squared.
Status
The toolkit is about the Moon-Knight's five designed mechanics. The core library and two of the five are complete and statistically verified. The third one is in progress still. Two are designed but not yet built. Every finished mechanic is a recombination of the same verified mechanics, so the remaining work is just composition.
The engineering side of the project. The limitations of Blueprints translated into C++ and the main code choices. The combat state machine, the data-driven layer and the quantum C++ engine limits.
Click here · Back to the engineering write-up Back to the design projectThe design project: video gameplays, the five quantum abilities, the type of enemies, the control scheme, the world of Kaelum and the beat chart the game was planned with.
Click here · Back to Moon-Knight