ZK.← Selected work
Algorithms / Systems integrationActively refining

Project / 03

A* vs Dijkstra Maze Visualizer

An ncurses C++ visualizer that generates randomized mazes, runs A* and Dijkstra over the same grid, compares their work, and saves layouts through the separate Redis-compatible server.

Architecture / Request path

How the pieces connect.

  1. 01Recursive backtracker
  2. 02Cell-bitmask grid
  3. 03A* + Dijkstra
  4. 04Metrics
  5. 05TCP / RESP storage

01 / Problem

Why I built it

Textbook descriptions show that A* uses a heuristic and Dijkstra does not, but they do not make the resulting search behavior tangible. I wanted to watch both algorithms solve the exact same maze and measure what each one actually did.

02 / Design

System shape

Randomized depth-first search with backtracking generates the maze. Cells store open directions as bit flags. Both pathfinders share the same search structure: Dijkstra prioritizes distance from the start, while A* adds Manhattan distance to the destination. Parent indices reconstruct both final paths.

03 / Implementation

What the code actually does

  • 01

    Recursive-backtracking maze generation over a compact cell-bitmask representation

  • 02

    A* and Dijkstra running against the same grid and endpoints

  • 03

    Path reconstruction plus explored-node, path-length, and timing metrics

  • 04

    ncurses rendering and keyboard input for macOS and Linux terminals

  • 05

    A POSIX TCP client that serializes mazes and uses RESP SET/GET with the Mini Redis server

04 / Decisions

Engineering choices

01

Use one grid

Both algorithms operate on the same maze and endpoints, removing different inputs as a source of misleading comparisons.

02

Measure more than time

Explored nodes and path length explain algorithm behavior when microsecond timings are dominated by overhead and system noise.

03

Keep storage external

The visualizer communicates through TCP and RESP instead of importing server code, preserving a real client-server boundary.

Concrete outcomes

01
2 algorithms / 1 grid
02
Runtime comparison
03
Redis save and load

Observed while building

  • A* can explore fewer nodes yet lose a tiny timing comparison because its heuristic adds per-node work.
  • Algorithmic complexity predicts scaling; profiling describes this implementation, input, and machine.
  • Serialization and validation are what let an in-memory maze safely cross a process boundary.

Next iteration

Expand malformed-input tests, compare larger maze sizes, and improve benchmark reporting without changing the shared-grid experiment.

C++A*DijkstrancursesRESP