A maze generator and solver that displays it in a (hopefully) pretty way through a LED matrix.
This Proof of Concept of the idea is based on Numberphile's video
"The Lightning Algorithm".
The maze generation currently uses Depth-First Search and Breath-First Search to solve it.
Each of the steps in the BFS are used to do the animation.
Then it uses blaz-r/pi_pico_neopixel library to control the pixels
and try to make some cool patterns.
- Raspberry Pi Pico
- 8x8 WS2812B LED matrix
- 5V power supply
- ...
- Clone the repo
- Connect the Raspberry Pi Pico to your computer
- Upload
Cell.py
,Generation.py
,Maze.py
,Printer.py
,Solver.py
to the pico with those names. (I recommend using something like Thonny) - Upload blaz-r/pi_pico_neopixel
neopixel.py
- Edit variables in
main.py
if necessary for your specific configuration. (If you are copying everything else in these instructions it shouldn't be necessary) - Upload
main.py
. - Connect the pins according to the schematic.
As stated before, I did not focus on performance as this was more of a Proof of Concept of the idea and a way to try micropython and the raspberry pi pico. Nevertheless, this is the current performance:
Grid size: 8x8
Sample size: 500
Minimum Path Length: 40
delay | (ms) |
---|---|
max | 18258 |
min | 92 |
average | 2985.168 |
If the maze generates in less time than the previous animation takes to display it will continue to seamlessly play one animation after the other. This is because the code utilizes the Pico's multithreading option, so while one core is doing the animations,the other is generating the next maze.
Animations usually take around 10 seconds, so a max case of 18 is not ideal. However, only 17/500 took longer than 10 seconds, so I find that acceptable. If you never want to have a delay larger than 10s you should probably decrease the minimum path length a bit.
Any contribution to the project is greatly appreciated, just open a PR.
seib0