GAME DEV ยท MAY 2026

Sorting & Maze Visualizer

A step-based algorithm visualizer in two parts: three sorting algorithms on colour-coded bars and three pathfinding algorithms on a procedural maze. Every algorithm runs one step per frame, so each comparison, swap and explored cell is visible.

  • C++
  • Raylib
  • Algorithms
  • Data Structures
Sorting & Maze Visualizer screenshot

At a glance

ROLE
Solo developer
TEAM
Solo
CONTEXT
Algorithms and data structures course assignment

What I built

  • Bubble, selection and insertion sort with colour-coded bars and comparison and swap counters.
  • BFS, DFS and A* on a 25 x 25 maze. A* estimates the grid steps left to the goal to decide where to search next.
  • Maze generation with a recursive backtracker, so every maze is solvable and has exactly one path between two cells.
  • A scene manager that switches between the menu and the visualizers.
  • Visit order stored per cell, which drives the blue discovery gradient.
  • An animated mouse that walks the solution route to the cheese.

Technical decision

One search step per frame

Each searcher keeps its whole state in members (the open heap, the costs, the parents and the visit order), and Step() expands one cell and returns. The visualizer calls it once per frame and draws the state in between, so there are no threads or coroutines. The A* class is Dijkstra with one difference: the heap is ordered by the cost so far plus an estimate of the steps left to the goal, counted along the grid as if there were no walls.

AStarSearcher.cpp
bool AStarSearcher::Step(const Maze& maze)
{
    if (m_done || m_heap.empty())
    {
        m_done = true;
        return true;
    }

    PQEntry top = m_heap.top();
    m_heap.pop();
    Cell current = top.second;

    if (current == m_goal)
    {
        m_path = ReconstructPath(maze.Start(), m_goal);
        m_done = true;
        return true;
    }

    for (Cell neighbour : maze.GetNeighbours(current))
    {
        float newCost = m_costSoFar[current] + 1.0f;

        if (m_costSoFar.find(neighbour) == m_costSoFar.end() ||
            newCost < m_costSoFar[neighbour])
        {
            m_costSoFar[neighbour] = newCost;
            m_cameFrom[neighbour] = current;
            m_visited[neighbour] = m_discoveryOrder++;

            // Key A* difference (push g + h)
            float fCost = newCost + Heuristic(neighbour, m_goal);
            m_heap.push({ fCost, neighbour });
        }
    }

    return false;
}
Snippet of one method. The full class is in the public repo.โ†— VIEW ON GITHUB