Giter VIP home page Giter VIP logo

quantris's Introduction

Quantris

Welcome to the Quantris repository! It has all the main mechanics of the original game (rotations, dropping, line clears), with additional functionality (each piece represents a quantum gate operator on the quantum state, which the user needs to utilize to meet the objectives).

To play Quatris using the web version: http://quantris.pages.dev

To see a video demonstration: https://www.youtube.com/watch?v=_Uonyu2nNHg

Game Documentation

This will go through all the controls and main functions to better understand the game from a user's perspective.

Controls

  • Up/down: move the piece up/down
  • Left: make the piece fall faster
  • Right: drop piece
  • X/Z: rotate the piece clockwise/counterclockwise
  • R: restart

Game Functions

  • Measurement: It will check if the observed pieces are measured with the same probabilities as the desired state, ignoring all phase factors. The game will clear all pieces to the left of the measurement, rewarding the player with 10 points each.
  • Clear Lines: It will clear a line if filled, rewarding 100, 300, 500, and 800 points for a single, double, triple, and quadruple clear, respectively.
  • Falling Piece: The piece will fall one block every second without the left arrow pressed and once every 1/5 second with the left arrow pressed.
  • Rotation: The piece will rotate according to the official Tetromino shape locations using the SRS kickback system.
  • Lose Condition: The game will be lost if the measurement is incorrect or a piece is placed out of bounds.
  • Piece Generation: A new piece will be generated, with a control gate or anti-control (50/50 chance) in a set location for each piece (the I piece never gets either because the control gate would have nothing to point to on a sideways I), and with otherwise completely random gates.

Game Archetecture Notes

  • All Peicies are an entity with a location rather than an array grid.
  • All locations are tracked through the entity's properties, then updated using the update_block_transforms, hide_outside_blocks, and move_control_wires methods.
  • Entities are never regenerated; each entity will last the lifetime of each block it represents rather than being respawned at some point.
  • The only difference between a falling and stationary block is in the Piece attribute.

Quantum Simulation Notes

  • Calculating the probability of measuring a certain outcome of a subset of n qbits in the HV basis is done by looping over every state in the vector, then adding the norm squared of each state in the 2^Y_COUNT state vector to a smaller 2^n state vector, where the location in the vector is just the location in the larger 2^Y_COUNT while removing the bits that are not in the subset of n qbits.
  • Calculating the 2^Y_COUNT dimensional vector representing the state at position x is done by multiplying the initial state by the quantum operator of each column<=x.
  • Calculating the 2^Y_COUNTx2^Y_COUNT quantum operator of each row is done with the tensor product (which is calculated using the nalgebra kronecker product) of every operator in that column. If there is no operator, then it will be multiplied by the identity matrix. If an operator is next to a control or anticontrol gate that is connected to the operator, then it transforms the 2x2 gate matrix to the 4x4 control gate matrix and uses that 4x4 controlled gate matrix as the matrix to represent the single gate. Control gates themselves are skipped over.

Current Hotfixes

Developer Notes

Run: cargo run

Build for web:

  cargo build --release --target wasm32-unknown-unknown
  wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/quantris.wasm

quantris's People

Contributors

alistairkeiller avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.