From db13cfa496270f6d605679e403ded9bb75c0ff1d Mon Sep 17 00:00:00 2001 From: Sebby1770 <274013474+Sebby1770@users.noreply.github.com> Date: Sat, 11 Jul 2026 01:14:39 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20add=20Pathfinding=20Lab=20=E2=80=94=206?= =?UTF-8?q?=20algorithms,=20grid=20editor,=20mazes,=20live=20re-path=20(v5?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns Sort Lab into Algorithm Lab with a second visualizer mode: - BFS, DFS, Dijkstra, A*, Greedy Best-First, and Bidirectional BFS on an interactive grid with walls, weighted terrain (cost x5), and draggable start/goal markers that re-solve the path live after a run - Recursive-division maze generator (odd-lattice walls, even-lattice gaps and endpoints, so every maze is guaranteed solvable), plus random scatter and weighted-terrain generators - Optional diagonal movement with octile heuristic and no corner-cutting - Per-algorithm profile panel (guarantee, complexity, weight-awareness) and live metrics (visited, steps, cost, compute time) - Mode tabs with per-mode keyboard shortcuts; sorting shortcuts no longer fire in pathfinding mode - Fix: workspaces with the hidden attribute now actually hide (the .workspace display:grid rule was overriding the UA [hidden] style) - SW cache bumped to v4, precaches pathfinding.js; manifest/README/ CHANGELOG rebranded to Algorithm Lab Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 23 +- README.md | 38 ++- index.html | 115 +++++++- manifest.json | 6 +- pathfinding.js | 770 +++++++++++++++++++++++++++++++++++++++++++++++++ script.js | 1 + style.css | 188 +++++++++++- sw.js | 5 +- 8 files changed, 1127 insertions(+), 19 deletions(-) create mode 100644 pathfinding.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 157e1ae..16d4d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,27 @@ # Changelog -All notable changes to Sort Lab (Algorithm Visualizer). +All notable changes to Algorithm Lab (formerly Sort Lab). + +## [2026-07-11] — v5 Pathfinding Lab + +### Added +- **Pathfinding mode** — a second visualizer alongside sorting, switchable via new topbar tabs +- **Six pathfinding algorithms**: Breadth-First Search, Depth-First Search, Dijkstra's Algorithm, A* Search, Greedy Best-First, and Bidirectional BFS +- **Interactive grid editor** — drag to draw walls, weighted cells (cost ×5), or erase; drag the start/goal markers; after a run the path re-solves live while dragging +- **Maze & terrain generators** — recursive-division maze (guaranteed solvable), random scatter walls, and scattered weights +- **Diagonal movement** option with octile heuristic and no corner-cutting +- **Algorithm profile panel** — shortest-path guarantee, complexity, and weight-awareness badges per algorithm +- **Live metrics** — visited cells, path steps, path cost, and compute time +- **Pathfinding keyboard shortcuts**: `V` visualize · `C` clear path · `B` clear board · `M` maze +- Three grid sizes (25×15, 37×21, 49×27) with full touch support + +### Changed +- Rebranded **Sort Lab → Algorithm Lab**; PWA manifest, title, and README updated +- Service worker cache bumped to v4 and now precaches `pathfinding.js` +- Sorting keyboard shortcuts are scoped to sorting mode so the two modes don't clash + +### Fixed +- `hidden` attribute on workspaces is now honored (explicit `display: none` override) ## [2026-07-05] — v4 Feature Expansion diff --git a/README.md b/README.md index b029969..e397af5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,31 @@ -# Sort Lab — Sorting Algorithm Visualizer +# Algorithm Lab — Sorting & Pathfinding Visualizer -An interactive, animated sorting algorithm visualizer built with pure HTML, CSS, and vanilla JavaScript — no frameworks, no build step. +An interactive, animated algorithm visualizer built with pure HTML, CSS, and vanilla JavaScript — no frameworks, no build step. Two labs in one app: **Sorting** and **Pathfinding**, switchable from the topbar. -![Sort Lab](https://img.shields.io/badge/algorithms-8-blue) ![PWA](https://img.shields.io/badge/PWA-offline-purple) +![Algorithms](https://img.shields.io/badge/sorting_algorithms-10-blue) ![Pathfinding](https://img.shields.io/badge/pathfinding_algorithms-6-teal) ![PWA](https://img.shields.io/badge/PWA-offline-purple) -## Features +## Pathfinding Lab -### Algorithms (8) +- **Six algorithms** — BFS, DFS, Dijkstra, A*, Greedy Best-First, Bidirectional BFS +- **Interactive grid** — drag to draw walls or weighted terrain (cost ×5), drag the start/goal markers, and watch the path re-solve live after a run +- **Mazes & terrain** — recursive-division maze (always solvable), random scatter, scattered weights +- **Diagonal movement** option (octile heuristic, no corner-cutting) +- **Per-algorithm profile** — shortest-path guarantee, complexity, weight-awareness +- **Live metrics** — visited cells, path steps, path cost, compute time +- Shortcuts: `V` visualize · `C` clear path · `B` clear board · `M` maze + +| Algorithm | Weighted | Shortest path | Complexity | +|-----------|----------|---------------|------------| +| BFS | No | ✅ (unweighted) | O(V + E) | +| DFS | No | ❌ | O(V + E) | +| Dijkstra | Yes | ✅ | O((V + E) log V) | +| A* | Yes | ✅ | O((V + E) log V) | +| Greedy Best-First | Yes | ❌ | O((V + E) log V) | +| Bidirectional BFS | No | ✅ (unweighted) | O(V + E) | + +## Sorting Lab + +### Algorithms (10) - Bubble Sort - Selection Sort - Insertion Sort @@ -15,6 +34,8 @@ An interactive, animated sorting algorithm visualizer built with pure HTML, CSS, - Heap Sort - **Shell Sort** — gap-based insertion with diminishing gaps - **Radix Sort** — LSD digit passes with bucket visualization +- **Counting Sort** — counting-array panel visualization +- **Cocktail Shaker Sort** — bidirectional bubble sweep ### Dataset Generators | Type | Description | @@ -53,9 +74,10 @@ An interactive, animated sorting algorithm visualizer built with pure HTML, CSS, ``` algorithm-visualiser/ -├── index.html # Lab UI layout -├── style.css # Theming, sidebar, race mode, responsive -├── script.js # Algorithms, metrics, race mode, tournament, teaching +├── index.html # Lab UI layout (sorting + pathfinding views) +├── style.css # Theming, sidebar, race mode, pathfinding grid, responsive +├── script.js # Sorting: algorithms, metrics, race mode, tournament, teaching +├── pathfinding.js # Pathfinding: grid editor, 6 algorithms, mazes, live re-path ├── sw.js # Service worker for offline caching ├── manifest.json # PWA manifest ├── CHANGELOG.md # Version history diff --git a/index.html b/index.html index eced353..76a982f 100644 --- a/index.html +++ b/index.html @@ -3,9 +3,9 @@ - + - Sort Lab — Algorithm Visualizer + Algorithm Lab — Sorting & Pathfinding Visualizer @@ -15,10 +15,14 @@
-

Sort Lab

+

Algorithm Lab

Sorting Algorithm Visualizer

+
@@ -30,7 +34,7 @@

Sort Lab

-
+
+ +