Skip to content

About

A static visualization tool for solving the optimal path in a triangle maze with dynamic programming.

Topics

Resources

Stars

53 stars

Watchers

0 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

Repository files navigation

Triangle Light Maze Solver

Created and maintained by Jingming Liang, featured by Lamplighter Commons.

An interactive visualization of dynamic programming. Build a triangular maze, mark its glowing nodes, and find a path from the top to the bottom that collects the most lights.

Open the live demo · 中文说明 · Report an issue

Runs entirely in your browser. No installation, dependencies, or build step. The application interface is currently in Chinese.

Preview

Maze editor Solved example
Triangle maze editor Solved maze with its optimal path highlighted

Features

  • Create and edit triangular mazes with 1–30 rows.
  • Toggle glowing nodes with mouse or keyboard controls.
  • Visualize the optimal path and inspect the dynamic programming table.
  • Choose left or right preference when paths have the same score.
  • See the score, captured lights, capture rate, and algorithm complexity.
  • Load an example, clear the lights, or reset the maze.
  • Download the project and use it offline.

Try it

  1. Enter the number of rows and select 生成迷阵 (Generate maze).
  2. Select nodes to mark them as glowing.
  3. Choose a tie-breaking preference.
  4. Select 运行求解 (Run solver) to see the result.

For a quick example, select 查看示例解 (Show example solution). 清空发光点 clears the lights while preserving the maze; 完全重置 resets the maze and results.

Run locally

Download or clone the repository, then open index.html in your browser. You can also serve the directory locally:

python3 -m http.server 8000

Open http://localhost:8000.

How it works

The solver uses dynamic programming followed by path reconstruction:

  • dp[r][c] stores the maximum number of glowing nodes collected on a path from the top to node (r, c).
  • parent[r][c] records the selected parent in the previous row.
  • The best endpoint in the last row is selected, then the path is reconstructed through the parent entries.

For equal scores, preferLeft selects the left parent or endpoint; preferRight selects the right one. Time and space complexity are both O(n²).

Development checks

Run these from the repository root with Node.js installed:

node --test tests/solver.test.js
node scripts/smoke-test.js
node scripts/check-release.js

The first command checks the solver, the second runs a smoke check, and the third checks release assets and documentation references.

Contributing

Bug reports, clearer explanations, accessibility improvements, and code contributions are welcome. See the contribution guide. Issues and pull requests may be written in English or Chinese.

If you find this project useful, consider starring it, sharing it, or contributing.

License

MIT. Created and maintained by Jingming Liang.

About

A static visualization tool for solving the optimal path in a triangle maze with dynamic programming.

Topics

Resources

Stars

53 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages