qcge


Nameqcge JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/devilkiller-ag/Quantum-Circuit-Game-Engine
SummaryA package that allows game developers to integrate quantum circuit in their pygame-based quantum games.
upload_time2023-10-29 18:24:05
maintainer
docs_urlNone
authorAshmit JaiSarita Gupta
requires_python
licenseMIT
keywords quantum circuit game engine quantum circuit pygame quantum circuit qcge quantum game pygame
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
![Quantum Circuit Game Engine](https://github.com/devilkiller-ag/Quantum-Circuit-Game-Engine/assets/43639341/dd998bca-c47b-44fd-8ed2-19724cbc57a2)

<h1>Quantum Circuit Game Engine for Pygame-based Quantum Games</h1>

This is a Quantum Circuit Game Engine for integrating Quantum Circuits into your Pygame-based quantum game. You can use it simply by creating an object of the `QuantumCircuitGrid` class stored in the `quantum_circuit.py` file.

This Quantum Circuit was originaly created for the **QPong Game** developed by <a href='https://huangjunye.github.io/' target='_blank'>Junye Huang</a> in the <a href="https://www.youtube.com/playlist?list=PLOFEBzvs-VvodTkP_rfrs3RWdeWE9aNRD" target='_blank'>12 Days of Qiskit Program</a>. I created this engine by re-writing its code located <a href='https://github.com/QPong/qpong-livestream' target='_blank'>here</a> to make it modular and abstract for easy use with any quantum game. 

The features I have included are:
- Modular and Abstract Code.
- All configurations in one place in the `config.py` file.
- Developers can create a Quantum Circuit for any number of qubit/wires and circuit width (max. number of gates which can be applied in a wire) of their choice. 
- Easy to change UI by replacing color configs and graphics for gates with those of your choice. 
- Easy to change the size of Quantum Circuit by adjusting `QUANTUM_CIRCUIT_TILE_SIZE`, `GATE_TILE_WIDTH`, and `GATE_TILE_HIEGHT` in the `config.py` file.
- Easily change controls by changing keys in the `handle_input()` method of the `QuantumCircuitGrid` class.


**If this project is helpful for you or you liked my work, consider supporting me through <a href="https://ko-fi.com/jaisarita" target="_blank">Ko.fi🍵</a>. Also, kindly consider giving a star to this repository.😁**

<!-- ------------------------------------------------------------------------- -->
<h2>About me</h2>

I am Ashmit JaiSarita Gupta, an Engineering Physics Undergraduate passionate about Quantum Computing, Machine Learning, UI/UX, and Web Development. I have worked on many projects in these fields, participated in hackathons, and am a part of great organizations in these fields. You can explore more about me, my work, and my experience at various organizations through my portfolio website: <a href='https://jaisarita.vercel.app/' target="_blank">https://jaisarita.vercel.app/</a> ☄️

<!-- ------------------------------------------------------------------------- -->
<h2>Installation</h2>

```bash
pip install qcge
```
<!-- ------------------------------------------------------------------------- -->
<h2>Usage</h2>

You can use it simply by creating an object of the `QuantumCircuitGrid` class stored in the `quantum_circuit.py` file. The constructor of `QuantumCircuitGrid` takes these values as argument:

- `position`: Position of the Quantum Circuit in the game window.
- `num_qubits`: Number of Qubits in the Quantum Circuit.
- `num_columns`: Circuit width (max. number of gates which can be applied in a wire) of their choice.
- `tile_size` (Optional, Default Value = 36): Size of single tile unit of the Quantum Circuit. It is the square area containing single gate in the quantum circuit.
- `gate_dimensions` (Optional Default Value = [24, 24]): [Width, Height] of quantum gates.
- `background_color` (Optional Default Value = '#444654'): Background Color of the Quantum Circuit.
- `wire_color` (Optional Default Value = '#ffffff'): Color of Quantum Wire in the Quantum Circuit.
- `gate_phase_angle_color` (Optional Default Value = '#97ad40'): Color to represent phase angle of Rotation Gates.

You can run your quantum circuit on BasicAer Simulator by using this function:
```python
def run_quantum_circuit(self, quantum_circuit):
        simulator = BasicAer.get_backend("statevector_simulator")
        quantum_circuit.measure_all()
        transpiled_circuit = transpile(quantum_circuit, simulator)
        counts = simulator.run(transpiled_circuit, shots=1).result().get_counts()
        measured_state = int(list(counts.keys())[0], 2)
        return measured_state
```

<!-- ------------------------------------------------------------------------- -->
<h2>Configurations</h2>

All the configurations for Quantum Circuit can be done in the `config.py` file. The controls of the quantum circuit in the game can be changed from the defaults mentioned below by changing keys in the `handle_input()` method of the `QuantumCircuitGrid` class.

- You can change the size of Quantum Circuit by passing optional parameters `tile_size`, and `gate_dimensions` (= [GATE_TILE_WIDTH, GATE_TILE_HIEGHT]) to the `qcge.QuantumCircuitGrid` class as parameters.
- You can change UI colors by passing optional parameters `background_color`, `wire_color`, and `gate_phase_angle_color` to the `qcge.QuantumCircuitGrid` class as parameters.

Default values of these optional parameter are:
```python
tile_size = 36
gate_dimensions = [24, 24]
background_color = '#444654'
wire_color = '#ffffff'
gate_phase_angle_color = '#97ad40'
```

<!-- ------------------------------------------------------------------------- -->
<h2>Game Controls for Building Quantum Circuit</h2>

- **W, A, S, D Keys:** Move the "Circuit Cursor" in the Quantum Circuit to the place where you want to add a gate in the circuit.
- **Backspace Key:** Remove the gate present at the Circuit Cursor.
- **Delete Key:** Clear the Quantum Circuit, i.e., remove all gates from the Quantum Circuit.
- **X Key:** Add X Gate to the quantum circuit.
- **Y Key:** Add Y Gate to the quantum circuit.
- **Z Key:** Add Z Gate to the quantum circuit.
- **H Key:** Add H Gate to the quantum circuit.
- **C, R, E Keys:** Press **C Key** to convert the X, Y, Z, or H gates into CX, CY, CZ, and CH gates respectively, and then press **R Key** and **F Key** to the control to qubit above or below respectively.
- **Q and E Keys:** To convert X, Y, and Z into RX, RY, and RZ gates respectively. **Q Key** decreases the rotation angle by π/8 and **E Key** increases the rotation angle by π/8.

<!-- ------------------------------------------------------------------------- -->

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/devilkiller-ag/Quantum-Circuit-Game-Engine",
    "name": "qcge",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "quantum circuit game engine,quantum circuit pygame,quantum circuit,qcge,quantum game,pygame",
    "author": "Ashmit JaiSarita Gupta",
    "author_email": "ashmitgupta.social@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/18/fa/24b41f5d7146e138276738dcd47d236c9e8983356d9b18ec152f01d672f5/qcge-1.0.1.tar.gz",
    "platform": null,
    "description": "\n![Quantum Circuit Game Engine](https://github.com/devilkiller-ag/Quantum-Circuit-Game-Engine/assets/43639341/dd998bca-c47b-44fd-8ed2-19724cbc57a2)\n\n<h1>Quantum Circuit Game Engine for Pygame-based Quantum Games</h1>\n\nThis is a Quantum Circuit Game Engine for integrating Quantum Circuits into your Pygame-based quantum game. You can use it simply by creating an object of the `QuantumCircuitGrid` class stored in the `quantum_circuit.py` file.\n\nThis Quantum Circuit was originaly created for the **QPong Game** developed by <a href='https://huangjunye.github.io/' target='_blank'>Junye Huang</a> in the <a href=\"https://www.youtube.com/playlist?list=PLOFEBzvs-VvodTkP_rfrs3RWdeWE9aNRD\" target='_blank'>12 Days of Qiskit Program</a>. I created this engine by re-writing its code located <a href='https://github.com/QPong/qpong-livestream' target='_blank'>here</a> to make it modular and abstract for easy use with any quantum game. \n\nThe features I have included are:\n- Modular and Abstract Code.\n- All configurations in one place in the `config.py` file.\n- Developers can create a Quantum Circuit for any number of qubit/wires and circuit width (max. number of gates which can be applied in a wire) of their choice. \n- Easy to change UI by replacing color configs and graphics for gates with those of your choice. \n- Easy to change the size of Quantum Circuit by adjusting `QUANTUM_CIRCUIT_TILE_SIZE`, `GATE_TILE_WIDTH`, and `GATE_TILE_HIEGHT` in the `config.py` file.\n- Easily change controls by changing keys in the `handle_input()` method of the `QuantumCircuitGrid` class.\n\n\n**If this project is helpful for you or you liked my work, consider supporting me through <a href=\"https://ko-fi.com/jaisarita\" target=\"_blank\">Ko.fi\ud83c\udf75</a>. Also, kindly consider giving a star to this repository.\ud83d\ude01**\n\n<!-- ------------------------------------------------------------------------- -->\n<h2>About me</h2>\n\nI am Ashmit JaiSarita Gupta, an Engineering Physics Undergraduate passionate about Quantum Computing, Machine Learning, UI/UX, and Web Development. I have worked on many projects in these fields, participated in hackathons, and am a part of great organizations in these fields. You can explore more about me, my work, and my experience at various organizations through my portfolio website: <a href='https://jaisarita.vercel.app/' target=\"_blank\">https://jaisarita.vercel.app/</a> \u2604\ufe0f\n\n<!-- ------------------------------------------------------------------------- -->\n<h2>Installation</h2>\n\n```bash\npip install qcge\n```\n<!-- ------------------------------------------------------------------------- -->\n<h2>Usage</h2>\n\nYou can use it simply by creating an object of the `QuantumCircuitGrid` class stored in the `quantum_circuit.py` file. The constructor of `QuantumCircuitGrid` takes these values as argument:\n\n- `position`: Position of the Quantum Circuit in the game window.\n- `num_qubits`: Number of Qubits in the Quantum Circuit.\n- `num_columns`: Circuit width (max. number of gates which can be applied in a wire) of their choice.\n- `tile_size` (Optional, Default Value = 36): Size of single tile unit of the Quantum Circuit. It is the square area containing single gate in the quantum circuit.\n- `gate_dimensions` (Optional Default Value = [24, 24]): [Width, Height] of quantum gates.\n- `background_color` (Optional Default Value = '#444654'): Background Color of the Quantum Circuit.\n- `wire_color` (Optional Default Value = '#ffffff'): Color of Quantum Wire in the Quantum Circuit.\n- `gate_phase_angle_color` (Optional Default Value = '#97ad40'): Color to represent phase angle of Rotation Gates.\n\nYou can run your quantum circuit on BasicAer Simulator by using this function:\n```python\ndef run_quantum_circuit(self, quantum_circuit):\n        simulator = BasicAer.get_backend(\"statevector_simulator\")\n        quantum_circuit.measure_all()\n        transpiled_circuit = transpile(quantum_circuit, simulator)\n        counts = simulator.run(transpiled_circuit, shots=1).result().get_counts()\n        measured_state = int(list(counts.keys())[0], 2)\n        return measured_state\n```\n\n<!-- ------------------------------------------------------------------------- -->\n<h2>Configurations</h2>\n\nAll the configurations for Quantum Circuit can be done in the `config.py` file. The controls of the quantum circuit in the game can be changed from the defaults mentioned below by changing keys in the `handle_input()` method of the `QuantumCircuitGrid` class.\n\n- You can change the size of Quantum Circuit by passing optional parameters `tile_size`, and `gate_dimensions` (= [GATE_TILE_WIDTH, GATE_TILE_HIEGHT]) to the `qcge.QuantumCircuitGrid` class as parameters.\n- You can change UI colors by passing optional parameters `background_color`, `wire_color`, and `gate_phase_angle_color` to the `qcge.QuantumCircuitGrid` class as parameters.\n\nDefault values of these optional parameter are:\n```python\ntile_size = 36\ngate_dimensions = [24, 24]\nbackground_color = '#444654'\nwire_color = '#ffffff'\ngate_phase_angle_color = '#97ad40'\n```\n\n<!-- ------------------------------------------------------------------------- -->\n<h2>Game Controls for Building Quantum Circuit</h2>\n\n- **W, A, S, D Keys:** Move the \"Circuit Cursor\" in the Quantum Circuit to the place where you want to add a gate in the circuit.\n- **Backspace Key:** Remove the gate present at the Circuit Cursor.\n- **Delete Key:** Clear the Quantum Circuit, i.e., remove all gates from the Quantum Circuit.\n- **X Key:** Add X Gate to the quantum circuit.\n- **Y Key:** Add Y Gate to the quantum circuit.\n- **Z Key:** Add Z Gate to the quantum circuit.\n- **H Key:** Add H Gate to the quantum circuit.\n- **C, R, E Keys:** Press **C Key** to convert the X, Y, Z, or H gates into CX, CY, CZ, and CH gates respectively, and then press **R Key** and **F Key** to the control to qubit above or below respectively.\n- **Q and E Keys:** To convert X, Y, and Z into RX, RY, and RZ gates respectively. **Q Key** decreases the rotation angle by \u03c0/8 and **E Key** increases the rotation angle by \u03c0/8.\n\n<!-- ------------------------------------------------------------------------- -->\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package that allows game developers to integrate quantum circuit in their pygame-based quantum games.",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/devilkiller-ag/Quantum-Circuit-Game-Engine"
    },
    "split_keywords": [
        "quantum circuit game engine",
        "quantum circuit pygame",
        "quantum circuit",
        "qcge",
        "quantum game",
        "pygame"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b233858b84bc66fe785a102040bea5026582fd686e6bc5aeccd2180f3bf8753",
                "md5": "03a19ad704ab2c62377596bd4260fd1b",
                "sha256": "399dd8f0ec643b3ae6ec59ee618fc7b897255a206d35a638303ed1bde4028461"
            },
            "downloads": -1,
            "filename": "qcge-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "03a19ad704ab2c62377596bd4260fd1b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4318,
            "upload_time": "2023-10-29T18:24:03",
            "upload_time_iso_8601": "2023-10-29T18:24:03.918177Z",
            "url": "https://files.pythonhosted.org/packages/8b/23/3858b84bc66fe785a102040bea5026582fd686e6bc5aeccd2180f3bf8753/qcge-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "18fa24b41f5d7146e138276738dcd47d236c9e8983356d9b18ec152f01d672f5",
                "md5": "329c61a1eb7a629afb7b81d5ca6335dd",
                "sha256": "1e66f0e15d8b9aa20ed0124f8befadab50cf86ae2f3138d5b15c12d0dc8d9b0d"
            },
            "downloads": -1,
            "filename": "qcge-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "329c61a1eb7a629afb7b81d5ca6335dd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4461,
            "upload_time": "2023-10-29T18:24:05",
            "upload_time_iso_8601": "2023-10-29T18:24:05.752904Z",
            "url": "https://files.pythonhosted.org/packages/18/fa/24b41f5d7146e138276738dcd47d236c9e8983356d9b18ec152f01d672f5/qcge-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-29 18:24:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "devilkiller-ag",
    "github_project": "Quantum-Circuit-Game-Engine",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "qcge"
}
        
Elapsed time: 0.13887s