I have built a feature-rich, interactive Tower of Hanoi web application with React, Vite, and Tailwind CSS.
Key Features Included:
-
Interactive Disks & Pegs:
- Dual Input Controls: Full HTML5 Drag-and-Drop, Touch/Pointer support, and Tap-to-Select peg interactions.
- Keyboard Navigation: Press keys
1, 2, 3 or A, B, C to move disks quickly, plus Ctrl+Z (Undo) and Ctrl+Y (Redo).
- Customizable Disk Count: Supports 3 to 10 disks with size progression and color-coded labels.
-
Move Validation & Feedback:
- Strictly enforces puzzle rules: only top disks can move, and larger disks cannot be placed on smaller ones.
- Visual error feedback with shake animation, toast message warnings, and audio feedback on invalid drop attempts.
-
Optimal Move Tracking & Move History:
- Computes exact optimal moves (2n−1) for any selected disk count (n).
- Calculates player efficiency percentage, logs full chronological move history, and provides Undo/Redo capabilities.
- Hint System: Highlights the exact optimal source and destination peg for the player's next move.
-
Auto-Solve Visualization:
- Solves the puzzle recursively step-by-step from the initial state or from any arbitrary intermediate board configuration.
- Playback Controls: Play, Pause, Step Forward, Step Backward, Restart, and Speed Slider (0.5× to 10×).
- Live step explanations and auto-solver progress bar.
-
5 Visual Themes:
- Cyberpunk Neon, Classic Mahogany Wood, Frosted Glass, Vibrant Spectrum, and Obsidian Minimal.
-
Interactive Gameplay Modes:
- Classic Mode: Standard puzzle with move counter and optimal comparison.
- Speedrun Mode: Precision timer for speedrunners.
- Sandbox Mode: Freely move or scatter disks onto any peg to create custom setups and find optimal solutions.
-
Educational Science & Math Section:
- Interactive Sierpiński Gasket State Graph: Renders the fractal state space graph (3n states) in real-time SVG and tracks the current puzzle position.
- Mathematical proof (M(n)=2n−1), Binary Gray Code connection, and the Ancient Legend of Brahma's 64 disks.
-
Celebration & Stats:
- Web Audio API sound effects pitch-scaled by disk size.
- Canvas Confetti burst and 3-star rating upon solving.
- Local records and best times stored per disk count.
Files built: index.html, src/utils/sound.ts, src/utils/themes.ts, src/utils/hanoiLogic.ts, src/components/Disk.tsx, src/components/Peg.tsx, src/components/Header.tsx, src/components/AutoSolveControls.tsx, src/components/MoveHistory.tsx, src/components/SandboxToolbar.tsx, src/components/HanoiBoard.tsx, src/components/EducationalModal.tsx, src/components/VictoryModal.tsx, src/components/StatsModal.tsx, src/App.tsx, src/index.css