mikepound / mazesolving

A variety of algorithms to solve mazes from an input image
The Unlicense
1.74k stars 411 forks source link

maze generation in python visuals #13

Open Roel1988 opened 7 years ago

Roel1988 commented 7 years ago

Hi Mike, I have a question regarding visualization in python of your maze generation with a* start algoritm. Is there a way to visualize the maze being solved in real time (i.e. show the grid with the openset and the close set)?

I worked something out using graphics.py and in the past I used pygame. However somehow it was very taxing on the process.'

What package do you recon is best to use for real time visualisation in python?

Greetings Roel

mikepound commented 7 years ago

Hi Roel,

Sorry for the slow reply - much work to be getting on with! I don't see why you couldn't do this, essentially you'd have to have the solve function report back some information each iteration. E.g. currently explored nodes, nodes in the queue, etc. The code to visualise is a bit simple in my implementation, so it only copies the original image, then draws over the path as a list of points. Doing that every iteration would be quite slow.

OpenCV has some pretty good gui stuff, and works nicely in python. Doing this efficiently will involve holding onto information from the previous frame, so that you can "undo" the last render before drawing on the next one. A simple first implementation could just create the image from scratch each time. You may not need to run in real time, as that'd be too quick to see anyway, so you could just output to a file and then turn the images into a video at the end.

Mike

Roel1988 commented 7 years ago

Hi Mike, sorry for my late reply as well. Many thanks for your answer. As I am not a skilled programmer it took me a while to illustrate my point. I just did a very simple implementation of the algo you showed. However my visualisation is getting slower with every iteration. Probably my lack of understanding python graphics. Keep up the good work and videos'

Best Regards,

Roel AStar_temp.py.txt graphics.py.txt