-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpathfinding.html
More file actions
232 lines (207 loc) · 10 KB
/
Copy pathpathfinding.html
File metadata and controls
232 lines (207 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Interactive pathfinding visualizer with BFS, DFS, Dijkstra, A*, greedy best-first, bidirectional BFS, maze generators, and race mode." />
<meta name="theme-color" content="#0b1220" />
<title>Algo Lab — Pathfinding Visualizer</title>
<link rel="manifest" href="manifest.json" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app-shell">
<header class="topbar">
<div class="topbar-start">
<div class="brand">
<span class="brand-mark" aria-hidden="true">⚗</span>
<div>
<h1>Algo Lab</h1>
<p class="brand-sub">Pathfinding Visualizer</p>
</div>
</div>
<nav class="lab-switcher" aria-label="Choose a lab">
<a class="lab-pill" href="index.html">Sort Lab</a>
<a class="lab-pill is-active" href="pathfinding.html" aria-current="page">Path Lab</a>
</nav>
</div>
<div class="topbar-actions">
<button id="shareUrlBtn" class="btn btn-ghost btn-sm" type="button" title="Copy shareable URL">🔗 Share</button>
<label class="toggle-pill" title="Sound effects on expand/path">
<input type="checkbox" id="soundToggle" aria-label="Toggle sound" />
<span>🔊 Sound</span>
</label>
<button id="themeToggle" class="icon-btn" aria-label="Toggle dark mode">🌙</button>
</div>
</header>
<div class="workspace">
<aside class="sidebar">
<section class="panel">
<h2 class="panel-title">Controls</h2>
<div class="field">
<label for="algorithm">Algorithm</label>
<select id="algorithm">
<option value="bfs">Breadth-First Search</option>
<option value="dfs">Depth-First Search</option>
<option value="dijkstra">Dijkstra</option>
<option value="astar" selected>A*</option>
<option value="greedy">Greedy Best-First</option>
<option value="bidirectionalBfs">Bidirectional BFS</option>
</select>
</div>
<div class="field race-field">
<label class="checkbox-row">
<input type="checkbox" id="raceMode" />
<span>Algorithm Race (dual pane)</span>
</label>
<select id="algorithmRace" disabled>
<option value="bfs">Breadth-First Search</option>
<option value="dfs">Depth-First Search</option>
<option value="dijkstra" selected>Dijkstra</option>
<option value="astar">A*</option>
<option value="greedy">Greedy Best-First</option>
<option value="bidirectionalBfs">Bidirectional BFS</option>
</select>
</div>
<div class="field">
<label for="maze">Maze / Map</label>
<select id="maze">
<option value="empty">Empty</option>
<option value="backtracker">Recursive Backtracker</option>
<option value="prim">Prim</option>
<option value="division">Recursive Division</option>
<option value="binary">Binary Tree</option>
<option value="scatter">Scatter Walls</option>
</select>
</div>
<div class="field">
<label for="rows">Rows: <span id="rowsValue">21</span></label>
<input type="range" id="rows" min="8" max="41" value="21" />
</div>
<div class="field">
<label for="cols">Cols: <span id="colsValue">41</span></label>
<input type="range" id="cols" min="8" max="61" value="41" />
</div>
<div class="field">
<label for="speed">Speed: <span id="speedValue">70</span></label>
<input type="range" id="speed" min="1" max="100" value="70" />
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="diagonal" />
<span>Diagonal movement</span>
</label>
</div>
<div class="field">
<span class="field-legend" id="brushLegend">Brush</span>
<div class="brush-pills" role="radiogroup" aria-labelledby="brushLegend">
<label class="brush-pill">
<input type="radio" name="brush" value="wall" checked />
Wall
</label>
<label class="brush-pill">
<input type="radio" name="brush" value="weight" />
Weight
</label>
<label class="brush-pill">
<input type="radio" name="brush" value="erase" />
Erase
</label>
</div>
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="stepMode" />
<span>Step Mode (manual advance)</span>
</label>
</div>
<div class="field">
<label class="checkbox-row">
<input type="checkbox" id="teachingMode" />
<span>Teaching Mode (narrated steps)</span>
</label>
</div>
<div class="btn-grid">
<button id="generateBtn" class="btn btn-secondary" title="Shortcut: G">Generate Maze</button>
<button id="startBtn" class="btn btn-primary" title="Shortcut: S">Start</button>
<button id="pauseBtn" class="btn btn-secondary" disabled title="Shortcut: Space">Pause</button>
<button id="stopBtn" class="btn btn-danger" disabled title="Shortcut: Esc">Stop</button>
<button id="nextStepBtn" class="btn btn-accent" disabled>Next Step</button>
<button id="clearPathBtn" class="btn btn-secondary" title="Shortcut: C">Clear Path</button>
<button id="resetBtn" class="btn btn-secondary" title="Shortcut: R">Reset Board</button>
</div>
<button id="tournamentBtn" type="button" class="btn btn-accent btn-full" title="Run all 6 algorithms on the current board">🏆 Algorithm Tournament</button>
<p class="shortcut-hint">Space pause · S start · G maze · R reset · C clear · Esc stop · 1 wall · 2 weight · 3 erase</p>
</section>
<section class="panel" id="profilePanel" aria-live="polite"></section>
<section class="panel" id="learningCardsPanel">
<h2 class="panel-title">Learning Cards</h2>
<p class="panel-sub">Tap to flip — trivia & real-world use cases</p>
<div id="learningCard" class="learning-card" tabindex="0" role="button" aria-label="Flip learning card">
<div class="learning-card-inner">
<div class="learning-card-front">
<span class="learning-card-label">Did you know?</span>
<p id="learningTrivia" class="learning-card-text"></p>
</div>
<div class="learning-card-back">
<span class="learning-card-label">Use case</span>
<p id="learningUseCase" class="learning-card-text"></p>
</div>
</div>
</div>
</section>
<section class="panel" id="tournamentPanel" hidden>
<h2 class="panel-title">Tournament Leaderboard</h2>
<p class="panel-sub">Ranked by path cost, then nodes expanded, then time</p>
<div id="leaderboard" class="leaderboard-wrap"></div>
</section>
<section class="panel">
<h2 class="panel-title">Run History</h2>
<ul id="historyList" class="history-list"></ul>
</section>
</aside>
<main class="main-stage">
<p id="statusText" class="status-bar" aria-live="polite" role="status">Ready</p>
<section id="teachingPanel" class="teaching-panel hidden" aria-labelledby="teachingTitle">
<h3 id="teachingTitle" class="teaching-title">Teaching Mode</h3>
<p id="teachingText" class="teaching-text" aria-live="assertive" aria-atomic="true">Enable Teaching Mode to see step-by-step explanations.</p>
</section>
<div class="viz-grid" id="vizGrid">
<section class="viz-pane" id="panePrimary">
<div class="pane-header">
<h3 id="panePrimaryLabel">Primary</h3>
<div id="metricsPrimary" class="metrics-strip"></div>
</div>
<div class="path-grid-wrap">
<div id="pathGrid" class="path-grid" role="grid" aria-label="Pathfinding grid"></div>
</div>
</section>
<section class="viz-pane hidden" id="paneSecondary">
<div class="pane-header">
<h3 id="paneSecondaryLabel">Race</h3>
<div id="metricsSecondary" class="metrics-strip"></div>
</div>
<div class="path-grid-wrap">
<div id="pathGridRace" class="path-grid" role="grid" aria-label="Pathfinding race grid"></div>
</div>
</section>
</div>
<section class="legend" id="legend">
<div class="legend-item"><span class="swatch path-empty"></span> Empty</div>
<div class="legend-item"><span class="swatch path-wall"></span> Wall</div>
<div class="legend-item"><span class="swatch path-start"></span> Start (S)</div>
<div class="legend-item"><span class="swatch path-end"></span> End (E)</div>
<div class="legend-item"><span class="swatch path-weight"></span> Weight (●)</div>
<div class="legend-item"><span class="swatch path-frontier"></span> Frontier</div>
<div class="legend-item"><span class="swatch path-visited"></span> Visited</div>
<div class="legend-item"><span class="swatch path-path"></span> Path</div>
</section>
</main>
</div>
</div>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<div id="a11yAnnouncer" class="sr-only" aria-live="assertive" aria-atomic="true"></div>
<script src="pathfinding-core.js"></script>
<script src="pathfinding.js"></script>
</body>
</html>