An educational tower defense game that brings quantum computing concepts to life using IBM's Qiskit SDK. Experience real quantum mechanics through engaging gameplay where enemies exist in superposition and collapse when measured!
- Overview
- Key Features
- Game Mechanics
- Quantum Concepts
- Installation
- How to Play
- Tower Types
- Enemy Types
- Controls
- Game Strategy
- Technical Architecture
- Contributing
- License
Quantum Tower Defense is an innovative educational game that bridges quantum computing and gaming. Built with IBM Qiskit and Pygame, it transforms abstract quantum mechanics into tangible gameplay mechanics. Enemies exist in quantum superposition across multiple paths simultaneously until observed, creating unique strategic challenges based on real quantum phenomena.
Educational Purpose: Learn quantum computing concepts like superposition, entanglement, measurement, and phase shifts through interactive gameplay.
Target Audience: Students, educators, quantum computing enthusiasts, and gamers interested in science.
- โ๏ธ Real Quantum Circuits: Uses actual Qiskit quantum circuits
- ๐ Superposition States: Enemies exist on multiple paths with probability amplitudes
- ๐ Wave Function Collapse: Measurement towers collapse superposition to definite states
- ๐ Quantum Entanglement: Enemy pairs share quantum states and damage
- ๐ Phase Manipulation: Rotate probability distributions using quantum gates
- ๐ก Quantum Teleportation: Transfer damage through entangled states
- ๐ฎ 4 Unique Tower Types: Each represents a different quantum operation
- ๐พ 2 Enemy Types: Standard enemies and entangled enemy pairs
- ๐ Progressive Difficulty: 6+ waves with increasing complexity
- ๐ฐ Resource Management: Balance money, lives, and quantum coherence
- โจ Visual Effects: Beautiful quantum operation animations
- ๐๏ธ Tower Removal: Right-click and DELETE/BACKSPACE to remove towers (50% refund)
- ๐ In-Game Tutorial: Learn as you play with helpful tooltips
- Enemy Spawning: Enemies spawn in quantum superposition across 4 paths
- Superposition Movement: Enemies progress along ALL paths simultaneously
- Tower Placement: Strategically place towers to measure, manipulate, or damage enemies
- Measurement: When measured, enemies collapse to a single path
- Defense: Prevent enemies from reaching the end to protect your base
๐ต Money
- Starting amount: $400
- Earn money by defeating enemies
- Spend on towers ($100-$250 each)
- Get 50% refund when removing towers
โค๏ธ Lives
- Starting lives: 20
- Lose 1 life per enemy that reaches the end
- Game over at 0 lives
๐ Quantum Coherence
- Starting coherence: 10.0 units
- Maximum: 20.0 units
- Regenerates at 0.1 units/second
- Lost when enemies spawn in superposition
- Required for maintaining quantum states
The game features 4 distinct paths representing the computational basis states:
- Path 0 (|00โฉ): Top route
- Path 1 (|01โฉ): Upper-middle route
- Path 2 (|10โฉ): Lower-middle route
- Path 3 (|11โฉ): Bottom route
Each enemy starts in equal superposition: |ฯโฉ = ยฝ(|00โฉ + |01โฉ + |10โฉ + |11โฉ)
A quantum system existing in multiple states simultaneously. In the game, enemies appear semi-transparent on all 4 paths at once, with each path having a probability amplitude.
Quantum Circuit: Hadamard gates create equal superposition:
H gate: |0โฉ โ (|0โฉ + |1โฉ)/โ2
Result: (|00โฉ + |01โฉ + |10โฉ + |11โฉ)/2
Observing a quantum system forces it into a definite state. Measurement towers collapse enemy superposition to one path based on probability distribution.
Two particles become correlated; measuring one affects the other. Entanglement towers link enemies so damage to one is shared with its partner (50% transfer).
Rotating the phase of probability amplitudes to change probability distribution. Phase towers reduce the probability of enemies being on specific paths.
Transferring quantum states using entanglement. Teleportation towers transfer damage instantly across the map.
Quantum states degrading due to environmental interaction. Represented by the quantum coherence resource that decreases over time.
- Python: 3.9 or higher
- pip: Package manager
- Operating System: Windows, macOS, or Linux
- RAM: 4GB minimum
# 1. Clone the repository
git clone https://github.com/N-Garai/Quantum-tower-defence.git
cd Quantum-tower-defence
# 2. Create virtual environment
python -m venv venv
# 3. Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# 4. Install dependencies
pip install -r requirements.txt
# 5. Run the game
python main.py- qiskit 1.0.0: Quantum computing framework
- qiskit-aer 0.13.3: Quantum circuit simulator
- pygame 2.5.2: Game development
- numpy 1.26.0: Numerical computing
- matplotlib 3.8.0: Visualization
- Launch the game:
python main.py - Main menu appears
- Press SPACE to start or T to toggle tutorial
- Game begins in wave preparation mode
Survive all waves by preventing enemies from reaching the end of paths!
- Protect your base (20 lives)
- Defeat enemies to earn money
- Build towers strategically
- Manage quantum coherence wisely
-
Preparation Phase
- Place towers before wave starts
- Check resources (money & coherence)
-
Wave Phase
- Enemies spawn in superposition
- Towers automatically engage enemies
- Monitor progress on all paths
- Watch for entangled pairs (purple link)
-
Between Waves
- Collect rewards from defeated enemies
- Reposition towers
- Prepare for next wave
- Press SPACE to start next wave
-
Victory or Defeat
- Victory: Survive all waves with lives remaining
- Defeat: All lives lost
- Press R to restart
Cost: $100 | Hotkey: 1 | Range: 150px | Damage: 20/sec
Function: Collapses enemy superposition to single path
Strategy:
- Place near path intersections
- Essential for dealing damage
- Cheapest tower - good for early game
- Use multiple towers for continuous measurement
Cost: $150 | Hotkey: 2 | Range: 120px | Damage: None (probability shift)
Function: Applies phase shift to reduce probability on specific paths
Strategy:
- Place before measurement towers
- Target shortest path to force enemies onto longer paths
- Combine with measurement towers for control
- Press numpad
0-3to select target path
Cost: $200 | Hotkey: 3 | Range: 100px | Damage: 15/sec
Function: Links two nearby enemies - damage is shared (50% transfer)
Strategy:
- Place where enemies group
- Doubles effective damage output
- Very effective against multiple enemies
- Entanglement persists until one dies
Cost: $250 | Hotkey: 4 | Range: 80px (attack) | Damage: 30/sec
Function: Instantly transfers damage across the map using quantum teleportation
Strategy:
- Place at key choke points
- Highest damage output
- Most expensive but most powerful
- Use to cover areas other towers can't reach
- Health: 100 HP
- Speed: 0.02 (moderate)
- Reward: $10
- Coherence Cost: 0.5/second
- Spawn Rate: 70%
Appearance: Blue semi-transparent (superposition) / Red solid (measured)
Strategy: Use measurement towers for reliable takedown
- Health: 100 HP each
- Speed: 0.02 (synchronized)
- Reward: $15 each (total $30)
- Coherence Cost: 0.8/second
- Spawn Rate: 30%
- Special: Damage shared between pair (50% correlation)
Appearance: Purple link connecting entangled enemies
Strategy: Focus damage on one enemy to damage both, use entanglement towers
| Key | Action |
|---|---|
| 1-4 | Select tower type (M, P, E, T) |
| SPACE | Start next wave / Start game |
| ESC | Pause / Resume / Exit |
| R | Restart game (after game over) |
| T | Toggle tutorial |
| Numpad 0-3 | Select path for Phase Tower |
| DELETE/BACKSPACE | Remove selected tower (50% refund) |
| Action | Function |
|---|---|
| Left Click | Place selected tower |
| Right Click | Select tower for removal |
| Hover | Preview tower range |
The game now includes professional visual effects for all quantum operations:
- โจ Measurement Effect: Green expanding circles showing wave function collapse
- ๐ฅ Damage Numbers: Floating red numbers showing damage dealt
- ๐ Phase Effect: Orange rotating particles showing phase manipulation
- ๐ Entanglement Effect: Purple particle links between entangled enemies
- โก Teleportation Effect: Cyan lightning beams showing instant attacks
- Start with Measurement Towers
- Place 2-3 towers covering multiple paths
- Build up economy by defeating enemies
- Diversify tower types
- Add Phase Towers before measurement points
- Place Entanglement Towers in dense areas
- Maximum synergy between tower types
- Add Teleportation Towers for bosses
- Focus fire on high-value targets
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Main Game Loop (60 FPS) โ
โ Input โ Update โ Render โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
Quantum Game Rendering
Engine Logic System
Quantum Engine (quantum_engine/)
- Manages quantum circuits and state vectors
- Handles enemy quantum states and entanglement
- Uses Qiskit for real simulation
Game Logic (game_logic/)
- Tower entities and attack logic
- Enemy spawning and wave progression
- Resource tracking
Rendering (rendering/)
- Main graphics engine
- UI components
- Visual effects system
Configuration (config/)
- Game constants and settings
- Path definitions
- Tower and enemy configurations
quantum-tower-defense/
โโโ main.py # Game entry point
โโโ requirements.txt # Dependencies
โโโ README.md # This file
โ
โโโ config/
โ โโโ __init__.py
โ โโโ game_config.py # Constants
โ
โโโ quantum_engine/
โ โโโ __init__.py
โ โโโ quantum_state.py # Quantum management
โ โโโ enemy_superposition.py # Enemy quantum behavior
โ
โโโ game_logic/
โ โโโ __init__.py
โ โโโ tower.py # Tower types
โ โโโ wave_manager.py # Wave system
โ โโโ resource_manager.py # Resources
โ
โโโ rendering/
โ โโโ __init__.py
โ โโโ game_renderer.py # Graphics
โ โโโ ui.py # UI elements
โ โโโ effects.py # Visual effects
โ
โโโ notebooks/
โโโ 01-quantum-concepts.ipynb
โโโ 02-game-prototype.ipynb
โโโ 03-full-demo.ipynb
We welcome contributions! Please see guidelines for:
- Bug reports
- Feature requests
- Documentation improvements
- Asset contributions
- Quantum accuracy verification
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
- IBM Qiskit Team: For the incredible quantum computing framework
- Pygame Community: For the robust game development library
- Quantum Computing Community: For education and research resources
- GitHub Issues: Report bugs or request features
- Email: For private inquiries
Built with โค๏ธ and โ๏ธ by quantum computing enthusiasts
Making quantum mechanics accessible through gaming!
Last Updated: November 7, 2025 Version: 1.1.0 Status: Production Ready โ