1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 14:18:13 +01:00
dotSCAD/docs/lib3x-mz_hamiltonian.md

32 lines
1.3 KiB
Markdown
Raw Normal View History

2020-12-24 17:11:09 +08:00
# mz_hamiltonian
Creates a hamiltonian path from a maze. The path is the result of maze traversal using [Wall follower](https://en.wikipedia.org/wiki/Maze_solving_algorithm#Wall_follower).
**Since:** 2.5
## Parameters
- `rows` : The rows of a maze.
- `columns` : The columns of a maze.
- `start` : The start point to travel the maze. Default to `[0, 0]`.
2022-08-27 15:36:50 +08:00
- `init_cells` : You can define your own initial cell data, a 2-dimension list of `[x, y, type, visited]`. `visited` means the cell is visited or not. A visited cell won't be visited when traveling the maze. If you don't provide `init_cells`, `mz_square` will generate one automatically. If you provide `init_cells`, `rows` and `columns` will be ignored. **Since:** 3.3
2020-12-24 17:11:09 +08:00
- `seed` : The maze is traveling randomly. Use `seed` to initialize the pseudorandom number generator.
## Examples
2022-06-06 13:11:46 +08:00
use <maze/mz_hamiltonian.scad>
use <polyline_join.scad>
2020-12-24 17:11:09 +08:00
rows = 5;
columns = 10;
path = mz_hamiltonian(rows, columns, [0, 0]);
2021-12-04 10:57:29 +08:00
polyline_join(path)
circle(.25);
2020-12-24 17:11:09 +08:00
2021-02-24 21:09:54 +08:00
![mz_hamiltonian](images/lib3x-mz_hamiltonian-1.JPG)
2020-12-24 17:11:09 +08:00
The [senbon_torii](https://github.com/JustinSDK/dotSCAD/blob/master/examples/maze/senbon_torii.scad) is based on `mz_hamiltonian`.
2021-02-24 21:09:54 +08:00
![mz_hamiltonian](images/lib3x-mz_hamiltonian-2.JPG)