Strilanc / Quirk

A drag-and-drop quantum circuit simulator that runs in your browser. A toy for exploring and understanding small quantum circuits.
http://algassert.com/quirk
Apache License 2.0
933 stars 158 forks source link

Building A Fork of Quirk, Not Completely Sure how circuit gates are stored. #464

Closed abhobe closed 4 years ago

abhobe commented 4 years ago

I am building an extension of quirk which needs to check the order and type of gates in the circuit. How is this stored?

Strilanc commented 4 years ago

There is a class CircuitDefinition which has a list of columns, and each column has a list of positions that either contain a gate or nothing. Each gate has a height property that says how far down it extends from its starting position.

The relevant CircuitDefinition instances lives inside a DisplayedCircuit inside of a DisplayedInspector. The latest displayed inspector is inside an ObservableValue called displayed in main.