Skip to content

Interactive PyQt6 2D/3D Tower of Hanoi visualizer with animated moves, recursion call tree, and depth chart.

License

Notifications You must be signed in to change notification settings

jguida941/HanoiVisualizer3D

Repository files navigation

HanoiVisualizer3D

An interactive Tower of Hanoi visualizer built with PyQt6, featuring both 2D and 3D animated views, a recursion call tree, and a depth chart.

Features

  • 2D Animation: Watch disks move in real time on a QGraphicsView.
  • 3D Visualization: Matplotlib 3D bar charts.
  • Recursion Call Tree: Expandable tree view of recursive calls and disk moves.
  • Depth Chart: Matplotlib chart plotting recursion depth over each move.
  • Controls:
    • Start: Run full animation automatically.
    • Step: Perform one move at a time.
    • Speed Slider: Adjust animation interval between moves.
    • Move Counter: Track current move number.
    • Reset: Clear the board and start over.
    • Disk Selector: Choose number of disks (1–10).

Requirements

  • Python 3.10 or higher
  • PyQt6 (Qt GUI bindings)
  • Matplotlib (for 2D/3D plotting)

Quick start (recommended):

# From the project folder
make venv
make install
make run

Manual setup:

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt

Notes:

  • On macOS, run from Terminal/iTerm (not Code Runner) and ensure VS Code uses your venv interpreter.

Developer workflow:

  • Use make venv then make install to set up.
  • Run the app with make run.
  • Run tests with make test (this installs dev deps and sets PYTHONPATH so imports resolve without changing code).

Screenshots

2D View:

2D View

3D View:

3D View

Recursion Call Tree:

Call Tree

Depth Chart:

Depth Chart

Usage

Run from the project directory:

# Option 1: Makefile (recommended)
make run

# Option 2: Directly with Python
python main.py

Keyboard shortcuts:

  • Space: Start/Pause
  • N: Step once
  • R: Reset

Layout tips:

  • Docks are resizable: drag the borders to make the right “Depth Chart” and bottom “3D View” larger or smaller.
  • The app opens with a larger window and increased default sizes for both charts for readability.

Troubleshooting:

  • “ModuleNotFoundError: PyQt6” → install deps with pip install -r requirements.txt.
  • “Qt platform plugin could not be initialized” on macOS/Linux → run from a real terminal and ensure the venv is active; try pip install --upgrade PyQt6.
  • Blank/slow plots on first run → ensure matplotlib installed via the steps above.

Notes for Windows:

  • Activate the venv with .venv\\Scripts\\activate.
  • Replace make commands with the equivalent steps:
    • python -m venv .venv && .venv\\Scripts\\python -m pip install --upgrade pip
    • pip install -r requirements.txt
    • python main.py

License

Evaluation only all rights reserved.

You may clone and run locally for personal or hiring evaluation.
You may not redistribute, sublicense, or use this work commercially without my written permission.

See the LICENSE file for the exact terms.

Qt note: This app uses PyQt6 (GPLv3). Do not redistribute the app unless you comply with GPLv3 or have a Qt commercial license.

About

Interactive PyQt6 2D/3D Tower of Hanoi visualizer with animated moves, recursion call tree, and depth chart.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published