Treasure Hunt is built from three focused ES modules that talk to each other through clean import boundaries. The maze engine knows nothing about the DOM; the agent brain knows nothing about buttons or timers; the UI layer owns rendering and input but delegates every rule to the modules below it. This separation means you can swap out the agent difficulty logic, rewrite the renderer, or generate mazes independently without touching the other two files.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/apursley2012/treasure-hunt-game/llms.txt
Use this file to discover all available pages before exploring further.
Module Dependency Graph
The dependency tree is strictly layered — dependencies only flow downward, and there are no circular imports.treasure-maze.js sits at the base of the tree. q-agent.js builds on top of it to power BFS-based policy moves. app.js sits at the top, pulling from both and connecting everything to the browser DOM.
File Structure
How Modules Are Loaded
The entry point is a single<script type="module"> tag in index.html. The browser resolves the import chain natively — no bundler, no build step, no transpilation required.
app.js is loaded as an ES module, all three files are fetched and evaluated in dependency order. The .nojekyll file in the repository root prevents GitHub Pages from interfering with the JavaScript module paths.
Public Exports
treasure-maze.js
| Export | Kind | Description |
|---|---|---|
LEFT | constant | Action integer 0 |
UP | constant | Action integer 1 |
RIGHT | constant | Action integer 2 |
DOWN | constant | Action integer 3 |
ACTION_NAMES | constant | Maps action int → string name |
ACTION_DELTAS | constant | Maps action int → [dr, dc] delta |
ORIGINAL_MAZE | constant | 8×8 fallback maze array |
cloneMaze | function | Deep-copies a maze array |
key | function | Serializes (row, col) to "row,col" string |
sameCell | function | Compares two [row, col] pairs |
shuffle | function | Fisher-Yates in-place shuffle |
isInside | function | Bounds check for a grid cell |
openNeighborCount | function | Counts passable neighbors of a cell |
findShortestPath | function | BFS path from start to target |
createRandomMaze | function | Procedurally generates a solvable 8×8 maze |
TreasureMaze | class | Full game-environment class |
q-agent.js
| Export | Kind | Description |
|---|---|---|
DIFFICULTY_SETTINGS | constant | Three-level config object (easy / medium / hard) |
CompetitiveAgent | class | BFS-driven AI opponent with hesitation and exploration |
Module Pages
TreasureMaze Module
Full API reference for
treasure-maze.js — the TreasureMaze class, createRandomMaze, findShortestPath, and all exported constants.Q-Agent Module
Full API reference for
q-agent.js — the CompetitiveAgent class and DIFFICULTY_SETTINGS that power the AI opponent.App Module
How
app.js wires the game engine and agent to the DOM — rendering, input handling, race timer, and HUD updates.