Skip to main content

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.

Treasure Hunt is a fully static app — no build step, no package manager, and no dependencies to install. However, because index.html loads app.js as a type="module" script, browsers enforce CORS rules that block module imports when a page is opened via the file:// protocol. Running a local HTTP server takes a single terminal command and sidesteps this entirely.

Why a Local Server Is Needed

The final line of index.html loads the game logic as an ES module:
<script type="module" src="./assets/js/app.js"></script>
app.js then imports from two sibling modules — treasure-maze.js and q-agent.js — using bare relative paths. Browsers treat file:// origins as opaque and refuse cross-file module imports under that scheme. In practice this means opening index.html by double-clicking it will produce a blank board and a CORS error in the DevTools console. Serving the files over http://localhost gives every module a proper origin and the imports resolve correctly. Python 3 ships with a zero-configuration static server. No install and no configuration file required.
1

Open a terminal in the project folder

Navigate to the root of the repository — the directory that contains index.html.
cd path/to/treasure-hunt-game
2

Start the HTTP server

python -m http.server 8000
You should see output like Serving HTTP on 0.0.0.0 port 8000.
3

Open the game in your browser

Visit http://localhost:8000. The game loads immediately — no build output to wait for.

All Server Options

python -m http.server 8000
All three serve the project on port 8000 and support the type="module" imports that app.js requires. Open http://localhost:8000 in any case.

What to Expect When the Server Starts

Once the page loads you will see the full game interface immediately — no loading spinner or build output. Specifically:
  • A fresh randomized 8×8 maze is generated automatically via createRandomMaze() in app.js.
  • Both the player (●) and the agent (🤖) start at position [0, 0] — the top-left cell.
  • The HUD above the board shows Ready in the status pill, reward at 0.00, and player and agent steps both at 0.
  • The Game Log at the bottom displays the shortest route length for the current maze.
  • The difficulty selector defaults to Medium.
You can click New Maze to generate a different board, select a difficulty, then click Start Race to begin.

File Structure Recap

Only two things need to be present for the game to run — the HTML entry point and the assets/ folder:
treasure-hunt-game/
├── index.html          ← entry point
└── assets/
    ├── css/
    │   └── styles.css
    ├── js/
    │   ├── app.js
    │   ├── q-agent.js
    │   └── treasure-maze.js
    └── images/
        ├── treasure-hunt-logo.png
        ├── treasure-hunt-mark.svg
        └── favicon.svg
There is no package.json, no node_modules, and no build output. The server serves these files as-is.
If the board renders but the agent does not appear on the grid, confirm that app.js is loading as a type="module" script. Check the <script> tag at the bottom of index.html — it must read <script type="module" src="./assets/js/app.js"></script>. Also verify you are accessing the page over http://localhost and not the file:// protocol.
VS Code users can install the Live Server extension (by Ritwick Dey) and click Go Live in the status bar. Live Server starts a local HTTP server, opens the page in your default browser, and auto-reloads whenever you save a file — handy for iterating on styles.css or the JavaScript modules.

Build docs developers (and LLMs) love